From 2d08ce252a39abc8ce53794670b1f0a9e1a55adb Mon Sep 17 00:00:00 2001 From: Matthew Sheppard Date: Mon, 28 Oct 2019 13:12:40 +0800 Subject: [PATCH] Luci-app-nps change to use procd init script (#1895) * Add luci-app-nps https://github.com/cnlh/nps * Luci-app-nps change to use procd init script * optimize Shell script --- package/lean/luci-app-nps/root/etc/init.d/nps | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/package/lean/luci-app-nps/root/etc/init.d/nps b/package/lean/luci-app-nps/root/etc/init.d/nps index be3db8f5d6f..e9ab09f96df 100755 --- a/package/lean/luci-app-nps/root/etc/init.d/nps +++ b/package/lean/luci-app-nps/root/etc/init.d/nps @@ -2,8 +2,7 @@ # Copyright (C) 2006-2011 OpenWrt.org START=50 -SERVICE_WRITE_PID=1 -SERVICE_DAEMONIZE=1 +USE_PROCD=1 LOGFILE="/var/etc/nps.log" tmpconf="/tmp/etc/nps.conf" @@ -46,23 +45,20 @@ nps_write_bool() { fi } -start() { +start_service() { config_load nps config_foreach nps_header nps - if [ "$Enabled" = "0" ];then - stop - else - logger -t FRPC 'Starting Nps service' - service_start /usr/bin/npc -config=$tmpconf -log_level=$Log_level -log_path=$LOGFILE + if [ "$Enabled" = "1" ];then + logger -t FRPC 'Starting Nps service' + #service_start /usr/bin/npc -config=$tmpconf -log_level=$Log_level -log_path=$LOGFILE + procd_open_instance + procd_set_param command /usr/bin/npc -config=$tmpconf -log_level=$Log_level + procd_set_param file $tmpconf + procd_set_param respawn + procd_set_param stdout 1 + procd_set_param stderr 1 + procd_close_instance fi - - return 0 } -stop() { - service_stop /usr/bin/npc - rm $tmpconf - logger -t FRPC 'Nps service stopped' - return 0 -}