From 7f0feb0a8348afb2c793946fbb89ef8fefd6086f Mon Sep 17 00:00:00 2001 From: Starrah Date: Fri, 30 Aug 2024 17:23:39 +0800 Subject: [PATCH] fix: procd script cannot auto re-auth In previous version, start_pre() is executed ONLY ONCE when the script is loaded by procd, while ONLY the "online" command is set as procd's instance command. This causes procd will only try to respawn the "online" command, rather than "deauth-auth-login" again. --- docs/init.d/goauthing | 17 ++++++++++------- docs/init.d/goauthing@ | 17 ++++++++++++----- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/docs/init.d/goauthing b/docs/init.d/goauthing index 9691924..f44c764 100644 --- a/docs/init.d/goauthing +++ b/docs/init.d/goauthing @@ -7,17 +7,20 @@ START=98 PROG="/usr/bin/goauthing" # cp script to this path first CONF="/etc/goauthing.json" -start_pre() { - "$PROG" -c "$CONF" -D deauth - "$PROG" -c "$CONF" -D auth - "$PROG" -c "$CONF" -D login +generate_command() { +CMD="\ +\"$PROG\" -c \"$CONF\" -D deauth; \ +\"$PROG\" -c \"$CONF\" -D auth; \ +\"$PROG\" -c \"$CONF\" -D login; \ +\"$PROG\" -c \"$CONF\" -D online; \ +" } start_service() { - start_pre + generate_command procd_open_instance - procd_set_param command "$PROG" - procd_append_param command -c "$CONF" -D online + procd_set_param command sh + procd_append_param command -c "$CMD" procd_set_param stderr 1 procd_set_param respawn procd_close_instance diff --git a/docs/init.d/goauthing@ b/docs/init.d/goauthing@ index 5e990fc..bebd3a1 100644 --- a/docs/init.d/goauthing@ +++ b/docs/init.d/goauthing@ @@ -7,19 +7,26 @@ START=98 PROG="/usr/bin/goauthing" SERV=goauthing # UCI config at /etc/config/goauthing +generate_command() { +CMD="\ +\"$PROG\" $1 deauth; \ +\"$PROG\" $1 auth; \ +\"$PROG\" $1 login; \ +\"$PROG\" $1 online; \ +" +} + start_instance() { local username password config_get username config username config_get password config password local args="-u $username -p $password" - "$PROG" $args deauth - "$PROG" $args auth - "$PROG" $args login + generate_command "$args" procd_open_instance - procd_set_param command "$PROG" - procd_append_param command $args online + procd_set_param command sh + procd_append_param command -c "$CMD" procd_set_param stderr 1 procd_set_param respawn procd_close_instance