gost: init: convert to procd

This commit is contained in:
CN_SZTL 2020-07-13 00:36:15 +08:00
parent 4f5d7e452c
commit af30aab7f2
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
4 changed files with 40 additions and 22 deletions

View File

@ -52,6 +52,10 @@ endef
define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(GO_PKG_BUILD_BIN_DIR)/gost $(1)/usr/bin/gost
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_CONF) $(CURDIR)/files/gost.config $(1)/etc/config/gost
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) $(CURDIR)/files/gost.init $(1)/etc/init.d/gost
endef
$(eval $(call GoBinPackage,$(PKG_NAME)))

View File

@ -0,0 +1,36 @@
#!/bin/sh /etc/rc.common
# Created By [CTCGFW]Project OpenWRT
# https://github.com/project-openwrt
START=99
STOP=10
USE_PROCD=1
enable="$(uci get gost.@gost[0].enable)"
run_command="$(uci get gost.@gost[0].run_command)"
start_service() {
[ "${enable}" -ne "1" ] && exit 0
procd_open_instance gost
procd_set_param command /usr/bin/gost
procd_append_param command ${run_command}
procd_set_param respawn ${respawn_threshold:-3600} ${respawn_timeout:-5} ${respawn_retry:-5}
procd_set_param limits core="unlimited"
procd_set_param stdout 1
procd_set_param stderr 1
procd_close_instance
}
reload_service()
{
stop
start
}
service_triggers()
{
procd_add_reload_trigger "gost"
}

View File

@ -1,22 +0,0 @@
#!/bin/sh /etc/rc.common
# Created By [CTCGFW]Project OpenWRT
# https://github.com/project-openwrt
START=90
STOP=10
enable="$(uci get gost.@gost[0].enable)"
run_command="$(uci get gost.@gost[0].run_command)"
start()
{
stop
[ "${enable}" -ne "1" ] && exit 0
/usr/bin/gost ${run_command} &
}
stop()
{
killall -9 "gost" > "/dev/null" 2>&1
}