r16:
[ntp-cn.git] / debian / postinst
1 #!/bin/sh
2
3 [ "$1" = "configure" ] || exit 0
4 [ "$DEBIAN_SCRIPT_DEBUG" ] && set -vx
5
6 konfiguriraj() {
7   if [ -f /etc/ntp.conf ]; then
8     cp -p /etc/ntp.conf /etc/ntp.conf.dpkg-old
9   fi
10
11   if [ -f /etc/default/ntp-servers ]; then
12     cp -p /etc/default/ntp-servers /etc/default/ntp-servers.dpkg-old
13   fi
14
15   cp /usr/share/doc/ntp-cn/ntp.conf.tmpl /etc
16
17   cat > /etc/default/ntp-servers <<EOF
18 NTPSERVERS="zg1.ntp.carnet.hr ri.ntp.carnet.hr zg2.ntp.carnet.hr 127.127.1.0"
19 EOF
20 }
21
22 if [ -f /usr/share/doc/ntp-cn/ntp.conf.tmpl -a -f /etc/ntp.conf ]; then
23   if ! cmp -s /usr/share/doc/ntp-cn/ntp.conf.tmpl /etc/ntp.conf; then
24     konfiguriraj
25   fi
26 fi
27
28 # restartaj sve
29 if [ -x /etc/init.d/ntp ]; then
30   if [ -x /usr/sbin/invoke-rc.d ]; then
31     invoke-rc.d ntp stop
32     for i in 1 2 3 4 5 6 7 8 9 0; do
33       pgrep -u root -f /usr/sbin/ntpd >/dev/null && sleep 1 || break
34     done
35     invoke-rc.d ntp start
36   else
37     /etc/init.d/ntp stop
38     for i in 1 2 3 4 5 6 7 8 9 0; do
39       pgrep -u root -f /usr/sbin/ntpd >/dev/null && sleep 1 || break
40     done
41     /etc/init.d/ntp start
42   fi
43 fi