create_ap

create a nat-ed wifi ap
git clone git://git.2f30.org/create_ap
Log | Files | Refs | README | LICENSE

commit 8f112390b24bc3361e17343b6718b5dbdce1dadb
parent 661a8aa1b71520130297c393b92d1504ed4d4a90
Author: oblique <psyberbits@gmail.com>
Date:   Sat,  2 May 2015 01:01:33 +0300

Kill haveged only if we are the last create_ap instance

Diffstat:
Mcreate_ap | 27++++++++++++++-------------
1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/create_ap b/create_ap @@ -399,11 +399,7 @@ haveged_watchdog() { elif ! pidof haveged > /dev/null 2>&1; then echo "Low entropy detected, starting haveged" # boost low-entropy - haveged -w 1024 -F > /dev/null 2>&1 & - local haveged_pid=$! - echo $haveged_pid > $CONFDIR/haveged.pid - mutex_unlock - wait $haveged_pid + haveged -w 1024 -p $COMMON_CONFDIR/haveged.pid fi fi mutex_unlock @@ -601,32 +597,35 @@ HAVEGED_WATCHDOG_PID= _cleanup() { local PID x - mutex_lock - trap "" SIGINT SIGUSR1 SIGUSR2 EXIT + mutex_lock + disown -a # kill haveged_watchdog [[ -n "$HAVEGED_WATCHDOG_PID" ]] && kill $HAVEGED_WATCHDOG_PID - # exiting + # kill processes for x in $CONFDIR/*.pid; do # even if the $CONFDIR is empty, the for loop will assign # a value in $x. so we need to check if the value is a file - if [[ -f $x ]]; then - PID=$(cat $x) - disown $PID - kill -9 $PID - fi + [[ -f $x ]] && kill -9 $(cat $x) done + rm -rf $CONFDIR # if we are the last create_ap instance then set back the common values if ! has_running_instance; then + # kill common processes + for x in $COMMON_CONFDIR/*.pid; do + [[ -f $x ]] && kill -9 $(cat $x) + done + # set old ip_forward if [[ -f $COMMON_CONFDIR/ip_forward ]]; then cp $COMMON_CONFDIR/ip_forward /proc/sys/net/ipv4 rm -f $COMMON_CONFDIR/ip_forward fi + # set old bridge-nf-call-iptables if [[ -f $COMMON_CONFDIR/bridge-nf-call-iptables ]]; then if [[ -e /proc/sys/net/bridge/bridge-nf-call-iptables ]]; then @@ -634,6 +633,8 @@ _cleanup() { fi rm -f $COMMON_CONFDIR/bridge-nf-call-iptables fi + + rm -rf $COMMON_CONFDIR fi if [[ "$SHARE_METHOD" != "none" ]]; then