vlmcsd-rhel 1.4 KB

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