procd: convert various packages to procd style init.d scripts
[openwrt/svn-archive/archive.git] / package / utils / busybox / files / sysntpd
1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2011 OpenWrt.org
3
4 START=98
5
6 USE_PROCD=1
7 PROG=/usr/sbin/ntpd
8 SERVICE_PID_FILE=/var/run/sysntpd.pid
9
10 start_service() {
11 local peers
12 local args="-n"
13 local enable_server
14
15 config_load system
16 config_get peers ntp server
17 config_get_bool enable_server ntp enable_server 0
18
19 [ $enable_server -eq 0 -a -z "$peers" ] && return
20
21 procd_open_instance
22 procd_set_param command "$PROG" -n
23 [ $enable_server -ne 0 ] && procd_append_param command -l
24 [ -n "$peers" ] && {
25 local peer
26 for peer in $peers; do
27 procd_append_param command -p $peer
28 done
29 }
30 procd_set_param respawn
31 procd_close_instance
32 }
33
34 service_triggers()
35 {
36 procd_add_reload_trigger "system"
37 }