root/tags/omega-1.0.0-rc3/configs/init.d/ispcp_daemon

Revision 849, 3.3 KB (checked in by raphael, 15 months ago)

Generate database keys at setup time (fix for Debian packaging)
Added ispCP config (/etc/ispcp) and database backup system
LSB compatiblity for installing/removing init scripts
Added BACKUP_DOMAINS yes/no switch to enable/disable customer backups
Made ispcp_network and ispcp_daemon more or less LSB compatible
Fixed #688: updated ispcp_network in all distros (including fedora)
Fixed #645: improve welcome emails messages
Fixed #758: phpMyAdmin Security vulnerability
Added different message levels to be used with write_log to reduce verbosity of emails sent
Fixed some Makefiles which were replacing files in the local copy rather than in the installation

Line 
1#!/bin/sh
2
3# ispCP ω (OMEGA) a Virtual Hosting Control System
4# Copyright (c) 2007 by ispCP
5# http://www.isp-control.net
6#
7#
8# License:
9#    This program is free software; you can redistribute it and/or
10#    modify it under the terms of the MPL Mozilla Public License
11#    as published by the Free Software Foundation; either version 1.1
12#    of the License, or (at your option) any later version.
13#
14#    This program is distributed in the hope that it will be useful,
15#    but WITHOUT ANY WARRANTY; without even the implied warranty of
16#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17#    MPL Mozilla Public License for more details.
18#
19#    You may have received a copy of the MPL Mozilla Public License
20#    along with this program.
21#
22#    An on-line copy of the MPL Mozilla Public License can be found
23#    http://www.mozilla.org/MPL/MPL-1.1.html
24#
25#
26# The ispCP Home Page is at:
27#
28#    http://www.isp-control.net
29#
30### BEGIN INIT INFO
31# Provides:             ispcp_daemon
32# Required-Start:       $network $local_fs $remote_fs
33# Required-Stop:
34# Should-Stop:          $local_fs
35# Default-Start:        2 3 4 5
36# Default-Stop:         0 1 6
37# Short-Description:    ispCP GUI-Backend communication Daemon
38### END INIT INFO
39# Note: do not modify any of these vars here, use /etc/default/$NAME instead
40
41PATH=/sbin:/bin:/usr/sbin:/usr/bin
42NAME=ispcp_daemon
43DAEMON=/var/www/ispcp/daemon/$NAME
44PID=/var/run/$NAME.pid
45DESC="ispCP GUI-Backend communication Daemon"
46LOGDIR=/var/log/ispcp
47LOGFILE=${LOGDIR}/${NAME}.log
48DIETIME=3
49
50START=1
51
52# Debian LSB extensions (will be used if init-functions doesn't override them):
53log_daemon_msg() {
54        if [ ! -z "${2:-}" ]; then
55                log_success_msg "${1:-}: ${2:-}"
56        else
57                log_success_msg "${1:-}"
58        fi
59}
60log_end_msg() {
61        local status="$1"
62}
63
64# if not present (e.g. *BSD) make sure to provide compatible methods via /etc/default/$NAME
65if [ -f /lib/lsb/init-functions ]; then
66        . /lib/lsb/init-functions
67fi
68
69test -x $DAEMON || {
70        if [ "$1" = "stop" ]; then
71                log_warning_msg "$DAEMON not installed, but stopping anyway."
72        else
73                exit 5
74        fi }
75
76# Read config file if present.
77if [ -r /etc/default/$NAME ]; then
78        . /etc/default/$NAME
79fi
80
81if [ $START -eq 0 ]; then
82        log_warning_msg "Not starting $DESC: edit /etc/default/$NAME."
83        exit 1
84fi
85
86case "$1" in
87  start)
88        log_daemon_msg "Starting $DESC" "$NAME"
89
90        start_daemon -p $PID $DAEMON -p $PID
91
92        log_end_msg $?
93        ;;
94  stop)
95        log_daemon_msg "Stopping $DESC" "$NAME"
96
97        killproc -p $PID $DAEMON
98
99        log_end_msg $?
100
101        [ ! -f "$PID" ] || rm -f $PID
102        ;;
103  restart|force-reload)
104        log_daemon_msg "Stopping $DESC" "$NAME"
105
106        killproc -p $PID $DAEMON
107
108        log_end_msg $?
109
110        [ ! -f "$PID" ] || rm -f $PID
111
112        [ -n "$DIETIME" ] && sleep "$DIETIME"
113
114        log_daemon_msg "Starting $DESC" "$NAME"
115
116        start_daemon -p $PID $DAEMON -- -p $PID
117
118        log_end_msg $?
119        ;;
120  status)
121        log_daemon_msg "Checking status of $DESC"
122
123        pidofproc $DAEMON
124
125        status="$?"
126        log_end_msg "$status"
127
128        case "$status" in
129                0)
130                        log_success_msg "$NAME running"
131                ;;
132                1)
133                        log_warning_msg "$NAME not running (but pid file found)"
134                ;;
135                2)
136                        log_warning_msg "$NAME not running (but lock file found)"
137                ;;
138                3)
139                        log_warning_msg "$NAME not running"
140                ;;
141                4|*)
142                        log_failure_msg "Service status is unknown"
143                        exit 1
144                ;;
145        esac
146        ;;
147       
148  *)
149        N=/etc/init.d/$NAME
150        echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
151        exit 1
152        ;;
153esac
154
155exit 0
Note: See TracBrowser for help on using the browser.