wpa-supplicant.sh: updated to modern init script format, refactoring, and new restart functionality
PATCH v2 1/1 wpa-supplicant.sh: updated to modern init script format, refactoring, and new restart functionality
Fixed a bug in the original commit where restart exited success without starting the daemon. Now both start and stop call check_socket to verify the socket was added/removed, and success is returned at the end of the script instead of in the body.
Signed-off-by Andrew Wichmann <[email protected]>
--- .../wpa-supplicant/wpa-supplicant.sh | 26 +++++++++++++++------- 1 file changed, 18 insertions(+), 8 deletions(-)
meta/recipes-connectivity/wpa-supplicant/wpa-supplicant/wpa-supplicant.sh +18 -8
@@ -50,7 +50,7 @@ start() { --name $WPA_SUP_PNAME --startas $WPA_SUP_BIN --pidfile $WPA_SUP_PIDFILE \ -- $WPA_SUP_OPTIONS $WPA_SUP_CONF -D $IF_WPA_DRIVER fi - check_socket + check_socket "start" } stop() {
@@ -69,16 +69,26 @@ stop() { rm -f $WPA_SUP_PIDFILE fi fi - exit 0 + check_socket "stop" } check_socket(){ - # if the interface socket exists, then wpa_supplicant was invoked successfully - if [ -S "$WPA_COMMON_CTRL_IFACE/$IFACE" ] - then - [ "$VERBOSE" = "yes" ] && echo "$WPA_SUP_PNAME: ctrl_interface socket located at$WPA_COMMON_CTRL_IFACE/$IFACE" - exit 0 + if [ $1 = "start" ]; then + # if the interface socket exists, then wpa_supplicant start was invoked successfully + if [ -S "$WPA_COMMON_CTRL_IFACE/$IFACE" ]; then + [ "$VERBOSE" = "yes" ] && echo "$WPA_SUP_PNAME: ctrl_interface socket located at$WPA_COMMON_CTRL_IFACE/$IFACE" + return + fi + + else if [$1 = "stop" ]; then + # if the interface socket does not exists, then wpa_supplicant stop was invoked successfully + if [ ! -S "$WPA_COMMON_CTRL_IFACE/$IFACE" ];then + [ "$VERBOSE" = "yes" ] && echo "$WPA_SUP_PNAME: ctrl_interface socket was removed" + return + fi fi + + # if the program reaches this line, then wpa_supplicant was invoked incorrectly exit 1 }
@@ -99,4 +109,4 @@ case "$1" in esac -exit 1 +exit 0
Signature · 1 line
1.9.1