Ovisnost o init-system-helpers
[ntp-cn.git] / debian / postinst
index eeb7068..5acabc4 100755 (executable)
@@ -1,6 +1,9 @@
 #!/bin/sh
 
+set -e
+
 [ "$1" = "configure" ] || exit 0
+[ "$DEBIAN_SCRIPT_DEBUG" ] && set -vx
 
 konfiguriraj() {
   if [ -f /etc/ntp.conf ]; then
@@ -11,11 +14,14 @@ konfiguriraj() {
     cp -p /etc/default/ntp-servers /etc/default/ntp-servers.dpkg-old
   fi
 
-  cp /usr/share/doc/ntp-cn/ntp.conf.tmpl /etc
+  cp /usr/share/doc/ntp-cn/ntp.conf.tmpl /etc/ntp.conf
+
+  # Load CARNet Tools
+  . /usr/share/carnet-tools/functions.sh
 
-  cat > /etc/default/ntp-servers <<EOF
-NTPSERVERS="zg1.ntp.carnet.hr ri.ntp.carnet.hr zg2.ntp.carnet.hr 127.127.1.0"
-EOF
+  cp_check_and_sed 'NTPSERVERS' \
+                   "s/^.*NTPSERVERS.*/NTPSERVERS=\"zg1.ntp.carnet.hr ri.ntp.carnet.hr zg2.ntp.carnet.hr st.ntp.carnet.hr os.ntp.carnet.hr 127.127.1.0\"/g" \
+                   /etc/default/ntpdate || true
 }
 
 if [ -f /usr/share/doc/ntp-cn/ntp.conf.tmpl -a -f /etc/ntp.conf ]; then
@@ -25,18 +31,6 @@ if [ -f /usr/share/doc/ntp-cn/ntp.conf.tmpl -a -f /etc/ntp.conf ]; then
 fi
 
 # restartaj sve
-if [ -x /etc/init.d/ntp ]; then
-  if [ -x /usr/sbin/invoke-rc.d ]; then
-    invoke-rc.d ntp stop
-    for i in 1 2 3 4 5 6 7 8 9 0; do
-      pgrep -u root -f /usr/sbin/ntpd >/dev/null && sleep 1 || break
-    done
-    invoke-rc.d ntp start
-  else
-    /etc/init.d/ntp stop
-    for i in 1 2 3 4 5 6 7 8 9 0; do
-      pgrep -u root -f /usr/sbin/ntpd >/dev/null && sleep 1 || break
-    done
-    /etc/init.d/ntp start
-  fi
-fi
+invoke-rc.d ntp restart
+
+#DEBHELPER#