Run a NTP client at startup (#301)

* Added NTP service to startup

A NTP service script will run a NTP client on a custom NTP server
in order to synchronize the camera's clock. This may be useful in
cases where the camera has to use a local NTP server rather than
the one hard coded in iCamera.

To use this, simply set your desired NTP server in the `NTP_SERVER`
option in `wz_mini.conf`.

* Kill timesync if a custom NTP server is used

When using a custom NTP server, the timesync service with its
hard-coded NTP servers should not be running.
This commit is contained in:
Leo 2022-09-27 18:50:21 -06:00 committed by GitHub
parent 10dba022a5
commit b7c27c73bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 0 deletions

View File

@ -0,0 +1,26 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides:
# Short-Description: Starts ntpd against a custom NTP server
# Description: The clock will synchronize against a user defined NTP server. Useful if the camera is on an isolated network.
### END INIT INFO
. /opt/wz_mini/wz_mini.conf
case "$1" in
start)
echo "#####$(basename "$0")#####"
if [ ! -z "$NTP_SERVER" ] ; then
# Slight delay required so that we can kill timesync from interfering
(sleep 30 && kill -9 $(pgrep -f timesync) ; /opt/wz_mini/tmp/.bin/ntpd -p "$NTP_SERVER") &
fi
;;
*)
echo "Usage: $0 {start}"
exit 1
;;
esac

View File

@ -36,6 +36,8 @@ ENABLE_NFSv4="false"
ENABLE_RTL8189FS_DRIVER="true"
ENABLE_ATBM603X_DRIVER="true"
NTP_SERVER=
##### NETWORK INTERFACE BONDING #####
BONDING_ENABLED="false"
BONDING_PRIMARY_INTERFACE="eth0"

View File

@ -36,6 +36,8 @@ ENABLE_NFSv4="false"
ENABLE_RTL8189FS_DRIVER="true"
ENABLE_ATBM603X_DRIVER="true"
NTP_SERVER=
##### NETWORK INTERFACE BONDING #####
BONDING_ENABLED="false"
BONDING_PRIMARY_INTERFACE="eth0"