blob: 6c548551b870465f3eefe97725e2a8fb3f076964 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001#!/bin/sh
2#
3### BEGIN INIT INFO
4# Provides: xserver
5# Required-Start: $local_fs $remote_fs dbus
6# Required-Stop: $local_fs $remote_fs
7# Default-Start: 5
8# Default-Stop: 0 1 2 3 6
9### END INIT INFO
10
11killproc() { # kill the named process(es)
12 pid=`/bin/pidof $1`
13 [ "$pid" != "" ] && kill $pid
14}
15
16read CMDLINE < /proc/cmdline
17for x in $CMDLINE; do
18 case $x in
19 x11=false)
20 echo "X Server disabled"
21 exit 0;
22 ;;
23 esac
24done
25
26case "$1" in
27 start)
28 . /etc/profile
Patrick Williamsc0f7c042017-02-23 20:41:17 -060029
30 #default for USER
31 . /etc/default/xserver-nodm
Patrick Williamsc124f4f2015-09-15 14:41:29 -050032 echo "Starting Xserver"
Patrick Williamsc0f7c042017-02-23 20:41:17 -060033 if [ "$USER" != "root" ]; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -050034 # setting for rootless X
35 chmod o+w /var/log
36 chmod g+r /dev/tty[0-3]
37 # hidraw device is probably needed
38 if [ -e /dev/hidraw0 ]; then
39 chmod o+rw /dev/hidraw*
40 fi
41 fi
Patrick Williamsc0f7c042017-02-23 20:41:17 -060042
Patrick Williamsc124f4f2015-09-15 14:41:29 -050043 # Using su rather than sudo as latest 1.8.1 cause failure [YOCTO #1211]
Patrick Williamsc0f7c042017-02-23 20:41:17 -060044 su -l -c '/etc/xserver-nodm/Xserver &' $USER
Patrick Williamsc124f4f2015-09-15 14:41:29 -050045 # Wait for the desktop to say its finished loading
46 # before loading the rest of the system
47 # dbus-wait org.matchbox_project.desktop Loaded
48 ;;
49
50 stop)
51 echo "Stopping XServer"
52 killproc xinit
53 sleep 1
54 chvt 1 &
55 ;;
56
57 restart)
58 $0 stop
59 $0 start
60 ;;
61
62 *)
63 echo "usage: $0 { start | stop | restart }"
64 ;;
65esac
66
67exit 0