Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # Copyright (C) 2016 O.S. Systems Software LTDA. |
| 3 | # Copyright (C) 2016 Freescale Semiconductor |
| 4 | |
| 5 | export PATH="/sbin:/usr/sbin:/bin:/usr/bin" |
| 6 | |
| 7 | usage() { |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 8 | cat <<EOF |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 9 | $0 [<weston options>] |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 10 | EOF |
| 11 | } |
| 12 | |
| 13 | ## Module support |
| 14 | modules_dir=@DATADIR@/weston-start |
| 15 | |
| 16 | # Add weston extra argument |
| 17 | add_weston_argument() { |
| 18 | weston_args="$weston_args $1" |
| 19 | } |
| 20 | |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 21 | ## Add module to --modules argument |
| 22 | add_weston_module() { |
| 23 | if [[ "x${weston_modules}" == "x" ]]; then |
| 24 | weston_modules="--modules " |
| 25 | fi; |
| 26 | weston_modules+="${1}," |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 27 | } |
| 28 | |
| 29 | if [ -n "$WAYLAND_DISPLAY" ]; then |
| 30 | echo "ERROR: A Wayland compositor is already running, nested Weston instance is not supported yet." |
| 31 | exit 1 |
| 32 | fi |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 33 | |
| 34 | if [ -n "$WESTON_USER" ]; then |
Andrew Geissler | 6ce62a2 | 2020-11-30 19:58:47 -0600 | [diff] [blame] | 35 | if [ -z "$WESTON_GROUP" ]; then |
| 36 | # no explicit WESTON_GROUP given, therefore use WESTON_USER |
| 37 | export WESTON_GROUP="${WESTON_USER}" |
| 38 | fi |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 39 | fi |
| 40 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 41 | weston_args=$* |
| 42 | |
| 43 | # Load and run modules |
| 44 | if [ -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 Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 53 | if [[ x"{$weston_modules}" != "x" ]]; then |
| 54 | add_weston_argument "${weston_modules}" |
| 55 | fi; |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 56 | done |
| 57 | fi |
| 58 | |
| 59 | if test -z "$XDG_RUNTIME_DIR"; then |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 60 | 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 Geissler | 6ce62a2 | 2020-11-30 19:58:47 -0600 | [diff] [blame] | 67 | chown $WESTON_USER:$WESTON_GROUP $XDG_RUNTIME_DIR |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 68 | fi |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 69 | fi |
| 70 | |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 71 | su -c "XDG_RUNTIME_DIR=/run/user/`id -u ${WESTON_USER}` weston $weston_args --log=/tmp/weston.log" $WESTON_USER |