summaryrefslogtreecommitdiffstats
path: root/sbin/init.d
diff options
context:
space:
mode:
authorWilly Tarreau <w@1wt.eu>2006-07-16 15:09:57 +0200
committerWilly Tarreau <willy@wtap.(none)>2006-07-26 12:03:42 +0200
commit0cc995b7882bec453af53dcfe6b827932e1f2e4c (patch)
tree5d8929f02973b0ed2549bc24ab60a6cfcbac4d8f /sbin/init.d
parent[RELEASE] init-scripts-0.3.23 (diff)
downloadinit-scripts-0cc995b7882bec453af53dcfe6b827932e1f2e4c.tar.gz
[RELEASE] init-scripts-0.3.24v0.3.24
Diffstat (limited to 'sbin/init.d')
-rwxr-xr-xsbin/init.d/functions6
-rwxr-xr-xsbin/init.d/pdnsd38
2 files changed, 39 insertions, 5 deletions
diff --git a/sbin/init.d/functions b/sbin/init.d/functions
index 883e256..491ba41 100755
--- a/sbin/init.d/functions
+++ b/sbin/init.d/functions
@@ -1,7 +1,7 @@
#!/bin/bash
#
-# sbin/init.d/functions - Formilux init script - version 0.3.23 - 2003-09-15
+# sbin/init.d/functions - Formilux init script - version 0.3.24 - 2003-10-02
#
# Copyright (C) 2001-2003 Benoit Dolez & Willy Tarreau
# mailto: benoit@ant-computing.com,willy@ant-computing.com
@@ -476,8 +476,10 @@ function do_stop {
return 0
}
+# we *absolutely* want to restart the service, even if it's frozen as "defunct"
function do_restart {
- do_stop $* && do_start $*
+ do_stop $* || ( FORCE_START_STOP=1 do_stop $* )
+ do_start $*
}
# returns a basic check of the service, an returns one line of info of the form:
diff --git a/sbin/init.d/pdnsd b/sbin/init.d/pdnsd
index 9adeb55..fbc3769 100755
--- a/sbin/init.d/pdnsd
+++ b/sbin/init.d/pdnsd
@@ -3,14 +3,46 @@
. `dirname $0`/functions
option config standard_option /etc/pdnsd.conf
-option pidfile reserved_option /var/run/syslog-ng.pid
+option pidfile reserved_option /var/run/pdnsd.pid
option bin reserved_option /usr/sbin/pdnsd
option cmdline reserved_option '$bin -c $opt_config -d -p $pidfile'
-# perform a forced synchronisation before starting the daemon
+# reinitialize the cache before starting the daemon
function fct_pre_start {
- if [ ! -d /var/cache/pdnsd ] ; then mkdir -p /var/cache/pdnsd ; fi
+ local user="$($bin -c $opt_config --pdnsd-user 2>/dev/null)"
+
+ if [ ! -d /var/cache/pdnsd ]; then
+ rm -f /var/cache/pdnsd >/dev/null 2>&1
+ mkdir -p /var/cache/pdnsd
+ fi
+
+ # compilation defaults state that default user is "nobody"
+ user="${user:-nobody}"
+ grep -q "^$user:" /etc/passwd || user="nobody"
+
+ # unconditionally rebuild the cache :
+ # - either it's empty and pdnsd will not start
+ # - or it's filled, but if damaged, it may crash
+ rm -f /var/cache/pdnsd/pdnsd.cache 2>/dev/null
+ dd if=/dev/zero of=/var/cache/pdnsd/pdnsd.cache bs=4 count=1 >/dev/null 2>&1
+ chown $user:adm /var/cache/pdnsd /var/cache/pdnsd/pdnsd.cache
+ chmod 750 /var/cache/pdnsd
+ chmod 640 /var/cache/pdnsd/pdnsd.cache
+ return 0
+}
+
+# this function ensures that the daemon really dies, even if multiple
+# pids appear while the pidfile only references one.
+function fct_post_stop {
+ local -a pids
+ local pid=$$
+
+ pids=( $(pidof -o $pid pdnsd) )
+ [ ${#pids[@]} -eq 0 ] && return 0
+ kill ${pids[@]} >/dev/null 2>&1
+ kill -9 ${pids[@]} >/dev/null 2>&1
+ return 0
}
load_config