vlmcsd-debian 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #!/bin/sh
  2. #
  3. # VLMCSD - this script starts and stops the KMS Server daemon
  4. #
  5. ### BEGIN INIT INFO
  6. # Provides: vlmcsd
  7. # Required-Start: $local_fs $network $named $time $syslog
  8. # Required-Stop: $local_fs $network $named $time $syslog
  9. # Default-Start: 2 3 4 5
  10. # Default-Stop: 0 1 6
  11. # Description: KMS Emulator in C
  12. ### END INIT INFO
  13. NAME=vlmcsd
  14. SCRIPT=/usr/bin/vlmcsd
  15. RUNAS=
  16. PIDFILE=/var/run/$NAME.pid
  17. LOGFILE=/var/log/$NAME.log
  18. start() {
  19. if [ -f "$PIDFILE" ] && kill -0 $(cat "$PIDFILE"); then
  20. echo 'Service already running.'
  21. return 1
  22. fi
  23. echo 'Starting service...'
  24. local CMD="$SCRIPT -p $PIDFILE -l $LOGFILE"
  25. su -c "$CMD" $RUNAS
  26. echo 'Service started.'
  27. }
  28. stop() {
  29. if [ ! -f "$PIDFILE" ] || ! kill -0 $(cat "$PIDFILE"); then
  30. echo 'Service not running.'
  31. return 1
  32. fi
  33. echo 'Stopping service...'
  34. kill -15 $(cat "$PIDFILE") && rm -f "$PIDFILE"
  35. echo 'Service stopped.'
  36. }
  37. status() {
  38. echo "Checking $NAME service..."
  39. if [ -f "$PIDFILE" ]; then
  40. local PID=$(cat "$PIDFILE")
  41. kill -0 $PID
  42. if [ $? -eq 0 ]; then
  43. echo "Running, the PID is $PID."
  44. else
  45. echo 'The process appears to be dead but pidfile still exists.'
  46. fi
  47. else
  48. echo 'Service not running.'
  49. fi
  50. }
  51. case "$1" in
  52. start)
  53. start
  54. ;;
  55. stop)
  56. stop
  57. ;;
  58. status)
  59. status
  60. ;;
  61. restart)
  62. stop
  63. start
  64. ;;
  65. *)
  66. echo "Usage: $0 {start|stop|status|restart}"
  67. exit 1
  68. ;;
  69. esac
  70. exit 0