source: projects/specs/trunk/l/lsyncd/lsyncd.init @ 1505

Revision 1505, 1.4 KB checked in by daisuke, 14 years ago (diff)

lsyncd: add initscript

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