1#!/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() { 8 cat <<EOF 9 $0 [<openvt arguments>] [-- <weston options>] 10EOF 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 21# Add openvt extra argument 22add_openvt_argument() { 23 openvt_args="$openvt_args $1" 24} 25 26if [ -n "$WAYLAND_DISPLAY" ]; then 27 echo "ERROR: A Wayland compositor is already running, nested Weston instance is not supported yet." 28 exit 1 29fi 30 31if [ -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" 37fi 38 39if [ -n "$DISPLAY" ]; then 40 launcher="weston" 41else 42 launcher="weston-launch $weston_args_user --" 43fi 44 45openvt_args="-s" 46while [ -n "$1" ]; do 47 if [ "$1" = "--" ]; then 48 shift 49 break 50 fi 51 openvt_args="$openvt_args $1" 52 shift 53done 54 55weston_args=$* 56 57# Load and run modules 58if [ -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 68fi 69 70if test -z "$XDG_RUNTIME_DIR"; then 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 80fi 81 82exec openvt $openvt_args -- $launcher $weston_args --log=@LOCALSTATEDIR@/log/weston.log 83