|
From: <abe...@us...> - 2016-11-29 14:54:46
|
Revision: 7997
http://sourceforge.net/p/astlinux/code/7997
Author: abelbeck
Date: 2016-11-29 14:54:44 +0000 (Tue, 29 Nov 2016)
Log Message:
-----------
ntp, ntpd: workaround restart lockup, start ntpd with 'ntp' privileges at boot, then restart as 'root'
Modified Paths:
--------------
branches/1.0/package/ntp/ntpd.init
Modified: branches/1.0/package/ntp/ntpd.init
===================================================================
--- branches/1.0/package/ntp/ntpd.init 2016-11-28 22:35:55 UTC (rev 7996)
+++ branches/1.0/package/ntp/ntpd.init 2016-11-29 14:54:44 UTC (rev 7997)
@@ -4,14 +4,18 @@
PIDFILE="/var/run/ntpd.pid"
+DATA_DIR="/var/lib/ntp"
+
+NTPD_STARTED="$DATA_DIR/ntpd_started"
+
init () {
# So sntp doesn't complain
touch /var/db/ntp-kod
- if [ ! -d /var/lib/ntp ]; then
- mkdir -m 0700 -p /var/lib/ntp
- chown ntp:ntp /var/lib/ntp
+ if [ ! -d $DATA_DIR ]; then
+ mkdir -m 0700 -p $DATA_DIR
+ chown ntp:ntp $DATA_DIR
fi
if [ -f /mnt/kd/ntpd.conf ]; then
@@ -22,7 +26,7 @@
fi
echo "# Autogenerated. Do not edit.
-driftfile /var/lib/ntp/ntpd.drift
+driftfile $DATA_DIR/ntpd.drift
restrict default noquery nopeer notrap nomodify
restrict 127.0.0.1" > /tmp/etc/ntpd.conf
@@ -56,7 +60,7 @@
}
start () {
- local NTPAF="" first
+ local NTPAF="" UG first driftfile
if [ -f /etc/ntpd.conf ]; then
@@ -74,8 +78,21 @@
hwclock -wu --noadjfile 2>/dev/null
fi
sleep 1
+
+ # workaround restart lockup, start ntpd with 'ntp' privileges at boot, then restart as 'root'
+ if [ -f $NTPD_STARTED ]; then
+ UG=""
+ else
+ UG="ntp:ntp"
+ driftfile="$(awk '/^driftfile / { print $2; nextfile; }' /etc/ntpd.conf)"
+ if [ -n "$driftfile" ] && [ -f "$driftfile" ]; then
+ chown $UG "$driftfile"
+ fi
+ fi
# Maintain the clock (small changes)
- ntpd $NTPAF -p $PIDFILE -u ntp:ntp -g -c /etc/ntpd.conf
+ ntpd $NTPAF -p $PIDFILE${UG:+ -u $UG} -g -c /etc/ntpd.conf
+
+ touch $NTPD_STARTED
elif ( set -o noclobber; echo "$$" > /var/lock/ntpd-delayed.lock ) 2>/dev/null; then
echo "ntpd: server unreachable, will automatically retry in 2 minutes"
(
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|