update 2022-05-27 23:44:25

This commit is contained in:
github-actions[bot]
2022-05-27 23:44:25 +08:00
parent 82ced6716c
commit 4bd42d478c
2 changed files with 45 additions and 1 deletions

44
ddnsto/files/ddnsto-monitor.sh Executable file
View File

@@ -0,0 +1,44 @@
#!/bin/sh
DEVICE_IDX=0
LOG_LEVEL=2
while getopts u:x:l: flag
do
case "${flag}" in
u) TOKEN=${OPTARG};;
x) DEVICE_IDX=${OPTARG};;
l) LOG_LEVEL=${OPTARG};;
esac
done
if [ -z "${TOKEN}" ]; then
echo "the token is empty, get token from https://www.ddnsto.com/ "
exit 2
fi
echo "ddnsto version device_id is is:"
/usr/sbin/ddnsto -u ${TOKEN} -w
_term() {
killall ddnsto 2>/dev/null
exit
}
trap "_term;" SIGTERM
while true ; do
if ! pidof "ddnsto" > /dev/null ; then
echo "ddnsto try running"
/usr/sbin/ddnsto -u ${TOKEN} -x ${DEVICE_IDX} &
PID=$!
wait $PID
RET=$?
echo "EXIT CODE: ${RET}"
if [ "${RET}" == "100" ]; then
echo "token error, please set a correct token from https://www.ddnsto.com/ "
exit 100
fi
fi
sleep 20
done

View File

@@ -19,7 +19,7 @@ start_service() {
fi
procd_open_instance
procd_set_param command /usr/sbin/ddnsto -u "$token"
procd_set_param command /usr/sbin/ddnsto-monitor.sh -u "$token" -x 0
[ "$logger" == 1 ] && procd_set_param stderr 1
procd_set_param respawn
procd_close_instance