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 |
| 9 | $0 [<openvt arguments>] [-- <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 | |
| 21 | # Add openvt extra argument |
| 22 | add_openvt_argument() { |
| 23 | openvt_args="$openvt_args $1" |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 24 | |
| 25 | } |
| 26 | ## Add module to --modules argument |
| 27 | add_weston_module() { |
| 28 | if [[ "x${weston_modules}" == "x" ]]; then |
| 29 | weston_modules="--modules " |
| 30 | fi; |
| 31 | weston_modules+="${1}," |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 32 | } |
| 33 | |
| 34 | if [ -n "$WAYLAND_DISPLAY" ]; then |
| 35 | echo "ERROR: A Wayland compositor is already running, nested Weston instance is not supported yet." |
| 36 | exit 1 |
| 37 | fi |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 38 | |
| 39 | if [ -n "$WESTON_USER" ]; then |
| 40 | if [ -z "$WESTON_TTY" ]; then |
| 41 | echo "ERROR: If you have WESTON_USER variable set, you also need WESTON_TTY." |
| 42 | exit 1 |
| 43 | fi |
Andrew Geissler | 6ce62a2 | 2020-11-30 19:58:47 -0600 | [diff] [blame] | 44 | if [ -z "$WESTON_GROUP" ]; then |
| 45 | # no explicit WESTON_GROUP given, therefore use WESTON_USER |
| 46 | export WESTON_GROUP="${WESTON_USER}" |
| 47 | fi |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 48 | weston_args_user="-u $WESTON_USER -t $WESTON_TTY" |
| 49 | fi |
| 50 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 51 | if [ -n "$DISPLAY" ]; then |
| 52 | launcher="weston" |
| 53 | else |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 54 | launcher="weston-launch $weston_args_user --" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 55 | fi |
| 56 | |
| 57 | openvt_args="-s" |
| 58 | while [ -n "$1" ]; do |
| 59 | if [ "$1" = "--" ]; then |
| 60 | shift |
| 61 | break |
| 62 | fi |
| 63 | openvt_args="$openvt_args $1" |
| 64 | shift |
| 65 | done |
| 66 | |
| 67 | weston_args=$* |
| 68 | |
| 69 | # Load and run modules |
| 70 | if [ -d "$modules_dir" ]; then |
| 71 | for m in "$modules_dir"/*; do |
| 72 | # Skip backup files |
| 73 | if [ "`echo $m | sed -e 's/\~$//'`" != "$m" ]; then |
| 74 | continue |
| 75 | fi |
| 76 | |
| 77 | # process module |
| 78 | . $m |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 79 | if [[ x"{$weston_modules}" != "x" ]]; then |
| 80 | add_weston_argument "${weston_modules}" |
| 81 | fi; |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 82 | done |
| 83 | fi |
| 84 | |
| 85 | if test -z "$XDG_RUNTIME_DIR"; then |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 86 | export XDG_RUNTIME_DIR=/run/user/`id -u ${WESTON_USER}` |
| 87 | if ! test -d "$XDG_RUNTIME_DIR"; then |
| 88 | mkdir --parents $XDG_RUNTIME_DIR |
| 89 | chmod 0700 $XDG_RUNTIME_DIR |
| 90 | fi |
| 91 | if [ -n "$WESTON_USER" ] |
| 92 | then |
Andrew Geissler | 6ce62a2 | 2020-11-30 19:58:47 -0600 | [diff] [blame] | 93 | chown $WESTON_USER:$WESTON_GROUP $XDG_RUNTIME_DIR |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 94 | fi |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 95 | fi |
| 96 | |
| 97 | exec openvt $openvt_args -- $launcher $weston_args --log=@LOCALSTATEDIR@/log/weston.log |