xdm.initd 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. #!/usr/bin/openrc-run
  2. # Copyright 1999-2014 Gentoo Foundation
  3. # Distributed under the terms of the GNU General Public License, v2
  4. depend() {
  5. need localmount xdm-setup
  6. # this should start as early as possible
  7. after bootmisc consolefont modules netmount
  8. after readahead-list ypbind autofs openvpn gpm lircmd
  9. after quota keymaps
  10. before alsasound
  11. # Start before X
  12. use elogind dbus xfs
  13. }
  14. setup_dm() {
  15. local MY_XDM
  16. MY_XDM=$(echo "${DISPLAYMANAGER}" | tr '[:upper:]' '[:lower:]')
  17. NAME=
  18. case "${MY_XDM}" in
  19. entrance*)
  20. EXE=/usr/bin/entrance
  21. PIDFILE=/run/entrance.pid
  22. ;;
  23. gdm|gnome)
  24. EXE=/usr/bin/gdm
  25. PIDFILE=/run/gdm/gdm.pid
  26. START_STOP_ARGS="--background"
  27. AUTOCLEAN_CGROUP="yes"
  28. ;;
  29. wdm)
  30. EXE=/usr/bin/wdm
  31. PIDFILE=
  32. ;;
  33. gpe)
  34. EXE=/usr/bin/gpe-dm
  35. PIDFILE=/run/gpe-dm.pid
  36. ;;
  37. lxdm)
  38. EXE=/usr/bin/lxdm-binary
  39. PIDFILE=/run/lxdm.pid
  40. START_STOP_ARGS="--background"
  41. ;;
  42. lightdm)
  43. EXE=/usr/bin/lightdm
  44. PIDFILE=/run/lightdm.pid
  45. START_STOP_ARGS="--background"
  46. ;;
  47. sddm)
  48. EXE="/usr/bin/sddm"
  49. START_STOP_ARGS="-m --background"
  50. PIDFILE=/run/sddm.pid
  51. ;;
  52. *)
  53. # first find out if there is such executable
  54. EXE="$(command -v ${MY_XDM} 2>/dev/null)"
  55. PIDFILE="/run/${MY_XDM}.pid"
  56. # warn user that he is doing sick things if the exe was not found
  57. if [ -z "${EXE}" ]; then
  58. echo "ERROR: Your XDM value is invalid."
  59. echo " No ${MY_XDM} executable could be found on your system."
  60. fi
  61. ;;
  62. esac
  63. if ! [ -x "${EXE}" ]; then
  64. EXE=/usr/bin/xdm
  65. PIDFILE=/run/xdm.pid
  66. if ! [ -x "/usr/bin/xdm" ]; then
  67. echo "ERROR: Please set your DISPLAYMANAGER variable in /etc/conf.d/xdm,"
  68. echo " or install x11-apps/xdm package"
  69. eend 255
  70. fi
  71. fi
  72. }
  73. start() {
  74. local EXE NAME PIDFILE AUTOCLEAN_CGROUP
  75. setup_dm
  76. if [ -f /etc/.noxdm ]; then
  77. einfo "Skipping ${EXE##*/}, /etc/.noxdm found or \"nox\" bootparam passed."
  78. rm /etc/.noxdm
  79. return 0
  80. fi
  81. ebegin "Setting up ${EXE##*/}"
  82. # save the prefered DM
  83. save_options "service" "${EXE}"
  84. save_options "name" "${NAME}"
  85. save_options "pidfile" "${PIDFILE}"
  86. save_options "start_stop_args" "${START_STOP_ARGS}"
  87. save_options "autoclean_cgroup" "${AUTOCLEAN_CGROUP:-no}"
  88. /etc/X11/startDM.sh
  89. eend 0
  90. }
  91. stop() {
  92. local retval
  93. retval=0
  94. local myexe myname mypidfile myservice
  95. myexe=$(get_options "service")
  96. myname=$(get_options "name")
  97. mypidfile=$(get_options "pidfile")
  98. myservice=${myexe##*/}
  99. yesno "${rc_cgroup_cleanup:-no}" || rc_cgroup_cleanup=$(get_options "autoclean_cgroup")
  100. [ -z "${myexe}" ] && return 0
  101. ebegin "Stopping ${myservice}"
  102. if start-stop-daemon --quiet --test --stop --exec "${myexe}"; then
  103. start-stop-daemon --stop --exec "${myexe}" --retry TERM/5/TERM/5 \
  104. ${mypidfile:+--pidfile} ${mypidfile} \
  105. ${myname:+--name} ${myname}
  106. retval=${?}
  107. fi
  108. eend ${retval} "Error stopping ${myservice}"
  109. return ${retval}
  110. }
  111. # vim: set ts=4 :