#!/bin/sh DAEMON=inadyn-mt . /etc/init.d/modlibrc ivalueof () { eval "echo -n \$${1}${2}" } escvalue () { echo "$@" | sed 's,\([\ ]\),\\\1,g' } configure () { local ii value echo background echo verbose $INADYN_MT_VERBOSE [ -x /etc/init.d/rc.syslogd ] && running=$(/etc/init.d/rc.syslogd status) if [ "$running" = "running" ]; then echo syslog else echo log_file /var/log/${DAEMON}.log fi echo pid_file /var/run/${DAEMON}.pid ii=0 # inadyn-mt -> dyndns.h can maintain maximal 5 servers while [ 5 -gt $ii ]; do if [ yes = "$(ivalueof INADYN_MT_ACTIVE $ii)" ]; then value=$(ivalueof INADYN_MT_URL $ii | sed 's,\([^/]*\)\(.*\),\1 \2,') case $(ivalueof INADYN_MT_SERVICE $ii) in dyndns.org) echo -e '\ndyndns_system dyndns@dyndns.org' ;; dyndns.org-statdns) echo -e '\ndyndns_system statdns@dyndns.org' ;; dyndns.org-custom) echo -e '\ndyndns_system custom@dyndns.org' ;; afraid.org) echo -e '\ndyndns_system default@freedns.afraid.org' ;; zoneedit.com) echo -e '\ndyndns_system default@zoneedit.com' ;; no-ip.com) echo -e '\ndyndns_system default@no-ip.com' ;; userdefined) [ -z "$value" ] && continue echo -e '\ndyndns_system custom@http_svr_basic_auth' ;; esac if [ -n "$value" ]; then echo dyndns_server_name $(echo $value | cut -d\ -f1) echo dyndns_server_url $(echo $value | cut -d\ -f2) fi for value in $(ivalueof INADYN_MT_ALIAS $ii); do echo "alias $value" done value=$(ivalueof INADYN_MT_USER $ii) [ -n "$value" ] && echo "username $value" value=$(ivalueof INADYN_MT_PASS $ii) [ -n "$value" ] && echo "password $(escvalue $value)" value=$(ivalueof INADYN_MT_OPTIONS $ii) [ -n "$value" ] && echo "$value" fi let ii++ done } config() { configure >/mod/etc/$DAEMON.conf if [ 5 -gt $(cat /mod/etc/$DAEMON.conf | wc -l) ]; then echo -n 'not configured, failed.' exit 1 fi } start() { modlib_startdaemon $DAEMON --input_file /mod/etc/$DAEMON.conf 2>/dev/null } case $1 in ""|load) modreg cgi $DAEMON 'Inadyn-mt' modreg daemon $DAEMON modlib_start $INADYN_MT_ENABLED ;; unload) modunreg daemon $DAEMON modunreg cgi $DAEMON modlib_stop ;; start) modlib_start ;; stop) modlib_stop ;; restart) modlib_restart ;; status) modlib_status ;; *) echo "Usage: $0 [load|unload|start|stop|restart|status]" 1>&2 exit 1 ;; esac exit 0