xserver-nodm 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. killproc() { # kill the named process(es)
  11. pid=`/bin/pidof $1`
  12. [ "$pid" != "" ] && kill $pid
  13. }
  14. read CMDLINE < /proc/cmdline
  15. for x in $CMDLINE; do
  16. case $x in
  17. x11=false)
  18. echo "X Server disabled"
  19. exit 0;
  20. ;;
  21. esac
  22. done
  23. case "$1" in
  24. start)
  25. . /etc/profile
  26. #default for USER
  27. . /etc/default/xserver-nodm
  28. echo "Starting Xserver"
  29. if [ "$USER" != "root" ]; then
  30. # setting for rootless X
  31. chmod o+w /var/log
  32. chmod g+r /dev/tty[0-3]
  33. # hidraw device is probably needed
  34. if [ -e /dev/hidraw0 ]; then
  35. chmod o+rw /dev/hidraw*
  36. fi
  37. # Make sure that the Xorg has the cap_sys_admin capability which is
  38. # needed for setting the drm master
  39. if ! grep -q "^auth.*pam_cap\.so" /etc/pam.d/su; then
  40. echo "auth optional pam_cap.so" >>/etc/pam.d/su
  41. fi
  42. if ! /usr/sbin/getcap $XSERVER | grep -q cap_sys_admin; then
  43. /usr/sbin/setcap cap_sys_admin+eip $XSERVER
  44. fi
  45. fi
  46. # Using su rather than sudo as latest 1.8.1 cause failure [YOCTO #1211]
  47. su -l -c '/etc/xserver-nodm/Xserver &' $USER
  48. # Wait for the desktop to say its finished loading
  49. # before loading the rest of the system
  50. # dbus-wait org.matchbox_project.desktop Loaded
  51. ;;
  52. stop)
  53. echo "Stopping XServer"
  54. killproc xinit
  55. sleep 1
  56. chvt 1 &
  57. ;;
  58. restart)
  59. $0 stop
  60. $0 start
  61. ;;
  62. *)
  63. echo "usage: $0 { start | stop | restart }"
  64. ;;
  65. esac
  66. exit 0