Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | #!/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 | |
| 11 | killproc() { # kill the named process(es) |
| 12 | pid=`/bin/pidof $1` |
| 13 | [ "$pid" != "" ] && kill $pid |
| 14 | } |
| 15 | |
| 16 | read CMDLINE < /proc/cmdline |
| 17 | for x in $CMDLINE; do |
| 18 | case $x in |
| 19 | x11=false) |
| 20 | echo "X Server disabled" |
| 21 | exit 0; |
| 22 | ;; |
| 23 | esac |
| 24 | done |
| 25 | |
| 26 | case "$1" in |
| 27 | start) |
| 28 | . /etc/profile |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 29 | |
| 30 | #default for USER |
| 31 | . /etc/default/xserver-nodm |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 32 | echo "Starting Xserver" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 33 | if [ "$USER" != "root" ]; then |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 34 | # 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 |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 41 | # Make sure that the Xorg has the cap_sys_admin capability which is |
| 42 | # needed for setting the drm master |
| 43 | if ! grep -q "^auth.*pam_cap\.so" /etc/pam.d/su; then |
| 44 | echo "auth optional pam_cap.so" >>/etc/pam.d/su |
| 45 | fi |
| 46 | if ! /usr/sbin/getcap $XSERVER | grep -q cap_sys_admin; then |
| 47 | /usr/sbin/setcap cap_sys_admin+eip $XSERVER |
| 48 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 49 | fi |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 50 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 51 | # Using su rather than sudo as latest 1.8.1 cause failure [YOCTO #1211] |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 52 | su -l -c '/etc/xserver-nodm/Xserver &' $USER |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 53 | # Wait for the desktop to say its finished loading |
| 54 | # before loading the rest of the system |
| 55 | # dbus-wait org.matchbox_project.desktop Loaded |
| 56 | ;; |
| 57 | |
| 58 | stop) |
| 59 | echo "Stopping XServer" |
| 60 | killproc xinit |
| 61 | sleep 1 |
| 62 | chvt 1 & |
| 63 | ;; |
| 64 | |
| 65 | restart) |
| 66 | $0 stop |
| 67 | $0 start |
| 68 | ;; |
| 69 | |
| 70 | *) |
| 71 | echo "usage: $0 { start | stop | restart }" |
| 72 | ;; |
| 73 | esac |
| 74 | |
| 75 | exit 0 |