rc.ices-cc 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #!/bin/sh
  2. # Start/stop/restart ices-cc as a daemon
  3. # Copyright (c) 2011 Antonio Hernández Blas <hba.nihilismus@gmail.com>
  4. #
  5. # DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
  6. # Version 2, December 2004
  7. #
  8. # Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
  9. #
  10. # Everyone is permitted to copy and distribute verbatim or modified
  11. # copies of this license document, and changing it is allowed as long
  12. # as the name is changed.
  13. #
  14. # DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
  15. # TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
  16. #
  17. # 0. You just DO WHAT THE FUCK YOU WANT TO.
  18. #
  19. CONF='/etc/ices-cc.conf'
  20. BASEDIR='/var/log/ices-cc'
  21. CMMD="/usr/bin/ices-cc -B -c $CONF -D $BASEDIR"
  22. ices_start() {
  23. if [ -x /usr/bin/ices-cc ]; then
  24. if [ -f $CONF ]; then
  25. PIDOF=$(pgrep -f "$CMMD")
  26. if [ ! -z "$PIDOF" ]; then
  27. echo "Error, ices is already running as daemon."
  28. else
  29. echo "Starting ices as daemon: $CMMD"
  30. /bin/su - ices -c "$CMMD"
  31. fi
  32. else
  33. echo "Error, file $CONF does not exist."
  34. fi
  35. fi
  36. }
  37. ices_stop() {
  38. PIDOF=$(pgrep -f "$CMMD")
  39. if [ -z $PIDOF ]; then
  40. echo "Error, ices-cc is not running as daemon."
  41. else
  42. echo "Stoping ices-cc as daemon: kill -s SIGINT $PIDOF"
  43. /bin/kill -s SIGINT $PIDOF
  44. fi
  45. }
  46. ices_status() {
  47. PIDOF=$(pgrep -f "$CMMD")
  48. if [ ! -z "$PIDOF" ]; then
  49. echo "ices-cc is running as daemon."
  50. else
  51. echo "ices-cc is not running as daemon."
  52. fi
  53. }
  54. case $1 in
  55. start)
  56. ices_start
  57. ;;
  58. stop)
  59. ices_stop
  60. ;;
  61. restart)
  62. ices_stop
  63. sleep 3
  64. ices_start
  65. ;;
  66. status)
  67. ices_status
  68. ;;
  69. *)
  70. echo "Usage $0 {start|stop|restart|status}"
  71. exit 1
  72. ;;
  73. esac