Skip to content

Commit

Permalink
msd_lite: actually fix reload service
Browse files Browse the repository at this point in the history
It's too complex to get network zone via ifname, so switch to use
network zone directly.

Signed-off-by: Tianling Shen <[email protected]>
  • Loading branch information
1715173329 committed Jul 10, 2023
1 parent 3cb61ba commit 08835e8
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion net/msd_lite/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
include $(TOPDIR)/rules.mk

PKG_NAME:=msd_lite
PKG_RELEASE:=2
PKG_RELEASE:=3

PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/rozhuk-im/msd_lite.git
Expand Down
2 changes: 1 addition & 1 deletion net/msd_lite/files/msd_lite.config
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ config instance
list 'address' '0.0.0.0:7088'
list 'address' '[::]:7088'
# For multicast receive
option 'interface' ''
option 'network' ''

# 0 = auto detect
option 'threads' '0'
Expand Down
28 changes: 27 additions & 1 deletion net/msd_lite/files/msd_lite.init
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2022 ImmortalWrt.org

. /lib/functions/network.sh

START=99
USE_PROCD=1

Expand All @@ -10,11 +12,20 @@ PROG="/usr/bin/$NAME"
CONF="/etc/$NAME/$NAME.conf.sample"
CONFDIR="/var/run/$NAME"

add_interface_tiggers() {
local enabled network
config_get_bool enabled "$1" "enabled" "1"
config_get network "$1" "network"

[ "$enabled" -eq "0" -o -z "$network" ] || procd_add_reload_interface_trigger "$network"
}

validate_msd_lite_section() {
uci_load_validate "$NAME" "instance" "$1" "$2" \
'enabled:bool:0' \
'address:string' \
'interface:string' \
'network:string' \
'threads:uinteger:0' \
'bind_to_cpu:bool:0' \
'drop_slow_clients:bool:0' \
Expand All @@ -27,10 +38,23 @@ validate_msd_lite_section() {

start_instance() {
local section="$1"
local seconds="0"

[ "$2" -eq "0" ] || { logger -p daemon.err -t "$NAME" "$section Validation failed."; return 1; }
[ "$enabled" -eq "1" ] || return 1

if [ -n "$network" ]; then
while [ "$seconds" -le 10 ]; do
network_get_device interface "$network"
if [ -n "$interface" ]; then
break
else
let seconds+=2
sleep 2
fi
done
fi

if [ -n "$address" ]; then
local addr bindlist
for addr in $address; do
Expand Down Expand Up @@ -85,5 +109,7 @@ reload_service() {

service_triggers() {
procd_add_reload_trigger "$NAME"
procd_add_raw_trigger "interface.*.up" 3000 /etc/init.d/$NAME reload

config_load "$NAME"
config_foreach add_interface_tiggers "instance"
}

0 comments on commit 08835e8

Please sign in to comment.