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 BROKEN INFINITE LOOPS IN BOOT ANIMATION
89 # VIRTUAL KEYBOARD BOOT SCRIPTS.
90 # ***********************************************************
93 # ***********************************************************
97 # Function that stops the daemon/service
102 # 0 if daemon has been stopped
103 # 1 if daemon was already stopped
104 # 2 if daemon could not be stopped
105 # other if a failure occurred
106 #start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
107 start-stop-daemon --stop --quiet --pidfile $PIDFILE --name $NAME
109 [ "$RETVAL" = 2 ] && return 2
110 # Wait for children to finish too if this is a daemon that forks
111 # and if the daemon is only ever run from this initscript.
112 # If the above conditions are not satisfied then add some other code
113 # that waits for the process to drop all resources that could be
114 # needed by services started subsequently. A last resort is to
115 # sleep for some time.
116 #start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
117 start-stop-daemon --stop --quiet --oknodo --exec $DAEMON
118 [ "$?" = 2 ] && return 2
119 # Many daemons don't delete their pidfiles when they exit.
125 # Function that sends a SIGHUP to the daemon/service
129 # If the daemon can reload its configuration without
130 # restarting (for example, when it is sent a SIGHUP),
131 # then implement that here.
133 start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
139 [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
142 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
143 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
147 [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
150 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
151 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
155 status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
157 #reload|force-reload)
159 # If do_reload() is not implemented then leave this commented out
160 # and leave 'force-reload' as an alias for 'restart'.
162 #log_daemon_msg "Reloading $DESC" "$NAME"
166 restart|force-reload)
168 # If the "reload" option is implemented then remove the
169 # 'force-reload' alias
171 log_daemon_msg "Restarting $DESC" "$NAME"
178 1) log_end_msg 1 ;; # Old process is still running
179 *) log_end_msg 1 ;; # Failed to start
189 #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
190 echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2