diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-set-time.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-set-time.sh index caa7a91..bc3a166 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-set-time.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-set-time.sh @@ -15,6 +15,7 @@ help=$(cat </dev/null 2>&1; then + if hwclock --systohc >/dev/null 2>&1; then + rtc="New time successfully saved to RTC.\n" + else + rtc="Unable to communicate with RTC module. An RTC module can save system time between reboots/power outages.\n" + fi + echo "System time updated to:\n$(date)\n\n${rtc}Time & date are also set automatically from internet." + return 0 + else + echo "Failed to set system time." + return 1 + fi +} + + +while getopts ":t:T:h" opt; do case ${opt} in t) # Option -t (timezone) set_timezone "$OPTARG" ;; + T) # Option -t (timestamp) + set_timestamp "$OPTARG" + ;; h) # Option -h (help) echo -e "$help" ;; @@ -79,15 +99,8 @@ if [ $arg_count -eq 0 ]; then # if the script was launched with no arguments, th if [ $? -eq 1 ]; then #if cancel/no exit 1 fi - if date -s "$DATE $TIME"; then # set time - if hwclock --systohc; then - rtc="New time successfully saved to RTC." - else - rtc="Unable to communicate with RTC module. An RTC module can save system time between reboots/power outages." - fi - log_message "System time updated to:\n$(date)\n\n$rtc\nTime & date are also set automatically from internet." - else - log_message "Failed to set system time." - exit 1 - fi + + log_message "$(set_timestamp $(date -d "$DATE $TIME" +%s))" + exit $? #exit status matches set_timestamp exit status + fi \ No newline at end of file