xsd.sysvrc 3.9 KB

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