lsyncd.init 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #!/bin/bash
  2. #
  3. # lsyncd
  4. #
  5. # chkconfig: - 99 20
  6. # processname: /usr/bin/lsyncd
  7. # description: Live syncing daemon
  8. ### BEGIN INIT INFO
  9. # Provides: lsyncd
  10. # Required-Start: $syslog $local_fs
  11. # Required-Stop: $syslog $local_fs
  12. # Default-Start: 2 3 4 5
  13. # Default-Stop: 0 1 6
  14. # Short-Description: start and stop lsyncd
  15. # Description: Live syncing daemon
  16. ### END INIT INFO
  17. #
  18. DAEMON=/usr/bin/lsyncd
  19. prog=`basename $DAEMON`
  20. CONFIG=/etc/lsyncd/lsyncd.conf.lua
  21. LSYNCD_ARGS=""
  22. PIDFILE=/var/run/${prog}.pid
  23. LOCKFILE=/var/lock/subsys/${prog}
  24. [ -x "$DAEMON" ] || exit 0
  25. [ -r "$CONFIG" ] || exit 0
  26. if [ -r /etc/init.d/functions ]; then
  27. . /etc/init.d/functions
  28. fi
  29. if [ -r /etc/sysconfig/${prog} ]; then
  30. . /etc/sysconfig/${prog}
  31. fi
  32. PATH=/sbin:/usr/sbin:/bin:/usr/bin
  33. export PATH
  34. RETVAL=0
  35. start() {
  36. # Check if it is already running
  37. if [ ! -f $PIDFILE ]; then
  38. echo -n $"Starting $prog: "
  39. daemon $DAEMON -pidfile $PIDFILE $DAEMON_ARGS $CONFIG
  40. RETVAL=$?
  41. [ $RETVAL -eq 0 ] && touch $LOCKFILE
  42. echo
  43. fi
  44. return $RETVAL
  45. }
  46. stop() {
  47. echo -n $"Stopping $prog: "
  48. killproc -p "${PIDFILE}" $DAEMON
  49. RETVAL=$?
  50. [ $RETVAL -eq 0 ] && rm -f $LOCKFILE
  51. echo
  52. return $RETVAL
  53. }
  54. restart() {
  55. stop
  56. start
  57. }
  58. case "$1" in
  59. start)
  60. start
  61. ;;
  62. stop)
  63. stop
  64. ;;
  65. restart)
  66. restart
  67. ;;
  68. condrestart)
  69. if [ -f $PIDFILE ]; then
  70. restart
  71. fi
  72. ;;
  73. status)
  74. status lsyncd
  75. RETVAL=$?
  76. ;;
  77. *)
  78. echo $"Usage: $0 {start|stop|status|restart|condrestart}"
  79. RETVAL=2
  80. esac
  81. exit $RETVAL