mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2025-12-10 07:44:50 +01:00
stunc: Added ci and docs
This commit is contained in:
parent
18545a1fb9
commit
ad0867991f
4 changed files with 75 additions and 43 deletions
|
|
@ -8,9 +8,9 @@
|
|||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=stunc
|
||||
PKG_VERSION:=1.0.0
|
||||
PKG_VERSION:=1.0.1
|
||||
|
||||
PKG_SOURCE_VERSION:=74c8205a45a69572d0c6a2615e87c019c15f8972
|
||||
PKG_SOURCE_VERSION:=cd7c5d70bc97a2f1a26d5587ccf6f4c1e9ca82c8
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/stunc.git
|
||||
|
||||
|
|
@ -41,8 +41,11 @@ TARGET_CFLAGS += \
|
|||
|
||||
define Package/$(PKG_NAME)/install
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/stund $(1)/usr/sbin/
|
||||
$(CP) ./files/* $(1)/
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/stunc $(1)/usr/sbin/
|
||||
$(INSTALL_BIN) ./files/etc/init.d/stunc $(1)/etc/init.d/stunc
|
||||
$(INSTALL_DATA) ./files/etc/config/stun $(1)/etc/config/stun
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,$(PKG_NAME)))
|
||||
|
|
|
|||
|
|
@ -8,7 +8,5 @@ config stun 'stun'
|
|||
option min_keepalive '30'
|
||||
option max_keepalive '3600'
|
||||
# option client_port 7547
|
||||
#if client_port option is not set or < 0 then use a random port for connection request source port
|
||||
#Log levels: Critical=0, Warning=1, Notice=2, Info=3, Debug=4
|
||||
option log_level '3'
|
||||
option log_level '0'
|
||||
|
||||
|
|
|
|||
67
stunc/files/etc/init.d/stunc
Executable file
67
stunc/files/etc/init.d/stunc
Executable file
|
|
@ -0,0 +1,67 @@
|
|||
#!/bin/sh /etc/rc.common
|
||||
# STUN client software
|
||||
# Copyright (C) 2020 iopsys Software Solutions AB
|
||||
# Author: Omar Kallel <omar.kallel@pivasoftware.com>
|
||||
|
||||
START=90
|
||||
|
||||
USE_PROCD=1
|
||||
PROG="/usr/sbin/stunc"
|
||||
|
||||
|
||||
log() {
|
||||
#echo "${@}" >/dev/console
|
||||
echo "${@}"|logger -t stun -p info
|
||||
}
|
||||
|
||||
validate_stun_section()
|
||||
{
|
||||
uci_validate_section stun stun stun \
|
||||
'enable:bool' \
|
||||
'Username:string' \
|
||||
'Password:string' \
|
||||
'server_address:host' \
|
||||
'server_port:port' \
|
||||
'client_port:port' \
|
||||
'log_level:uinteger:0'
|
||||
}
|
||||
|
||||
service_running() {
|
||||
ubus wait_for tr069
|
||||
return $?;
|
||||
}
|
||||
|
||||
start_service() {
|
||||
local enable server_address
|
||||
|
||||
config_load stun
|
||||
validate_stun_section || {
|
||||
log "Validation failed for stun section";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
if [ "$enable" -eq 0 ]; then
|
||||
exit 0;
|
||||
fi
|
||||
|
||||
if [ -z "${server_address}" ]; then
|
||||
log "Stun server address not defined or invalid"
|
||||
exit 0;
|
||||
fi
|
||||
|
||||
procd_open_instance stun
|
||||
procd_set_param command "$PROG"
|
||||
procd_set_param respawn "3" "7" "0"
|
||||
procd_close_instance
|
||||
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
service_triggers()
|
||||
{
|
||||
procd_add_reload_trigger stun
|
||||
}
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
#!/bin/sh /etc/rc.common
|
||||
# STUN client software
|
||||
# Copyright (C) 2020 iopsys Software Solutions AB
|
||||
# Author: Omar Kallel <omar.kallel@pivasoftware.com>
|
||||
|
||||
START=90
|
||||
|
||||
USE_PROCD=1
|
||||
PROG="/usr/sbin/stund"
|
||||
|
||||
start_service() {
|
||||
local enable=`uci -q get stun.stun.enable`
|
||||
if [ "$enable" == "1" ]; then
|
||||
local server=`uci -q get stun.stun.server_address`
|
||||
[ "$server" = "" ] && exit 0
|
||||
procd_open_instance
|
||||
procd_set_param command "$PROG"
|
||||
procd_set_param respawn "3" "7" "0"
|
||||
procd_close_instance
|
||||
fi
|
||||
}
|
||||
|
||||
boot() {
|
||||
start
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
logger -p crit -t "stun" "reloading service()"
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
service_triggers()
|
||||
{
|
||||
procd_add_reload_trigger stun
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue