xsd.sysvrc 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. #! /bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides: xsd
  4. # Required-Start: $remote_fs $syslog
  5. # Required-Stop: $remote_fs $syslog
  6. # Default-Start: 2 3 4 5
  7. # Default-Stop:
  8. # Short-Description: eXperimental Shell Daemon
  9. ### END INIT INFO
  10. set -e
  11. # /etc/init.d/xsd: start and stop the eXperimental "secure" Shell Daemon
  12. test -x /usr/local/sbin/xsd || exit 0
  13. ( /usr/local/sbin/xsd -h 2>&1 | grep -q chaff ) 2>/dev/null || exit 0
  14. umask 022
  15. #if test -f /etc/default/ssh; then
  16. # . /etc/default/ssh
  17. #fi
  18. . /lib/lsb/init-functions
  19. if [ -n "$2" ]; then
  20. XSD_OPTS="$XSD_OPTS $2"
  21. fi
  22. # Are we running from init?
  23. run_by_init() {
  24. ([ "$previous" ] && [ "$runlevel" ]) || [ "$runlevel" = S ]
  25. }
  26. check_for_no_start() {
  27. # forget it if we're trying to start, and /etc/xsd_not_to_be_run exists
  28. if [ -e /etc/xsd_not_to_be_run ]; then
  29. if [ "$1" = log_end_msg ]; then
  30. log_end_msg 0 || true
  31. fi
  32. if ! run_by_init; then
  33. log_action_msg "eXperimental Shell Daemon not in use (/etc/xsd_not_to_be_run)" || true
  34. fi
  35. exit 0
  36. fi
  37. }
  38. check_dev_null() {
  39. if [ ! -c /dev/null ]; then
  40. if [ "$1" = log_end_msg ]; then
  41. log_end_msg 1 || true
  42. fi
  43. if ! run_by_init; then
  44. log_action_msg "/dev/null is not a character device!" || true
  45. fi
  46. exit 1
  47. fi
  48. }
  49. #check_privsep_dir() {
  50. # # Create the PrivSep empty dir if necessary
  51. # if [ ! -d /run/sshd ]; then
  52. # mkdir /run/sshd
  53. # chmod 0755 /run/sshd
  54. # fi
  55. #}
  56. #check_config() {
  57. # if [ ! -e /etc/xsd_not_to_be_run ]; then
  58. # /usr/local/sbin/xsd $XSD_OPTS -t || exit 1
  59. # fi
  60. #}
  61. export PATH="${PATH:+$PATH:}/usr/local/sbin:/usr/sbin:/sbin"
  62. case "$1" in
  63. start)
  64. #check_privsep_dir
  65. check_for_no_start
  66. check_dev_null
  67. log_daemon_msg "Starting eXperimental Shell Daemon" "xsd" || true
  68. if start-stop-daemon --start -b --quiet --oknodo --chuid 0:0 --exec /usr/local/sbin/xsd -- $XSD_OPTS; then
  69. log_end_msg 0 || true
  70. else
  71. log_end_msg 1 || true
  72. fi
  73. ;;
  74. stop)
  75. log_daemon_msg "Stopping eXperimental Shell Daemon" "xsd" || true
  76. if start-stop-daemon --stop --quiet --oknodo --exec /usr/local/sbin/xsd; then
  77. log_end_msg 0 || true
  78. else
  79. log_end_msg 1 || true
  80. fi
  81. ;;
  82. reload|force-reload)
  83. check_for_no_start
  84. #check_config
  85. log_daemon_msg "Reloading eXperimental Shell Daemon's configuration" "xsd" || true
  86. if start-stop-daemon --stop --signal 1 --quiet --oknodo --exec /usr/local/sbin/xsd; then
  87. log_end_msg 0 || true
  88. else
  89. log_end_msg 1 || true
  90. fi
  91. ;;
  92. restart)
  93. #check_privsep_dir
  94. #check_config
  95. log_daemon_msg "Restarting eXperimental Shell Daemon" "xsd" || true
  96. start-stop-daemon --stop --quiet --oknodo --retry 30 --exec /usr/local/sbin/xsd
  97. check_for_no_start log_end_msg
  98. check_dev_null log_end_msg
  99. if start-stop-daemon --start -b --quiet --oknodo --chuid 0:0 --exec /usr/local/sbin/xsd -- $XSD_OPTS; then
  100. log_end_msg 0 || true
  101. else
  102. log_end_msg 1 || true
  103. fi
  104. ;;
  105. try-restart)
  106. #check_privsep_dir
  107. #check_config
  108. log_daemon_msg "Restarting eXperimental Shell Daemon" "xsd" || true
  109. RET=0
  110. start-stop-daemon --stop --quiet --retry 30 --exec /usr/local/sbin/xsd || RET="$?"
  111. case $RET in
  112. 0)
  113. # old daemon stopped
  114. check_for_no_start log_end_msg
  115. check_dev_null log_end_msg
  116. if start-stop-daemon --start -b --quiet --oknodo --chuid 0:0 --exec /usr/local/sbin/xsd -- $XSD_OPTS; then
  117. log_end_msg 0 || true
  118. else
  119. log_end_msg 1 || true
  120. fi
  121. ;;
  122. 1)
  123. # daemon not running
  124. log_progress_msg "(not running)" || true
  125. log_end_msg 0 || true
  126. ;;
  127. *)
  128. # failed to stop
  129. log_progress_msg "(failed to stop)" || true
  130. log_end_msg 1 || true
  131. ;;
  132. esac
  133. ;;
  134. status)
  135. status_of_proc -p /run/xsd.pid /usr/local/sbin/xsd xsd && exit 0 || exit $?
  136. ;;
  137. *)
  138. log_action_msg "Usage: /etc/init.d/xsd {start|stop|reload|force-reload|restart|try-restart|status}" || true
  139. exit 1
  140. esac
  141. exit 0