4 # Required-Start: $remote_fs $syslog
5 # Required-Stop: $remote_fs $syslog
6 # Default-Start: 2 3 4 5
8 # Short-Description: Weston compositor boot script
9 # Description: This script starts the Weston compositor at boot.
12 # Author: Ossama Othman
14 # Please remove the "Author" lines above and replace them
15 # with your own name if you copy and modify this script.
22 # Use the Weston DRM backend if $DISPLAY is set and X isn't running
23 #since Weston won't be able use the X11 backend.
25 # This allows this script to start Weston with either the X11 or DRM
27 if [ -z `pidof Xorg` ] && [ -n "$DISPLAY" ]; then
28 backend="--backend=drm-backend.so"
31 # PATH should only include /usr/* if it runs after the mountnfs.sh script
32 PATH=/sbin:/usr/sbin:/bin:/usr/bin
33 DESC="Weston compositor"
35 DAEMON=/usr/bin/weston
36 DAEMON_ARGS="$backend --log=/var/log/weston.log"
37 PIDFILE=/var/run/$NAME.pid
38 SCRIPTNAME=/etc/init.d/$NAME
40 # Exit if the package is not installed
41 [ -x "$DAEMON" ] || exit 0
43 # Read configuration variable file if it is present
44 [ -r /etc/default/$NAME ] && . /etc/default/$NAME
46 # Load the VERBOSE setting and other rcS variables
49 # Define LSB log_* functions.
50 # Depend on lsb-base (>= 3.2-14) to ensure that this file is present
51 # and status_of_proc is working.
52 . /lib/lsb/init-functions
55 # Function that starts the daemon/service
59 # Make sure we have a sane XDG_RUNTIME_DIR environment
61 if [ -z "${XDG_RUNTIME_DIR}" ]; then
62 . /etc/profile.d/weston.sh
66 # 0 if daemon has been started
67 # 1 if daemon was already running
68 # 2 if daemon could not be started
69 start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
71 # start-stop-daemon --start --background --quiet --pidfile $PIDFILE --exec $DAEMON -- \
74 $DAEMON $DAEMON_ARGS &
77 if [ $weston_pid = 0 ]; then
80 echo $weston_pid > $PIDFILE
83 # Add code here, if necessary, that waits for the process to be ready
84 # to handle requests from services started subsequently which depend
85 # on this one. As a last resort, sleep for some time.
87 # ************************************************************
88 # HACK TO WORK AROUND INSUFFICIENT ACCESS PERMISSIONS FOR
91 # Ideally we should launch weston with weston-launch with the
92 # appropriate --user flag. Unfortunately, weston-launch isn't
93 # available due to missing package dependencies.
94 # ************************************************************
95 chmod 777 $XDG_RUNTIME_DIR/wayland-0
97 # ***********************************************************
98 # HACK TO WORK AROUND BROKEN INFINITE LOOPS IN BOOT ANIMATION
99 # VIRTUAL KEYBOARD BOOT SCRIPTS.
100 # ***********************************************************
103 # ***********************************************************
107 # Function that stops the daemon/service
112 # 0 if daemon has been stopped
113 # 1 if daemon was already stopped
114 # 2 if daemon could not be stopped
115 # other if a failure occurred
116 #start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
117 start-stop-daemon --stop --quiet --pidfile $PIDFILE --name $NAME
119 [ "$RETVAL" = 2 ] && return 2
120 # Wait for children to finish too if this is a daemon that forks
121 # and if the daemon is only ever run from this initscript.
122 # If the above conditions are not satisfied then add some other code
123 # that waits for the process to drop all resources that could be
124 # needed by services started subsequently. A last resort is to
125 # sleep for some time.
126 #start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
127 start-stop-daemon --stop --quiet --oknodo --exec $DAEMON
128 [ "$?" = 2 ] && return 2
129 # Many daemons don't delete their pidfiles when they exit.
135 # Function that sends a SIGHUP to the daemon/service
139 # If the daemon can reload its configuration without
140 # restarting (for example, when it is sent a SIGHUP),
141 # then implement that here.
143 start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
149 [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
152 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
153 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
157 [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
160 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
161 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
165 status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
167 #reload|force-reload)
169 # If do_reload() is not implemented then leave this commented out
170 # and leave 'force-reload' as an alias for 'restart'.
172 #log_daemon_msg "Reloading $DESC" "$NAME"
176 restart|force-reload)
178 # If the "reload" option is implemented then remove the
179 # 'force-reload' alias
181 log_daemon_msg "Restarting $DESC" "$NAME"
188 1) log_end_msg 1 ;; # Old process is still running
189 *) log_end_msg 1 ;; # Failed to start
199 #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
200 echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2