From 4bd42d478ca9a64ea2cefb65f2f6c037ae79a5a2 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 27 May 2022 23:44:25 +0800 Subject: [PATCH] update 2022-05-27 23:44:25 --- ddnsto/files/ddnsto-monitor.sh | 44 ++++++++++++++++++++++++++++++++++ ddnsto/files/ddnsto.init | 2 +- 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100755 ddnsto/files/ddnsto-monitor.sh diff --git a/ddnsto/files/ddnsto-monitor.sh b/ddnsto/files/ddnsto-monitor.sh new file mode 100755 index 000000000..399ae69d4 --- /dev/null +++ b/ddnsto/files/ddnsto-monitor.sh @@ -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 + diff --git a/ddnsto/files/ddnsto.init b/ddnsto/files/ddnsto.init index 34ba27c1f..ed84174f6 100755 --- a/ddnsto/files/ddnsto.init +++ b/ddnsto/files/ddnsto.init @@ -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