diff options
author | Renato Botelho <garga@FreeBSD.org> | 2015-03-27 16:38:51 -0300 |
---|---|---|
committer | Renato Botelho <garga@FreeBSD.org> | 2015-03-27 16:38:51 -0300 |
commit | babc54b9d664fd29f562d87cc7f9a02c6414fa7a (patch) | |
tree | 31862a80bff52ddaac546ebdb96bb2008a7e099d /config | |
parent | 3c555e74abb2833a61bda5525a16a261c5bb5ab4 (diff) | |
parent | 8a344ecccd0f111562804d4a01828386458c7fb6 (diff) | |
download | pfsense-packages-babc54b9d664fd29f562d87cc7f9a02c6414fa7a.tar.gz pfsense-packages-babc54b9d664fd29f562d87cc7f9a02c6414fa7a.tar.bz2 pfsense-packages-babc54b9d664fd29f562d87cc7f9a02c6414fa7a.zip |
Merge pull request #839 from k-paulius/fix-4337
Diffstat (limited to 'config')
-rw-r--r-- | config/freeradius2/freeradius.inc | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/config/freeradius2/freeradius.inc b/config/freeradius2/freeradius.inc index df231821..00076816 100644 --- a/config/freeradius2/freeradius.inc +++ b/config/freeradius2/freeradius.inc @@ -134,7 +134,42 @@ function freeradius_install_command() { $rcfile = array(); $rcfile['file'] = 'radiusd.sh'; - $rcfile['start'] = FREERADIUS_ETC . '/rc.d/radiusd onestart'; + $freeradius_etc_dir = FREERADIUS_ETC; + $rcfile['start'] = <<<EOD +SERVICENAME="radiusd" + LOCKFILE="/tmp/\${SERVICENAME}_start.lock" + PIDFILE="/var/run/\${SERVICENAME}.pid" + + # prevent this part of script from running in parallel + if ( set -o noclobber; echo "\$\$" > "\$LOCKFILE") 2> /dev/null; then + # make sure lock file is removed even if script is terminated + trap 'rm -f "\$LOCKFILE"; exit \$?' INT TERM EXIT + + {$freeradius_etc_dir}/rc.d/radiusd onestart + + # try to wait until the service starts + if [ ! -f "\$PIDFILE" ]; then + echo "\$SERVICENAME.sh: PID file was not found" + + for i in 1 2 3 4 5; do + if [ -f "\$PIDFILE" ]; then + echo "\$SERVICENAME.sh: Service started PID: `cat \$PIDFILE`" + break + else + echo "\$SERVICENAME.sh: Waiting 0.5 seconds" + sleep 0.5 + fi + done + else + echo "\$SERVICENAME.sh: Service running PID: `cat \$PIDFILE`" + fi + + rm -f "\$LOCKFILE" + trap - INT TERM EXIT + else + echo "\$SERVICENAME.sh: Cannot continue at this moment, this script is already trying to start service PID: \$(cat \$LOCKFILE)" + fi +EOD; $rcfile['stop'] = FREERADIUS_ETC . '/rc.d/radiusd onestop'; write_rcfile($rcfile); conf_mount_ro(); |