# format to show date information in log and luci-app-ddns default ISO 8601 format
ddns_dateformat=$(uci -q get ddns.global.ddns_dateformat) || ddns_dateformat="%F %R"
-DATE_PROG="date +'$ddns_dateformat'"
+
+# Print the current date using the configured format.
+# Do not turn this into a command string that is run through "eval": the format
+# is read from UCI and a single quote inside it would start a new shell word.
+date_prog() { date +"$ddns_dateformat"; }
# USE_CURL if GNU Wget and cURL installed normally Wget is used by do_transfer()
# to change this use global option use_curl '1'
case $1 in
0) if [ $__ERR -eq 0 ]; then
- write_log 5 "PID '$$' exit normal at $(eval $DATE_PROG)${N}"
+ write_log 5 "PID '$$' exit normal at $(date_prog)${N}"
else
- write_log 4 "PID '$$' exit WITH ERROR '$__ERR' at $(eval $DATE_PROG)${N}"
+ write_log 4 "PID '$$' exit WITH ERROR '$__ERR' at $(date_prog)${N}"
fi ;;
- 1) write_log 6 "PID '$$' received 'SIGHUP' at $(eval $DATE_PROG)"
+ 1) write_log 6 "PID '$$' received 'SIGHUP' at $(date_prog)"
# reload config via starting the script again
/usr/lib/ddns/dynamic_dns_updater.sh -v "0" -S "$__SECTIONID" -- start || true
exit 0 ;; # and leave this one
- 2) write_log 5 "PID '$$' terminated by 'SIGINT' at $(eval $DATE_PROG)${N}";;
- 3) write_log 5 "PID '$$' terminated by 'SIGQUIT' at $(eval $DATE_PROG)${N}";;
- 15) write_log 5 "PID '$$' terminated by 'SIGTERM' at $(eval $DATE_PROG)${N}";;
+ 2) write_log 5 "PID '$$' terminated by 'SIGINT' at $(date_prog)${N}";;
+ 3) write_log 5 "PID '$$' terminated by 'SIGQUIT' at $(date_prog)${N}";;
+ 15) write_log 5 "PID '$$' terminated by 'SIGTERM' at $(date_prog)${N}";;
*) write_log 13 "Unhandled signal '$1' in 'trap_handler()'";;
esac
[ $VERBOSE -le 1 ] && VERBOSE=2 # force console out and logfile output
[ -f $LOGFILE ] && rm -f $LOGFILE # clear logfile before first entry
write_log 7 "************ ************** ************** **************"
- write_log 5 "PID '$$' started at $(eval $DATE_PROG)"
+ write_log 5 "PID '$$' started at $(date_prog)"
write_log 7 "ddns version : $VERSION"
write_log 7 "uci configuration:${N}$(uci -q show ddns | grep '=service' | sort)"
write_log 14 "Service section '$SECTION_ID' not defined"
}
write_log 7 "************ ************** ************** **************"
-write_log 5 "PID '$$' started at $(eval $DATE_PROG)"
+write_log 5 "PID '$$' started at $(date_prog)"
write_log 7 "ddns version : $VERSION"
write_log 7 "uci configuration:${N}$(uci -q show ddns.$SECTION_ID | sort)"
# write_log 7 "ddns version : $(opkg list-installed ddns-scripts | cut -d ' ' -f 3)"
write_log 7 "last update: never"
else
EPOCH_TIME=$(( $(date +%s) - $CURR_TIME + $LAST_TIME ))
- EPOCH_TIME="date -d @$EPOCH_TIME +'$ddns_dateformat'"
- write_log 7 "last update: $(eval $EPOCH_TIME)"
+ write_log 7 "last update: $(date -d @$EPOCH_TIME +"$ddns_dateformat")"
fi
# verify Proxy server and set environment
[ $use_ipv6 -eq 1 ] && expand_ipv6 "$REGISTERED_IP" REGISTERED_IP
# loop endlessly, checking ip every check_interval and forcing an updating once every force_interval
-write_log 6 "Starting main loop at $(eval $DATE_PROG)"
+write_log 6 "Starting main loop at $(date_prog)"
while : ; do
get_current_ip CURRENT_IP # read current IP
[ $FORCE_SECONDS -eq 0 ] && write_log 6 "Configured to run once"
[ $VERBOSE -gt 1 -o $FORCE_SECONDS -eq 0 ] && exit 0
- write_log 6 "Rerun IP check at $(eval $DATE_PROG)"
+ write_log 6 "Rerun IP check at $(date_prog)"
done
# we should never come here there must be a programming error
write_log 12 "Error in 'dynamic_dns_updater.sh - program coding error"