Guest User

Untitled

a guest
Sep 22nd, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.36 KB | None | 0 0
  1. #! /bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides: mono-xsp2
  4. # Required-Start: $remote_fs
  5. # Required-Stop: $remote_fs
  6. # Should-Start:
  7. # Should-Stop:
  8. # Default-Start: 2 3 4 5
  9. # Default-Stop: 0 1 6
  10. # Short-Description: Mono XSP2
  11. # Description: Debian init script for Mono XSP2.
  12. ### END INIT INFO
  13. #
  14. # Written by Pablo Fischer <pablo@pablo.com.mx>
  15. # Dylan R. E. Moonfire <debian@mfgames.com>
  16. # Modified for Debian GNU/Linux
  17. #
  18. # Version: @(#)mono-xsp2 pablo@pablo.com.mx
  19. #
  20.  
  21. # Variables
  22. PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
  23. DAEMON=/usr/bin/xsp2
  24. NAME=mono-xsp2
  25. DESC="XSP 2.0 WebServer"
  26. DEFAULT=/etc/default/$NAME
  27. CFGDIR=/etc/xsp2
  28. VIRTUALFILE=$CFGDIR/debian.webapp
  29. MONO_SHARED_DIR=/var/run/$NAME
  30. start_boot=false
  31.  
  32. # Use LSB
  33. . /lib/lsb/init-functions
  34.  
  35. # If we don't have the basics, don't bother
  36. test -x $DAEMON || exit 0
  37. test -f $DEFAULT && . $DEFAULT
  38.  
  39. if [ "x$start_boot" != "xtrue" ] ; then
  40. exit 0
  41. fi
  42.  
  43. if [ ! -e $MONO_SHARED_DIR ]; then
  44. mkdir $MONO_SHARED_DIR
  45. chown $user:$group $MONO_SHARED_DIR
  46. fi
  47.  
  48. should_start() {
  49. if [ ! -e $VIRTUALFILE -o `cat $VIRTUALFILE | wc -l` = "2" ]; then
  50. log_action_msg "You have an incomplete $VIRTUALFILE"
  51. log_action_msg "To fix it, you need to install at least one package for xsp2 (like asp.net2-examples)"
  52. return 1
  53. fi
  54.  
  55. if [ -f /var/run/$NAME.pid ]; then
  56. # Are we really running xsp2?
  57. xsp2_pid=`cat /var/run/$NAME.pid`
  58. xsp2_ps=`ps -p $xsp2_pid | wc -l`
  59. if [ "$xsp2_ps" != "1" ]; then
  60. log_action_msg "Sorry, there is already a xsp2 running, stop it first"
  61. return 1
  62. fi
  63. fi
  64.  
  65. return 0
  66.  
  67. }
  68.  
  69. case "$1" in
  70. start)
  71. if should_start ; then
  72. log_daemon_msg "Starting $DESC" "$NAME"
  73. export MONO_SHARED_DIR
  74. start-stop-daemon --start --background --make-pidfile \
  75. --quiet --pidfile /var/run/$NAME.pid \
  76. --user $user --group $group --chuid $user \
  77. --exec $DAEMON -- \
  78. --port $port --address $address --appconfigdir \
  79. $CFGDIR --nonstop
  80. log_end_msg $?
  81. fi
  82. ;;
  83. stop)
  84. log_daemon_msg "Stopping $DESC" "$NAME"
  85. for i in $(ps aux | grep -v grep | grep 'xsp2.exe' | cut -c 10-15)
  86. do
  87. kill $i > /dev/null 2>&1
  88. done
  89. log_end_msg $?
  90. ;;
  91. restart|force-reload)
  92. $0 stop
  93. $0 start
  94. ;;
  95. *)
  96. N=/etc/init.d/$NAME
  97. echo "Usage: $N {start|stop|restart|force-reload}" >&2
  98. exit 1
  99. ;;
  100. esac
  101.  
  102. exit 0
Add Comment
Please, Sign In to add comment