blob: 0b93dc964a1d9e5348cd3555ddd1a7edb1c0b178 [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
Andrew Geissler6ce62a22020-11-30 19:58:47 -060036 if [ -z "$WESTON_GROUP" ]; then
37 # no explicit WESTON_GROUP given, therefore use WESTON_USER
38 export WESTON_GROUP="${WESTON_USER}"
39 fi
Brad Bishopc342db32019-05-15 21:57:59 -040040 weston_args_user="-u $WESTON_USER -t $WESTON_TTY"
41fi
42
Patrick Williamsc0f7c042017-02-23 20:41:17 -060043if [ -n "$DISPLAY" ]; then
44 launcher="weston"
45else
Brad Bishopc342db32019-05-15 21:57:59 -040046 launcher="weston-launch $weston_args_user --"
Patrick Williamsc0f7c042017-02-23 20:41:17 -060047fi
48
49openvt_args="-s"
50while [ -n "$1" ]; do
51 if [ "$1" = "--" ]; then
52 shift
53 break
54 fi
55 openvt_args="$openvt_args $1"
56 shift
57done
58
59weston_args=$*
60
61# Load and run modules
62if [ -d "$modules_dir" ]; then
63 for m in "$modules_dir"/*; do
64 # Skip backup files
65 if [ "`echo $m | sed -e 's/\~$//'`" != "$m" ]; then
66 continue
67 fi
68
69 # process module
70 . $m
71 done
72fi
73
74if test -z "$XDG_RUNTIME_DIR"; then
Brad Bishopc342db32019-05-15 21:57:59 -040075 export XDG_RUNTIME_DIR=/run/user/`id -u ${WESTON_USER}`
76 if ! test -d "$XDG_RUNTIME_DIR"; then
77 mkdir --parents $XDG_RUNTIME_DIR
78 chmod 0700 $XDG_RUNTIME_DIR
79 fi
80 if [ -n "$WESTON_USER" ]
81 then
Andrew Geissler6ce62a22020-11-30 19:58:47 -060082 chown $WESTON_USER:$WESTON_GROUP $XDG_RUNTIME_DIR
Brad Bishopc342db32019-05-15 21:57:59 -040083 fi
Patrick Williamsc0f7c042017-02-23 20:41:17 -060084fi
85
86exec openvt $openvt_args -- $launcher $weston_args --log=@LOCALSTATEDIR@/log/weston.log