#!/bin/sh DAEMON=openntpd . /etc/init.d/modlibrc start() { modlib_adduser ntp -G users -D -S -g "NTP daemon" # Setting permissions chown root /mod/home/ntp -R chmod 0700 /mod/home/ntp -R ( if [ -x "/tmp/flash/${DAEMON}_conf" ]; then /tmp/flash/${DAEMON}_conf else /mod/etc/default.$DAEMON/${DAEMON}_conf fi if [ -r "/tmp/flash/${DAEMON}.extra" ]; then cat /tmp/flash/${DAEMON}.extra fi ) > /mod/etc/$DAEMON.conf echo 'Starting ntp server...' if [ "$OPENNTPD_MULTID" = "no" ]; then echo ' * Stopping multid ntp client...' multid -t > /dev/null 2>&1 fi if [ ! -e "/var/db" ]; then mkdir -p /var/db fi ntpd -s -f /mod/etc/ntpd.conf exitval=$? if [ "$exitval" -eq 0 ]; then echo 'done.' else echo 'failed.' exit $exitval fi } stop () { echo -n 'Stopping ntp server...' kill -USR1 $(pidof -s ntpd) > /dev/null 2>&1 exitval=$? rm -f /mod/etc/$DAEMON.conf if [ "$exitval" -eq 0 ]; then echo 'done.' else echo 'failed.' exit $exitval fi } case "$1" in ""|load) modreg cgi 'openntpd' 'Openntpd' if [ "$OPENNTPD_ENABLED" != "yes" ]; then echo "$DAEMON is disabled" 1>&2 exit 1; fi start ;; unload) stop modunreg cgi 'openntpd' ;; start) start ;; stop) stop ;; restart) stop sleep 1 start ;; status) if [ -z "$(pidof ntpd)" ]; then echo 'stopped' else echo 'running' fi ;; *) echo "Usage: $0 [load|unload|start|stop|restart|status]" 1>&2 exit 1 ;; esac exit 0