mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-02-14 11:31:51 +00:00
Add an init script for mptcpd
This commit is contained in:
parent
ce845a6cd3
commit
65034c126c
2 changed files with 72 additions and 0 deletions
|
@ -61,6 +61,7 @@ define Package/$(PKG_NAME)/install
|
|||
$(CP) $(PKG_INSTALL_DIR)/usr/lib/mptcpd/* $(1)/usr/lib/mptcpd/
|
||||
$(INSTALL_DIR) $(1)/etc/mptcpd
|
||||
$(INSTALL_DATA) $(PKG_BUILD_DIR)/etc/mptcpd.conf $(1)/etc/mptcpd/mptcpd.conf
|
||||
$(CP) ./files/* $(1)/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,$(PKG_NAME)))
|
||||
|
|
71
mptcpd/files/etc/init.d/mptcpd
Executable file
71
mptcpd/files/etc/init.d/mptcpd
Executable file
|
@ -0,0 +1,71 @@
|
|||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2023 Ycarus (Yannick Chabanois) <ycarus@zugaina.org> for OpenMPTCProuter project
|
||||
|
||||
START=10
|
||||
STOP=10
|
||||
|
||||
USE_PROCD=1
|
||||
PROG_NAME=mptcpd
|
||||
PROG=/usr/bin/${PROG_NAME}
|
||||
|
||||
_log() {
|
||||
logger -p daemon.info -t ${PROG_NAME} "$@"
|
||||
}
|
||||
|
||||
_err() {
|
||||
logger -p daemon.err -t ${PROG_NAME} "$@"
|
||||
}
|
||||
|
||||
version_over_5_4() {
|
||||
MAJOR_VERSION=$(uname -r | awk -F '.' '{print $1}')
|
||||
MINOR_VERSION=$(uname -r | awk -F '.' '{print $2}')
|
||||
if [ $MAJOR_VERSION -ge 5 ] && [ $MINOR_VERSION -gt 13 ] || [ $MAJOR_VERSION -gt 5 ] ; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
validate_section() {
|
||||
uci_validate_section network globals "${1}" \
|
||||
'mptcpd_enable:string:"disabled"' \
|
||||
'mptcp_pm_type:bool:0' \
|
||||
'mptcpd_path_manager:list(string)' \
|
||||
'mptcpd_plugins:list(string)' \
|
||||
'mptcpd_addr_flags:list(string)' \
|
||||
'mptcpd_notify_flags:list(string)'
|
||||
}
|
||||
|
||||
start_service() {
|
||||
local mptcpd_enable mptcp_pm_type mptcpd_path_manager mptcpd_plugins mptcpd_addr_flags mptcpd_notify_flags
|
||||
validate_section "globals" || {
|
||||
_err "validation failed"
|
||||
return 1
|
||||
}
|
||||
|
||||
[ "${mptcp_pm_type}" = "1" ] || return 1
|
||||
[ "${mptcpd_enable}" = "enable" ] || return 1
|
||||
|
||||
[ version_over_5_4 ] || return 1
|
||||
|
||||
procd_open_instance
|
||||
|
||||
procd_set_param command ${PROG}
|
||||
[ "${mptcpd_path_manager}" ] && procd_append_param command --path-manager=${mptcpd_path_manager// /,}
|
||||
[ "${mptcpd_plugins}" ] && procd_append_param command --load-plugins=${mptcpd_plugins// /,}
|
||||
[ "${mptcpd_add_flags}" ] && procd_append_param command --addr-flags=${mptcpd_addr_flags// /,}
|
||||
[ "${mptcpd_notify_flags}" ] && procd_append_param command --notify-flags=${mptcpd_notify_flags// /,}
|
||||
|
||||
procd_set_param respawn 0 30 5
|
||||
|
||||
procd_set_param stdout 1
|
||||
procd_set_param stderr 1
|
||||
|
||||
procd_close_instance
|
||||
|
||||
}
|
||||
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger network
|
||||
}
|
Loading…
Reference in a new issue