]> git.pld-linux.org Git - packages/csync2.git/blob - csync2.init
- fix building with librsync 1.0+
[packages/csync2.git] / csync2.init
1 #!/bin/sh
2 #
3 # csync2        This shell script takes care of starting and stopping csync2
4 #
5 # chkconfig:    345 90 25
6 # description:  csync2 daemon
7 # processname:  csync2
8 #
9 # pidfile:      /var/run/csync2.pid
10
11 # Source function library.
12 . /etc/rc.d/init.d/functions
13
14 # Source networking configuration.
15 . /etc/sysconfig/network
16
17 # Check that networking is up.
18 if is_yes "${NETWORKING}"; then
19         if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
20                 msg_network_down csync2
21                 exit 1
22         fi
23 else
24         exit 0
25 fi
26
27 # Get service configuration
28 [ -f /etc/sysconfig/csync2 ] && . /etc/sysconfig/csync2
29
30 start() {
31         if [ ! -f /var/lock/subsys/csync2 ]; then
32                 msg_starting csync2
33                 daemon --fork csync2 -ii ${CSYNC2_OPTIONS}
34                 RETVAL=$?
35                 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/csync2
36         else
37                 msg_already_running csync2
38         fi
39 }
40
41 stop() {
42         # Stop daemons.
43         if [ -f /var/lock/subsys/csync2 ]; then
44                 msg_stopping csync2
45                 killproc csync2
46                 rm -f /var/lock/subsys/csync2 >/dev/null 2>&1
47         else
48                 msg_not_running csync2
49         fi
50 }
51
52 RETVAL=0
53 # See how we were called.
54 case "$1" in
55   start)
56         start
57         ;;
58   stop)
59         stop
60         ;;
61   restart|reload|force-restart|force-reload)
62         stop
63         start
64         ;;
65   init)
66         nls "Now the csync2 host key will be generated."
67         /usr/bin/openssl genrsa \
68                 -out /etc/csync2/csync2_ssl_key.pem 1024
69         chmod 600 /etc/csync2/csync2_ssl_key.pem
70         /usr/bin/openssl req -new \
71                 -key /etc/csync2/csync2_ssl_key.pem \
72                 -out /etc/csync2/csync2_ssl_cert.csr
73         chmod 600 /etc/csync2/csync2_ssl_cert.csr
74         /usr/bin/openssl x509 -req -days 600 \
75                 -in /etc/csync2/csync2_ssl_cert.csr \
76                 -signkey /etc/csync2/csync2_ssl_key.pem \
77                 -out /etc/csync2/csync2_ssl_cert.pem
78         chmod 600 /etc/csync2/csync2_ssl_cert.pem
79         exit $?
80         ;;
81   status)
82         status csync2
83         exit $?
84         ;;
85   *)
86         msg_usage "$0 {start|stop|restart|reload|force-restart|force-reload|init|status}"
87         exit 3
88 esac
89
90 exit $RETVAL
This page took 0.064495 seconds and 3 git commands to generate.