p910nd: init script
authorPaul Donald <newtwen@gmail.com>
Sat, 10 Feb 2024 17:35:35 +0000 (18:35 +0100)
committerPaul Donald <newtwen@gmail.com>
Wed, 14 Feb 2024 23:05:59 +0000 (00:05 +0100)
Don't run procd with a name of p9100d or p9101d etc.
Use the original binary name: p910nd.

This way, all supplied parameters should be visible via e.g.:

ps
xargs -0 < /proc/{procid}/cmdline

Revise all p910nd strings to the variable DAEMON_NAME or CONFIG where
appropriate.

Signed-off-by: Paul Donald <newtwen@gmail.com>
(cherry picked from commit 3f04d2d791fb18d03e990926955b87198293bb9d)

net/p910nd/files/p910nd.init

index 2ddbdc7128d8b7707af513cee08ff7f12f48769b..2332d917535d452910ffebadc65742a8efb81963 100644 (file)
@@ -2,6 +2,8 @@
 # Copyright (C) 2007 OpenWrt.org
 START=99
 USE_PROCD=1
+DAEMON_NAME="p910nd"
+CONFIG="p910nd"
 
 append_bool() {
        local section="$1"
@@ -22,8 +24,8 @@ append_string() {
 }
 
 start_service() {
-       config_load "p910nd"
-       config_foreach start_p910nd p910nd
+       config_load $CONFIG
+       config_foreach start_p910nd $CONFIG
 }
 
 
@@ -33,17 +35,16 @@ start_p910nd() {
        if [ "$enabled" -gt 0 ]; then
                args="-d "
                config_get port "$section" port
-               name=p910${port}d
                append_bool "$section" bidirectional "-b"
                append_string "$section" device "-f "
                append_string "$section" bind "-i "
                append_string "$section" port ""
-               procd_open_instance $name
-               procd_set_param command /usr/sbin/p910nd $args
+               procd_open_instance $DAEMON_NAME
+               procd_set_param command /usr/sbin/$DAEMON_NAME $args
                procd_set_param respawn
 
                config_get_bool runas_root "$section" runas_root 0
-               [ "$runas_root" -ne 1 ] && procd_set_param user p910nd
+               [ "$runas_root" -ne 1 ] && procd_set_param user $DAEMON_NAME
 
                config_get_bool "mdns" "$section" "mdns" '0'
                config_get mdns_note "$section" mdns_note
@@ -61,6 +62,6 @@ start_p910nd() {
 service_triggers()
 {
        procd_open_trigger
-       procd_add_config_trigger "config.change" "p910nd" /etc/init.d/p910nd reload
+       procd_add_config_trigger "config.change" $DAEMON_NAME /etc/init.d/$DAEMON_NAME reload
        procd_close_trigger
 }