summaryrefslogtreecommitdiff
path: root/package/openntpd/ipkg/CONTROL/postinst
blob: 8881116c0d8bc622b7271e134f2c2e37ac1d17d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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