mirror of
https://github.com/kenzok8/small-package.git
synced 2026-02-04 13:57:45 +08:00
update 2022-05-27 23:44:25
This commit is contained in:
44
ddnsto/files/ddnsto-monitor.sh
Executable file
44
ddnsto/files/ddnsto-monitor.sh
Executable 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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user