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" |
| 24 | } |
| 25 | |
| 26 | if [ -n "$WAYLAND_DISPLAY" ]; then |
| 27 | echo "ERROR: A Wayland compositor is already running, nested Weston instance is not supported yet." |
| 28 | exit 1 |
| 29 | fi |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 30 | |
| 31 | if [ -n "$WESTON_USER" ]; then |
| 32 | if [ -z "$WESTON_TTY" ]; then |
| 33 | echo "ERROR: If you have WESTON_USER variable set, you also need WESTON_TTY." |
| 34 | exit 1 |
| 35 | fi |
| 36 | weston_args_user="-u $WESTON_USER -t $WESTON_TTY" |
| 37 | fi |
| 38 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 39 | if [ -n "$DISPLAY" ]; then |
| 40 | launcher="weston" |
| 41 | else |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 42 | launcher="weston-launch $weston_args_user --" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 43 | fi |
| 44 | |
| 45 | openvt_args="-s" |
| 46 | while [ -n "$1" ]; do |
| 47 | if [ "$1" = "--" ]; then |
| 48 | shift |
| 49 | break |
| 50 | fi |
| 51 | openvt_args="$openvt_args $1" |
| 52 | shift |
| 53 | done |
| 54 | |
| 55 | weston_args=$* |
| 56 | |
| 57 | # Load and run modules |
| 58 | if [ -d "$modules_dir" ]; then |
| 59 | for m in "$modules_dir"/*; do |
| 60 | # Skip backup files |
| 61 | if [ "`echo $m | sed -e 's/\~$//'`" != "$m" ]; then |
| 62 | continue |
| 63 | fi |
| 64 | |
| 65 | # process module |
| 66 | . $m |
| 67 | done |
| 68 | fi |
| 69 | |
| 70 | if test -z "$XDG_RUNTIME_DIR"; then |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 71 | export XDG_RUNTIME_DIR=/run/user/`id -u ${WESTON_USER}` |
| 72 | if ! test -d "$XDG_RUNTIME_DIR"; then |
| 73 | mkdir --parents $XDG_RUNTIME_DIR |
| 74 | chmod 0700 $XDG_RUNTIME_DIR |
| 75 | fi |
| 76 | if [ -n "$WESTON_USER" ] |
| 77 | then |
| 78 | chown $WESTON_USER:$WESTON_USER $XDG_RUNTIME_DIR |
| 79 | fi |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 80 | fi |
| 81 | |
| 82 | exec openvt $openvt_args -- $launcher $weston_args --log=@LOCALSTATEDIR@/log/weston.log |