fixup openntpd package. ntpd now starts as user ntp and CONTROL/postinst can be execu...
authorWaldemar Brodkorb <mail@waldemar-brodkorb.de>
Wed, 23 Mar 2005 20:19:42 +0000 (20:19 +0000)
committerWaldemar Brodkorb <mail@waldemar-brodkorb.de>
Wed, 23 Mar 2005 20:19:42 +0000 (20:19 +0000)
SVN-Revision: 435

openwrt/package/openntpd/Makefile
openwrt/package/openntpd/files/ntpd.conf [deleted file]
openwrt/package/openntpd/ipkg/CONTROL/postinst [new file with mode: 0755]
openwrt/package/openntpd/ipkg/etc/init.d/S49ntpd [new file with mode: 0755]
openwrt/package/openntpd/ipkg/etc/ntpd.conf [new file with mode: 0644]
openwrt/rules.mk

index 8094e5ef7a36090035d0f770d6fc725b49546d25..3f6f950377e8d1bee7f528e7c875e2c352b1a523 100644 (file)
@@ -42,6 +42,7 @@ $(PKG_BUILD_DIR)/.configured: $(PKG_BUILD_DIR)/.unpacked
                --mandir=/usr/man \
                --infodir=/usr/info \
                --with-builtin-arc4random \
+               --with-privsep-user=ntp \
        );
        touch $(PKG_BUILD_DIR)/.configured
 
@@ -49,11 +50,10 @@ $(PKG_BUILD_DIR)/ntpd: $(PKG_BUILD_DIR)/.configured
        $(MAKE) -C $(PKG_BUILD_DIR)
 
 $(PKG_IPK): $(PKG_BUILD_DIR)/ntpd
+       mkdir -p $(PKG_IPK_DIR)/usr/sbin 
+       cp -a ./ipkg/* $(PKG_IPK_DIR)/
        $(SCRIPT_DIR)/make-ipkg-dir.sh $(PKG_IPK_DIR) $(PKG_NAME).control $(PKG_VERSION)-$(PKG_RELEASE) $(ARCH)
-       mkdir -p $(PKG_IPK_DIR){/usr/sbin,/etc/init.d} 
        cp $(PKG_BUILD_DIR)/ntpd $(PKG_IPK_DIR)/usr/sbin/
-       cp ./files/ntpd.conf $(PKG_IPK_DIR)/etc/
-       cp ./files/S49ntpd $(PKG_IPK_DIR)/etc/init.d/
        $(STRIP) $(PKG_IPK_DIR)/usr/sbin/*
        mkdir -p $(PACKAGE_DIR)
        $(IPKG_BUILD) $(PKG_IPK_DIR) $(PACKAGE_DIR)
diff --git a/openwrt/package/openntpd/files/ntpd.conf b/openwrt/package/openntpd/files/ntpd.conf
deleted file mode 100644 (file)
index 6993b8e..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-# use a random selection of 8 public stratum 2 servers
-# see http://twiki.ntp.org/bin/view/Servers/NTPPoolServers
-servers pool.ntp.org
diff --git a/openwrt/package/openntpd/ipkg/CONTROL/postinst b/openwrt/package/openntpd/ipkg/CONTROL/postinst
new file mode 100755 (executable)
index 0000000..8881116
--- /dev/null
@@ -0,0 +1,25 @@
+#!/bin/sh
+grep -q '^ntp[[:space:]]*123/udp' ${IPKG_INSTROOT}/etc/services 2>/dev/null
+[ $? -ne 0 ] && echo "ntp      123/udp" >>${IPKG_INSTROOT}/etc/services
+
+NU=ntp
+U=`grep "^$NU:" ${IPKG_INSTROOT}/etc/passwd 2>/dev/null | cut -d: -f3`
+if [ .$U = . ]; then
+       U=`cut -d: -f3 ${IPKG_INSTROOT}/etc/passwd 2>/dev/null | sort -n | tail -1`
+       [ .$U = . ] && U=49
+       U=`expr $U + 1`
+       [ $U -lt 50 ] && U=50
+       G=`grep "^$NU:" ${IPKG_INSTROOT}/etc/group 2>/dev/null | cut -d: -f3`
+       if [ .$G = . ]; then
+               G=`cut -d: -f3 ${IPKG_INSTROOT}/etc/group 2>/dev/null | sort -n | tail -1`
+               [ .$G = . ] && G=49
+               G=`expr $G + 1`
+               [ $G -lt 50 ] && G=50
+       fi
+       LINE="$NU:x:$U:$G::/tmp/.ntp:/bin/false"
+       echo "$LINE" >>${IPKG_INSTROOT}/etc/passwd
+else
+       awk -F: '{ if($1=="ntp") printf("%s:%s:%s:%s:%s:/tmp/.ntp:/bin/false\n",$1,$2,$3,$4,$5); else print $0 }' ${IPKG_INSTROOT}/etc/passwd >/tmp/$$
+       mv /tmp/$$ ${IPKG_INSTROOT}/etc/passwd
+       chmod 644 ${IPKG_INSTROOT}/etc/passwd
+fi
diff --git a/openwrt/package/openntpd/ipkg/etc/init.d/S49ntpd b/openwrt/package/openntpd/ipkg/etc/init.d/S49ntpd
new file mode 100755 (executable)
index 0000000..e528748
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+mkdir -p `grep "^ntp:" /etc/passwd | cut -d: -f6`
+/usr/sbin/ntpd -s
diff --git a/openwrt/package/openntpd/ipkg/etc/ntpd.conf b/openwrt/package/openntpd/ipkg/etc/ntpd.conf
new file mode 100644 (file)
index 0000000..6993b8e
--- /dev/null
@@ -0,0 +1,3 @@
+# use a random selection of 8 public stratum 2 servers
+# see http://twiki.ntp.org/bin/view/Servers/NTPPoolServers
+servers pool.ntp.org
index ba027d4576ac3d2cb576e9aaff3328b04e41e9c2..6e804857f1f7bf56f490f76507bc8bb4f3169fbc 100644 (file)
@@ -112,7 +112,7 @@ endif
 
 
 # invoke ipkg with configuration in $(STAGING_DIR)/etc/ipkg.conf 
-IPKG := IPKG_CONF_DIR=$(STAGING_DIR)/etc $(TARGET_DIR)/bin/ipkg -force-defaults -force-depends
+IPKG := IPKG_INSTROOT=$(TARGET_DIR) IPKG_CONF_DIR=$(STAGING_DIR)/etc $(TARGET_DIR)/bin/ipkg -force-defaults -force-depends
 IPKG_STATE_DIR := $(TARGET_DIR)/usr/lib/ipkg
 
 # invoke ipkg-build with some default options