mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2025-12-10 07:44:50 +01:00
This is a regression caused by the below commit. The command "killall dectmngr" tries to kill
both the service /usr/sbin/dectmngr and the init-script /etc/init.d/dectmngr. This is wrong.
The fix is to kill /usr/sbin/dectmngr only.
commit 501193da98
Author: Yalu Zhang <yalu.zhang@iopsys.eu>
Date: Tue May 11 11:15:35 2021 +0200
Rename etc/init.d/dect to etc/init.d/dectmngr
137 lines
3.6 KiB
Bash
Executable file
137 lines
3.6 KiB
Bash
Executable file
#!/bin/sh /etc/rc.common
|
|
|
|
source /lib/functions/uci-defaults.sh
|
|
|
|
START=70
|
|
STOP=12
|
|
|
|
USE_PROCD=1
|
|
PROG=/usr/sbin/dectmngr
|
|
LOG_PATH=/var/log/dectmngr
|
|
DB_PATH=/etc/dect
|
|
DCX81_UART_DT_ALIAS=/proc/device-tree/aliases/dcx81-uart
|
|
|
|
DECT_GPIO="$(gpiofind DCX81_RSTN | cut -d ' ' -f 2 2>/dev/null)"
|
|
|
|
# Ask dectmngr to exit nicely and wait for it to clean up, which is a slow process.
|
|
stop_and_wait_dectmngr() {
|
|
dect_pid=$(pidof $PROG)
|
|
[ -n "$dect_pid" ] && kill $dect_pid
|
|
|
|
pidof $PROG > /dev/null 2>&1 && sleep 2 # wait for the process to stop gracefully
|
|
while pidof $PROG > /dev/null 2>&1; do
|
|
dect_pid=$(pidof $PROG)
|
|
[ -n "$dect_pid" ] && kill -9 $dect_pid
|
|
sleep 1
|
|
done
|
|
}
|
|
|
|
has_dect() {
|
|
[ -f "$DCX81_UART_DT_ALIAS" ]
|
|
}
|
|
|
|
get_dcx81_device() {
|
|
readonly dcx81_uart_dt_node="/proc/device-tree/$(cat "$DCX81_UART_DT_ALIAS" 2>/dev/null)"
|
|
[ -e "$dcx81_uart_dt_node" ] || return 1
|
|
for tty_dt_node in /sys/class/tty/*/device/of_node; do
|
|
if [ "$tty_dt_node" -ef "$dcx81_uart_dt_node" ]; then
|
|
readonly uevent_file="${tty_dt_node%%/device/of_node}/uevent"
|
|
local device_name_line
|
|
device_name_line="$(grep '^DEVNAME=' "$uevent_file")" || return 1
|
|
readonly device="/dev/${device_name_line##DEVNAME=}"
|
|
[ -c "$device" ] || return 1
|
|
printf "%s" "$device"
|
|
return 0
|
|
fi
|
|
done
|
|
return 1
|
|
}
|
|
|
|
start_service() {
|
|
local opt_ext=
|
|
local rfpi=
|
|
local model_id=
|
|
local rxtun=
|
|
|
|
if ! has_dect; then
|
|
logger -t "$PROG" "Not starting because no DECT hardware is available."
|
|
return 0
|
|
fi
|
|
|
|
local dcx81_uart_device
|
|
if ! dcx81_uart_device="$(get_dcx81_device)"; then
|
|
logger -t "$PROG" -p daemon.warning "Could not determine DCX81 UART device. Falling back to default ttyH0."
|
|
dcx81_uart_device=/dev/ttyH0
|
|
fi
|
|
|
|
[ -n "$DECT_GPIO" ] && echo 1 > /sys/class/gpio/gpio${DECT_GPIO}/value
|
|
|
|
rfpi=$(db -q get hw.board.dect_rfpi)
|
|
[ -n "$rfpi" -a ${#rfpi} -eq 14 ] && opt_ext="$opt_ext -rfpi $rfpi"
|
|
|
|
model_id=$(db -q get hw.board.dect_model_id)
|
|
[ -n "$model_id" -a ${#model_id} -eq 8 ] || {
|
|
echo "Invalid hw.board.dect_model_id:$model_id. Set to 30.3B.06"
|
|
model_id="30.3B.06"
|
|
}
|
|
opt_ext="$opt_ext -model $model_id"
|
|
|
|
rxtun=$(db -q get hw.board.dect_rxtun)
|
|
[ -n "$rxtun" -a ${#rxtun} -eq 2 ] && opt_ext="$opt_ext -rxtun $rxtun"
|
|
|
|
config_load dect
|
|
config_get log_dect_cmbs global log_dect_cmbs syslog
|
|
|
|
procd_open_instance
|
|
|
|
# dectmngr takes expects device without /dev
|
|
readonly dcx81_uart_device_wo_dev="${dcx81_uart_device##/dev/}"
|
|
case "$log_dect_cmbs" in
|
|
none)
|
|
echo "Starting dectmngr with cmbs logging disabled"
|
|
procd_set_param command "$PROG" -comname "$dcx81_uart_device_wo_dev" $opt_ext
|
|
rm -f $LOG_PATH/*
|
|
;;
|
|
file)
|
|
echo "Starting dectmngr with cmbs logging enabled to file"
|
|
procd_set_param command "$PROG" -comname "$dcx81_uart_device_wo_dev" -log $LOG_PATH/dect-cmbs.log $opt_ext
|
|
;;
|
|
*)
|
|
echo "Starting dectmngr with cmbs logging enabled to syslog"
|
|
procd_set_param command "$PROG" -comname "$dcx81_uart_device_wo_dev" -syslog $opt_ext
|
|
rm -f $LOG_PATH/*
|
|
;;
|
|
esac
|
|
|
|
procd_set_param respawn 6 2 3
|
|
procd_set_param term_timeout 20
|
|
procd_set_param triggers asterisk
|
|
procd_close_instance
|
|
}
|
|
|
|
stop_service() {
|
|
has_dect || return 0
|
|
|
|
[ -n "$DECT_GPIO" ] && echo 0 > /sys/class/gpio/gpio${DECT_GPIO}/value
|
|
stop_and_wait_dectmngr
|
|
}
|
|
|
|
reload_service() {
|
|
ubus call dect reload
|
|
}
|
|
|
|
service_triggers() {
|
|
procd_add_config_trigger "config.change" "asterisk" /etc/init.d/dectmngr restart
|
|
procd_add_config_trigger "config.change" "dect" /etc/init.d/dectmngr reload
|
|
}
|
|
|
|
boot() {
|
|
[ -n "$DECT_GPIO" ] && {
|
|
echo ${DECT_GPIO} > /sys/class/gpio/export
|
|
echo out > /sys/class/gpio/gpio${DECT_GPIO}/direction
|
|
}
|
|
|
|
[ ! -d $LOG_PATH ] && mkdir -p $LOG_PATH
|
|
[ ! -d $DB_PATH ] && mkdir -p $DB_PATH
|
|
start
|
|
}
|