+default_prerm() {
+ local name
+ name=$(echo $(basename $1) | cut -d. -f1)
+ [ -f /usr/lib/opkg/info/${name}.prerm-pkg ] && . /usr/lib/opkg/info/${name}.prerm-pkg
+ for i in `cat /usr/lib/opkg/info/${name}.list | grep "^/etc/init.d/"`; do
+ $i disable
+ $i stop
+ done
+}
+
+default_postinst() {
+ local name rusers
+ name=$(echo $(basename $1) | cut -d. -f1)
+ [ -f ${IPKG_INSTROOT}/usr/lib/opkg/info/${name}.postinst-pkg ] && . ${IPKG_INSTROOT}/usr/lib/opkg/info/${name}.postinst-pkg
+ rusers=$(grep "Require-User:" ${IPKG_INSTROOT}/usr/lib/opkg/info/${name}.control)
+ [ -n "$rusers" ] && {
+ local user group
+ for a in $(echo $rusers | sed "s/Require-User://g"); do
+ user=""
+ group=""
+ for b in $(echo $a | sed "s/:/ /g"); do
+ [ -z "$user" ] && {
+ user=$b
+ continue
+ }
+ [ -z "$group" ] && {
+ group=$b
+ group_add_next $b
+ gid=$?
+ user_exists $user || user_add $user "" $gid
+ continue
+ }
+ group_add_next $b
+ group_add_user $b $user
+ done
+ done
+ }
+ [ -n "${IPKG_INSTROOT}" -o "$PKG_UPGRADE" = "1" ] || for i in `cat /usr/lib/opkg/info/${name}.list | grep "^/etc/init.d/"`; do
+ $i enable
+ $i start
+ done
+ return 0
+}
+