blob: 01670cd4f51504c28f3632e482275fe5d9599758 [file] [log] [blame]
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001#!/bin/sh
2# Copyright (C) 2016 O.S. Systems Software LTDA.
3# Copyright (C) 2016 Freescale Semiconductor
4
5export PATH="/sbin:/usr/sbin:/bin:/usr/bin"
6
7usage() {
Brad Bishopc342db32019-05-15 21:57:59 -04008 cat <<EOF
Andrew Geissler7e0e3c02022-02-25 20:34:39 +00009 $0 [<weston options>]
Patrick Williamsc0f7c042017-02-23 20:41:17 -060010EOF
11}
12
13## Module support
14modules_dir=@DATADIR@/weston-start
15
16# Add weston extra argument
17add_weston_argument() {
18 weston_args="$weston_args $1"
19}
20
Andrew Geisslereff27472021-10-29 15:35:00 -050021## Add module to --modules argument
22add_weston_module() {
23 if [[ "x${weston_modules}" == "x" ]]; then
24 weston_modules="--modules "
25 fi;
26 weston_modules+="${1},"
Patrick Williamsc0f7c042017-02-23 20:41:17 -060027}
28
29if [ -n "$WAYLAND_DISPLAY" ]; then
30 echo "ERROR: A Wayland compositor is already running, nested Weston instance is not supported yet."
31 exit 1
32fi
Brad Bishopc342db32019-05-15 21:57:59 -040033
34if [ -n "$WESTON_USER" ]; then
Andrew Geissler6ce62a22020-11-30 19:58:47 -060035 if [ -z "$WESTON_GROUP" ]; then
36 # no explicit WESTON_GROUP given, therefore use WESTON_USER
37 export WESTON_GROUP="${WESTON_USER}"
38 fi
Brad Bishopc342db32019-05-15 21:57:59 -040039fi
40
Patrick Williamsc0f7c042017-02-23 20:41:17 -060041weston_args=$*
42
43# Load and run modules
44if [ -d "$modules_dir" ]; then
45 for m in "$modules_dir"/*; do
46 # Skip backup files
47 if [ "`echo $m | sed -e 's/\~$//'`" != "$m" ]; then
48 continue
49 fi
50
51 # process module
52 . $m
Andrew Geisslereff27472021-10-29 15:35:00 -050053 if [[ x"{$weston_modules}" != "x" ]]; then
54 add_weston_argument "${weston_modules}"
55 fi;
Patrick Williamsc0f7c042017-02-23 20:41:17 -060056 done
57fi
58
59if test -z "$XDG_RUNTIME_DIR"; then
Brad Bishopc342db32019-05-15 21:57:59 -040060 export XDG_RUNTIME_DIR=/run/user/`id -u ${WESTON_USER}`
61 if ! test -d "$XDG_RUNTIME_DIR"; then
62 mkdir --parents $XDG_RUNTIME_DIR
63 chmod 0700 $XDG_RUNTIME_DIR
64 fi
65 if [ -n "$WESTON_USER" ]
66 then
Andrew Geissler6ce62a22020-11-30 19:58:47 -060067 chown $WESTON_USER:$WESTON_GROUP $XDG_RUNTIME_DIR
Brad Bishopc342db32019-05-15 21:57:59 -040068 fi
Patrick Williamsc0f7c042017-02-23 20:41:17 -060069fi
70
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000071su -c "XDG_RUNTIME_DIR=/run/user/`id -u ${WESTON_USER}` weston $weston_args --log=/tmp/weston.log" $WESTON_USER