summaryrefslogtreecommitdiff
path: root/openwrt/package/openntpd/ipkg
diff options
context:
space:
mode:
authorWaldemar Brodkorb <mail@waldemar-brodkorb.de>2005-03-27 21:36:57 +0000
committerWaldemar Brodkorb <mail@waldemar-brodkorb.de>2005-03-27 21:36:57 +0000
commit8b86d7c65fd1f8ed38319c5fa3d88e5b1f0caf84 (patch)
tree6a0028caf7a1e3a38016b86f37c369cddea48078 /openwrt/package/openntpd/ipkg
parent8c71ede5ef8310bb7932829a17778b9f68db409c (diff)
downloadmtk-20170518-8b86d7c65fd1f8ed38319c5fa3d88e5b1f0caf84.zip
mtk-20170518-8b86d7c65fd1f8ed38319c5fa3d88e5b1f0caf84.tar.gz
mtk-20170518-8b86d7c65fd1f8ed38319c5fa3d88e5b1f0caf84.tar.bz2
add static uid, but handle squashfs rootfs systems correctly
SVN-Revision: 469
Diffstat (limited to 'openwrt/package/openntpd/ipkg')
-rwxr-xr-xopenwrt/package/openntpd/ipkg/CONTROL/postinst52
1 files changed, 31 insertions, 21 deletions
diff --git a/openwrt/package/openntpd/ipkg/CONTROL/postinst b/openwrt/package/openntpd/ipkg/CONTROL/postinst
index 8881116..daa0baf 100755
--- a/openwrt/package/openntpd/ipkg/CONTROL/postinst
+++ b/openwrt/package/openntpd/ipkg/CONTROL/postinst
@@ -1,25 +1,35 @@
#!/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
+name=ntp
+id=50
+
+# do not change below
+# check if we are on real system
+if [ -z "${IPKG_INSTROOT}" ]; then
+ # create copies of passwd and group, if we use squashfs
+ rootfs=`mount |awk '/root/ { print $5 }'`
+ if [ "$rootfs" = "squashfs" ]; then
+ if [ -h /etc/group ]; then
+ rm /etc/group
+ cp /rom/etc/group /etc/group
+ fi
+ if [ -h /etc/passwd ]; then
+ rm /etc/passwd
+ cp /rom/etc/passwd /etc/passwd
+ fi
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
+
+echo ""
+if [ -z "$(grep ^\\${name}: ${IPKG_INSTROOT}/etc/group)" ]; then
+ echo "adding group $name to /etc/group"
+ echo "${name}:x:${id}:" >> ${IPKG_INSTROOT}/etc/group
+fi
+
+if [ -z "$(grep ^\\${name}: ${IPKG_INSTROOT}/etc/passwd)" ]; then
+ echo "adding user $name to /etc/passwd"
+ echo "${name}:x:${id}:${id}:${name}:/tmp/.${name}:/bin/false" >> ${IPKG_INSTROOT}/etc/passwd
+fi
+
+grep -q '^ntp[[:space:]]*123/udp' ${IPKG_INSTROOT}/etc/services 2>/dev/null
+[ $? -ne 0 ] && echo "ntp 123/udp" >>${IPKG_INSTROOT}/etc/services