Mandriva: when server starts/stops, run scripts

With this feature, server special initialization and/or preparation can
be scripted. The same after stopping, too.

bzr revid: p_christ@hol.gr-20091023222925-oph2bc6kr3u0ol7w
This commit is contained in:
P. Christeas 2009-10-24 01:29:25 +03:00
parent 78ac7ac767
commit c716ecb731
1 changed files with 30 additions and 17 deletions

View File

@ -50,6 +50,14 @@ fi
RETVAL=0
start() {
if [ -d /etc/openerp/start.d ] ; then
echo -n $"Preparing $desc: "
run-parts --exit-on-error /etc/openerp/start.d
RETVAL=$?
echo
[ $RETVAL -ne 0 ] && return $RETVAL
fi
echo -n $"Starting $desc ($prog): "
daemon --user openerp --check openerp-server \
"/usr/bin/setsid /usr/bin/openerp-server \
@ -66,18 +74,23 @@ start() {
stop() {
echo -n $"Stopping $desc ($prog): "
kill -TERM `cat $PIDFILE` > /dev/null 2>&1
RETVAL=$?
if [ $RETVAL -eq 0 ] ; then
rm -f $LOCKFILE
RETVAL=$?
if [ $RETVAL -eq 0 ] ; then
rm -f $LOCKFILE
echo_success
echo
else
echo_failure
echo
fi
return $RETVAL
}
echo_success
echo
else
echo_failure
echo
fi
if [ -d /etc/openerp/stop.d ] ; then
echo -n $"Clearing $desc: "
run-parts /etc/openerp/stop.d
echo
fi
return $RETVAL
}
restart() {
stop
@ -91,14 +104,14 @@ condrestart() {
status() {
if [ -f $PIDFILE ] ; then
checkpid `cat $PIDFILE`
RETVAL=$?
RETVAL=$?
if [ $RETVAL -eq 0 ] ; then
echo $"$prog is running..."
else
echo $"$prog is stopped"
fi
echo $"$prog is running..."
else
echo $"$prog is stopped"
fi
else
echo $"$prog is stopped"
echo $"$prog is stopped"
fi
return $RETVAL
}