summaryrefslogtreecommitdiff
path: root/package/base-files/files/etc/init.d/sysntpd
blob: fefb48fb19ee510850e8c912f89249867eb8e0a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/sh /etc/rc.common
# Copyright (C) 2011 OpenWrt.org

START=98

BIN=/usr/sbin/ntpd
PID=/var/run/sysntpd.pid

start() {
	[ -x $BIN ] || exit 0

	local peers

	getpeers() {
		config_get peers "$1" server
	}

	config_load system
	config_foreach getpeers timeserver

	if [ -n "$peers" ]; then
		local peer
		local args="-n"
		for peer in $peers; do
			append args "-p $peer"
		done

		start-stop-daemon -x $BIN -m -p $PID -b -S -- $args
	fi
}

stop() {
	service_kill ${BIN##*/} $PID
	rm -f $PID
}