#!/bin/sh # # /etc/rc.d/rc.local: Local system initialization script. # # Put any local startup commands in here. Also, if you have # anything that needs to be run at shutdown time you can # make an /etc/rc.d/rc.local_shutdown script and put those # commands in there. # test for network interface connection carrier for NIF in $(ls /sys/class/net/ | grep -v lo); do if [[ -n $(cat /sys/class/net/"${NIF}"/carrier 2>/dev/null) ]]; then # set system time from ntp server [remote] /usr/sbin/sntp -Ss 0.pool.ntp.org > /dev/null 2>&1 || \ /usr/sbin/sntp -Ss 1.pool.ntp.org > /dev/null 2>&1 # set RTC from system time [if detected] [ -h /dev/rtc ] && /sbin/hwclock -w > /dev/null 2>&1 elif [ -h /dev/rtc ]; then # set system time from RTC [if detected] /sbin/hwclock -s > /dev/null 2>&1 else # output to stderr if time sync fails echo "WARNING! : system time sync ERROR ... " 1>&2 fi done #EOF