I have rPi B+ running ArchLinux with kernel
Linux comp001 3.18.6-2-ARCH #1 PREEMPT Sun Feb 8 09:43:43 MST 2015 armv6l GNU/Linux with Real Time Clock hardware RTC Pi. However, I would like to check if there is internet connection at boot time with running ntp client. If ntp client connects to ntp server and fetches clock, I do now want to sync clock with hardware. I want to use hw clock only when internet connection (ntp client check return code) is offline. I've built a service, which runs ok, but I do not know how to check if ntp client was launched without any problems. How do I chechk that? Ok, I have been working on following script with corrected spaces and still does not work:
#!/bin/sh if [ ?('modprobe -v rtc_ds1307') = 0 ]; then # rtc is connected and working, use it echo "RTC Hardware connected, getting time" systemctl disable ntpd.service systemctl stop ntpd.service echo "ds1307 0x68" > /sys/class/i2c-adapter/i2c-1/new_device hwclock -s else # rtc is offline / not connected, get time via ntp echo "RTC Hardware disconnected/battery dead/offline, use NTP" systemctl enable ntpd.service systemctl start ntpd.service fi
Why does exeuction of script fails in first 3rd line with:
./script_rtc.sh: line 3: syntax error near unexpected token `'modprobe -v rtc_ds1307'' ./script_rtc.sh: line 3: `if [?('modprobe -v rtc_ds1307')=0]; then'