Skip to content

Commit

Permalink
fix: procd script cannot auto re-auth
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Starrah committed Aug 30, 2024
1 parent e42c2fd commit 7f0feb0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
17 changes: 10 additions & 7 deletions docs/init.d/goauthing
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 12 additions & 5 deletions docs/init.d/goauthing@
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7f0feb0

Please sign in to comment.