diff options
author | Renato Botelho <garga@FreeBSD.org> | 2013-04-30 18:29:19 -0300 |
---|---|---|
committer | Renato Botelho <garga@FreeBSD.org> | 2013-04-30 18:29:19 -0300 |
commit | 8596af32d3bf099dce8df344c90b8a525598f00f (patch) | |
tree | 63bc740009c1ea228dd1cc4649fd04fc00d549c6 /config | |
parent | 20765c96dc454d40d452fd4dbeb91c2ec5c53d12 (diff) | |
download | pfsense-packages-8596af32d3bf099dce8df344c90b8a525598f00f.tar.gz pfsense-packages-8596af32d3bf099dce8df344c90b8a525598f00f.tar.bz2 pfsense-packages-8596af32d3bf099dce8df344c90b8a525598f00f.zip |
Fix unbound_monitor.sh (Ticket #2817)
. Use a PID file to keep track if it's running or not
. Move it to /usr/local/bin, it doesn't need to be started by
rc.start_packages since it's already called by unbound.inc
. Define PATH and remove complete path for all binaries
. Remove unbound initscript symlink created when it's installed by a PBI
package
. Bump unbound to 1.4.20_5
Diffstat (limited to 'config')
-rw-r--r-- | config/unbound/unbound.inc | 7 | ||||
-rw-r--r-- | config/unbound/unbound.xml | 4 | ||||
-rwxr-xr-x | config/unbound/unbound_monitor.sh | 27 |
3 files changed, 27 insertions, 11 deletions
diff --git a/config/unbound/unbound.inc b/config/unbound/unbound.inc index 3287b194..c5cbfc49 100644 --- a/config/unbound/unbound.inc +++ b/config/unbound/unbound.inc @@ -70,6 +70,7 @@ function unbound_initial_setup() { // We do not need the sample conf or the default rc.d startup file @unlink_if_exists(UNBOUND_BASE . "/etc/unbound/unbound.conf.sample"); @unlink_if_exists(UNBOUND_BASE . "/etc/rc.d/unbound"); + @unlink_if_exists("/usr/local/etc/rc.d/unbound"); // Setup rc file for startup and shutdown. unbound_rc_setup(); @@ -205,7 +206,7 @@ function unbound_control($action) { @unlink("/var/run/dnsmasq.pid"); mwexec("/bin/ln -s /var/run/unbound.pid /var/run/dnsmasq.pid"); } - mwexec_bg("/usr/local/etc/rc.d/unbound_monitor.sh start"); + mwexec_bg("/usr/local/bin/unbound_monitor.sh"); fetch_root_hints(); } break; @@ -213,14 +214,14 @@ function unbound_control($action) { case "stop": //Stop unbound and unmount the file system if($unbound_config['unbound_status'] == "on") { - mwexec_bg("/usr/local/etc/rc.d/unbound_monitor.sh stop"); + mwexec_bg("/usr/local/bin/unbound_monitor.sh stop"); unbound_ctl_exec("stop"); } break; case "termstop": //Stop Unbound by sigkillbypid(); - mwexec_bg("/usr/local/etc/rc.d/unbound_monitor.sh stop"); + mwexec_bg("/usr/local/bin/unbound_monitor.sh stop"); sigkillbypid("{$g['varrun_path']}/unbound.pid", "TERM"); break; diff --git a/config/unbound/unbound.xml b/config/unbound/unbound.xml index 36c005a4..10de1f97 100644 --- a/config/unbound/unbound.xml +++ b/config/unbound/unbound.xml @@ -40,7 +40,7 @@ <requirements/> <faq/> <name>unbound</name> - <version>1.4.20_4</version> + <version>1.4.20_5</version> <title>Services: Unbound DNS Forwarder: Basic Settings</title> <include_file>/usr/local/pkg/unbound.inc</include_file> <menu> @@ -76,7 +76,7 @@ <item>http://www.pfsense.org/packages/config/unbound/unbound_advanced.xml</item> </additional_files_needed> <additional_files_needed> - <prefix>/usr/local/etc/rc.d/</prefix> + <prefix>/usr/local/bin/</prefix> <chmod>0755</chmod> <item>http://www.pfsense.org/packages/config/unbound/unbound_monitor.sh</item> </additional_files_needed> diff --git a/config/unbound/unbound_monitor.sh b/config/unbound/unbound_monitor.sh index 042866be..c277bbaa 100755 --- a/config/unbound/unbound_monitor.sh +++ b/config/unbound/unbound_monitor.sh @@ -27,33 +27,48 @@ # POSSIBILITY OF SUCH DAMAGE. # +export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin + set -e LOOP_SLEEP=5 +PIDFILE=/var/run/unbound_monitor.pid if [ -f /var/run/unbound_alarm ]; then rm /var/run/unbound_alarm fi +PID="" +if [ -f "${PIDFILE}" ]; then + PID=`head -n 1 ${PIDFILE}` +fi if [ "$1" = "stop" ]; then - pkill -f unbound_monitor.sh + if [ -n "${PID}" ] && ps -p ${PID} | grep -q unbound_monitor.sh; then + kill ${PID} + else + pkill -f unbound_monitor.sh + fi exit 0 fi -PROCS=`/bin/pgrep -f unbound_monitor.sh | wc -l | awk '{print $1}'` - -if [ ${PROCS} -gt 1 ]; then +if [ -n "${PID}" ] && ps -p ${PID} | grep -q unbound_monitor.sh; then echo "There are another unbound monitor proccess running" exit 0 fi +echo $$ > ${PIDFILE} + # Sleep 5 seconds on startup not to mangle with existing boot scripts. sleep 5 while true; do + if [ ! -f "${PIDFILE}" ]; then + echo $$ > ${PIDFILE} + fi + if [ ! -f /var/run/unbound_alarm ]; then - NUM_PROCS=`/bin/pgrep unbound | wc -l | awk '{print $1}'` + NUM_PROCS=`pgrep unbound | wc -l | awk '{print $1}'` if [ $NUM_PROCS -lt 1 ]; then # Unbound is not running echo "Unbound has exited." | logger -p daemon.info -i -t Unbound_Alarm @@ -63,7 +78,7 @@ while true; do touch /var/run/unbound_alarm fi fi - NUM_PROCS=`/bin/pgrep unbound | wc -l | awk '{print $1}'` + NUM_PROCS=`pgrep unbound | wc -l | awk '{print $1}'` if [ $NUM_PROCS -gt 0 ]; then if [ -f /var/run/unbound_alarm ]; then echo "Unbound has resumed." | logger -p daemon.info -i -t Unbound_Alarm |