port lots of init scripts over to rc.common (more to come)
[packages.git] / net / ntpclient / files / ntpclient.init
1 #!/bin/sh
2 # Copyright (C) 2006 OpenWrt.org
3
4 ntp_server=$(nvram get ntp_server)
5 case "${ACTION:-ifup}" in
6         ifup)
7                 ps x | grep 'bin/[n]tpclient' >&- || {
8                         route -n 2>&- | grep '^0.0.0.0' >&- && /usr/sbin/ntpclient -c 1 -s -h ${ntp_server:-pool.ntp.org} &
9                 }
10                 ;;
11         ifdown)
12                 route -n 2>&- | grep '^0.0.0.0' >&- || killall ntpclient 2>&- >&- ;;
13 esac