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 --idle-time=0"
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 wayland_socket="$XDG_RUNTIME_DIR/wayland-0"
98 while [ ! -f $wayland_socket ] && [ $attempt -lt $MAX_ATTEMPTS ]
101 attempt=$[$attempt + 1]
103 chmod 777 $wayland_socket
105 # ***********************************************************
106 # HACK TO WORK AROUND BROKEN INFINITE LOOPS IN BOOT ANIMATION
107 # VIRTUAL KEYBOARD BOOT SCRIPTS.
108 # ***********************************************************
111 # ***********************************************************
115 # Function that stops the daemon/service
120 # 0 if daemon has been stopped
121 # 1 if daemon was already stopped
122 # 2 if daemon could not be stopped
123 # other if a failure occurred
124 #start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
125 start-stop-daemon --stop --quiet --pidfile $PIDFILE --name $NAME
127 [ "$RETVAL" = 2 ] && return 2
128 # Wait for children to finish too if this is a daemon that forks
129 # and if the daemon is only ever run from this initscript.
130 # If the above conditions are not satisfied then add some other code
131 # that waits for the process to drop all resources that could be
132 # needed by services started subsequently. A last resort is to
133 # sleep for some time.
134 #start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
135 start-stop-daemon --stop --quiet --oknodo --exec $DAEMON
136 [ "$?" = 2 ] && return 2
137 # Many daemons don't delete their pidfiles when they exit.
143 # Function that sends a SIGHUP to the daemon/service
147 # If the daemon can reload its configuration without
148 # restarting (for example, when it is sent a SIGHUP),
149 # then implement that here.
151 start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
157 [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
160 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
161 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
165 [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
168 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
169 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
173 status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
175 #reload|force-reload)
177 # If do_reload() is not implemented then leave this commented out
178 # and leave 'force-reload' as an alias for 'restart'.
180 #log_daemon_msg "Reloading $DESC" "$NAME"
184 restart|force-reload)
186 # If the "reload" option is implemented then remove the
187 # 'force-reload' alias
189 log_daemon_msg "Restarting $DESC" "$NAME"
196 1) log_end_msg 1 ;; # Old process is still running
197 *) log_end_msg 1 ;; # Failed to start
207 #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
208 echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2