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() { |
| 8 | cat <<EOF |
| 9 | $0 [<openvt arguments>] [-- <weston options>] |
| 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 |
| 30 | if [ -n "$DISPLAY" ]; then |
| 31 | launcher="weston" |
| 32 | else |
| 33 | launcher="weston-launch --" |
| 34 | fi |
| 35 | |
| 36 | openvt_args="-s" |
| 37 | while [ -n "$1" ]; do |
| 38 | if [ "$1" = "--" ]; then |
| 39 | shift |
| 40 | break |
| 41 | fi |
| 42 | openvt_args="$openvt_args $1" |
| 43 | shift |
| 44 | done |
| 45 | |
| 46 | weston_args=$* |
| 47 | |
| 48 | # Load and run modules |
| 49 | if [ -d "$modules_dir" ]; then |
| 50 | for m in "$modules_dir"/*; do |
| 51 | # Skip backup files |
| 52 | if [ "`echo $m | sed -e 's/\~$//'`" != "$m" ]; then |
| 53 | continue |
| 54 | fi |
| 55 | |
| 56 | # process module |
| 57 | . $m |
| 58 | done |
| 59 | fi |
| 60 | |
| 61 | if test -z "$XDG_RUNTIME_DIR"; then |
| 62 | export XDG_RUNTIME_DIR=/run/user/`id -u` |
| 63 | if ! test -d "$XDG_RUNTIME_DIR"; then |
| 64 | mkdir --parents $XDG_RUNTIME_DIR |
| 65 | chmod 0700 $XDG_RUNTIME_DIR |
| 66 | fi |
| 67 | fi |
| 68 | |
| 69 | exec openvt $openvt_args -- $launcher $weston_args --log=@LOCALSTATEDIR@/log/weston.log |