# Get network config
. /etc/sysconfig/network
+# default user if not overriden by config
+NTPD_USER="ntp"
+
# Get service config - may override defaults
[ -f /etc/sysconfig/chronyd ] && . /etc/sysconfig/chronyd
EOF
chronycpid=$!
- # chronyc will hang if the daemon doesn't respond, kill it after 3 s
- (sleep 3; kill $chronycpid) < /dev/null &> /dev/null &
+ # chronyc will hang if the daemon doesn't respond, kill it after 3 s
+ (sleep 3; kill $chronycpid) < /dev/null > /dev/null 2>&1 &
killerpid=$!
wait $chronycpid &> /dev/null
commandkey=$(get_key $commandkeyid)
[ -z "$commandkey" ] || return 0
- echo -n $"Generating chrony command key: "
+ show "Generating Chrony command key"; busy
commandkey=$(tr -c -d '[\041-\176]' < /dev/urandom | head -c 8)
- [ -n "$commandkey" ] && echo "$commandkeyid $commandkey" >> $keyfile &&
- success || failure
- echo
+ [ -n "$commandkey" ] && echo "$commandkeyid $commandkey" >> $keyfile && ok || fail
}
start() {
generate_commandkey
msg_starting "Chronyd NTPD"
- daemon /usr/sbin/chronyd $OPTIONS
+ daemon /usr/sbin/chronyd -u $NTPD_USER $OPTIONS
RETVAL=$?
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/chronyd
}
force-reload)
condrestart 7
;;
- online|offline|cyclelogs)
+ cyclelogs|flush-logs)
+ status chronyd >/dev/null 2>&1 || exit 7
+ chrony_command cyclelogs
+ ;;
+ online|offline)
status chronyd >/dev/null 2>&1 || exit 7
chrony_command $1
;;
status)
status chronyd
RETVAL=$?
+ if [ $RETVAL = 0 ]; then
+ chrony_command sources
+ fi
;;
*)
msg_usage "$0 {start|stop|restart|try-restart|force-reload|online|offline|cyclelogs|command|status}"