#!/bin/sh /etc/rc.common # Copyright (C) 2006-2011 OpenWrt.org START=65 STOP=65 USE_PROCD=1 PROG=/sbin/ntpd HOTPLUG_HELPER=/usr/sbin/ntpd.hotplug-helper CONFIG_FILE=/var/run/ntpd.conf validate_ntp_section() { uci_validate_section system timeserver "${1}" \ 'server:list(host)' 'enabled:bool:1' 'enable_server:bool:0' } start_service() { mkdir -p /var/lib/ntp local server enabled enable_server peer restrict validate_ntp_section ntp || { echo "validation failed" return 1 } [ $enabled = 0 ] && return [ -z "$server" ] && return if [ $enable_server = 0 ]; then restrict="ignore" else restrict="nomodify noquery notrap" fi cat >$CONFIG_FILE <>$CONFIG_FILE done procd_open_instance procd_set_param command $PROG -g -p /var/run/ntpd.pid -c $CONFIG_FILE -n procd_set_param respawn procd_set_param file $CONFIG_FILE procd_close_instance procd_open_instance procd_set_param command $HOTPLUG_HELPER procd_close_instance } service_triggers() { procd_add_reload_trigger "system" procd_add_validation validate_ntp_section }