diff options
author | PÁLI Gábor János <pali.gabor@gmail.com> | 2022-04-23 21:53:23 +0200 |
---|---|---|
committer | PÁLI Gábor János <pali.gabor@gmail.com> | 2022-04-23 21:57:14 +0200 |
commit | 72f172a8eab45e2cdac686e92e0eaff16adf4560 (patch) | |
tree | 659c14167e5af9d5441562469758336665512b3f /aports | |
parent | 3ed31a8e2a23d6c52b2662752a3741deaa1219e1 (diff) | |
download | freebsd-wifibox-alpine-72f172a8eab45e2cdac686e92e0eaff16adf4560.zip |
wpa_passthru: Rework how the script is stopped.
Diffstat (limited to 'aports')
-rw-r--r-- | aports/wpa_passthru/APKBUILD | 4 | ||||
-rw-r--r-- | aports/wpa_passthru/wpa_passthru | 46 |
2 files changed, 35 insertions, 15 deletions
diff --git a/aports/wpa_passthru/APKBUILD b/aports/wpa_passthru/APKBUILD index 5672428..9b19541 100644 --- a/aports/wpa_passthru/APKBUILD +++ b/aports/wpa_passthru/APKBUILD @@ -1,7 +1,7 @@ # Maintainer: Gabor Pali <pali.gabor@gmail.com> pkgname=wpa_passthru -pkgver=0.1.0 +pkgver=0.1.1 pkgrel=0 pkgdesc="WPA Supplicant pass-through for Wifibox" url="https://github.com/pgj/freebsd-wifibox-alpine" @@ -19,5 +19,5 @@ package() { } sha512sums=" ab107ef28b73517468c8e4558642b798fb3b6861e9ad92df4fd9912b5c3a56aa83822ce71ac1d4b84bf3113dc9c8c1aec6a76e3be17f0613ee722108a384e3ff wpa_passthru.initd -46178341d5cd323bc2e7bdf1f21158e7806f6746efe480f1f0f9b57254355b78def8e90d5f5e87e10122b04f6280da711865640ee38faa7566c5da0f3d9f18c3 wpa_passthru +d4af36a86994b6332ac261b450a00f28bc83f0478fdd7bbee7b7ebcbafd90bec144eb657bc00ae373797c207199d12ca9e525b164cb5cfe634866f0de41dc35c wpa_passthru " diff --git a/aports/wpa_passthru/wpa_passthru b/aports/wpa_passthru/wpa_passthru index 4e95d2f..babb5b5 100644 --- a/aports/wpa_passthru/wpa_passthru +++ b/aports/wpa_passthru/wpa_passthru @@ -9,6 +9,7 @@ log() { } enabled=no +_block= # shellcheck disable=SC1091 . /media/etc/wpa_ctrl.conf @@ -24,18 +25,26 @@ fi if_lan=eth0 wpa_conf="/media/wpa/wpa_supplicant.conf" -cleanup() { - local _socats - - _socats=$(/usr/bin/pgrep socat) - log info "Stopping, socat processes: [${_socats}]" - [ -n "${_socats}" ] \ - && /usr/bin/kill -TERM ${_socats} - [ -n "${_socket_directory}" ] \ - && /bin/rm -rf "${_socket_directory}" +terminate() { + local _sleep + + if [ -n "${_block}" ]; then + log info "Received signal for termination, stopping PID ${_block}." + /bin/kill -KILL "${_block}" + log debug "Killed: $?" + _sleep=$(/bin/ps -o ppid,comm,pid \ + | /bin/grep -F "1 sleep" \ + | /usr/bin/head -1 \ + | /bin/sed "s@[ ]*1[ ]*sleep[ ]*@@") + log info "Stopping the orphaned sleep as PID ${_sleep}." + /bin/kill -KILL "${_sleep}" + log debug "Killed: $?" + else + log warn "Nothing is blocked, nothing to do." + fi } -trap cleanup EXIT TERM +trap terminate TERM find_network() { /sbin/ifconfig ${if_lan} \ @@ -96,6 +105,17 @@ for _wlan_dev in ${_wlan_devs}; do UNIX-SENDTO:"${_ctrl_socket}",bind="${_socket}",unlink-early & done -while /bin/true; do - /bin/sleep 60 -done +(while /bin/true; do /bin/sleep 365d; done) & +_block=$! + +log info "Waiting for PID ${_block} to stop." +wait "${_block}" + +_socats=$(/usr/bin/pgrep socat) +log info "Stopping, socat processes: [${_socats}]" + +# shellcheck disable=SC2086 +[ -n "${_socats}" ] && /bin/kill -TERM ${_socats} +[ -n "${_socket_directory}" ] && /bin/rm -rf "${_socket_directory}" + +log info "Finished." |