blob: ccc70934259c1c6a83805f4fd2ce165c50e326c9 [file] [log] [blame]
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001#!/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() {
Brad Bishopc342db32019-05-15 21:57:59 -04008 cat <<EOF
9 $0 [<openvt arguments>] [-- <weston options>]
Patrick Williamsc0f7c042017-02-23 20:41:17 -060010EOF
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
Brad Bishopc342db32019-05-15 21:57:59 -040030
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
Patrick Williamsc0f7c042017-02-23 20:41:17 -060039if [ -n "$DISPLAY" ]; then
40 launcher="weston"
41else
Brad Bishopc342db32019-05-15 21:57:59 -040042 launcher="weston-launch $weston_args_user --"
Patrick Williamsc0f7c042017-02-23 20:41:17 -060043fi
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
Brad Bishopc342db32019-05-15 21:57:59 -040071 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 Williamsc0f7c042017-02-23 20:41:17 -060080fi
81
82exec openvt $openvt_args -- $launcher $weston_args --log=@LOCALSTATEDIR@/log/weston.log