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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
#!/bin/bash -e
. /usr/share/debconf/confmodule
test $DEBIAN_SCRIPT_DEBUG && set -v -x
CONFFILE=/etc/default/libphidgets0
PREVCONF=/etc/hotplug/usb/phidgets
set_option() {
if [[ -f $CONFFILE ]] && grep -q "^$1=" $CONFFILE; then
sed -i -e "s,^[# ]*\($1\)=.*,\1=$2," $CONFFILE
else
touch $CONFFILE
echo $1=$2 >> $CONFFILE
fi
}
do_rename_group() {
[[ -n $PHIDGETS_GROUP ]] && [[ $PHIDGETS_GROUP != $RET ]]
}
case $1 in
configure|upgrade)
if [[ -n $2 ]] && dpkg --compare-versions $2 lt 0.3.1-1 \
&& [[ -f $PREVCONF.dpkg-old ]]; then
PREVGROUP=$(sed -ne 's,^chgrp \([^[:space:]]*\).*,\1,p' $PREVCONF.dpkg-old)
fi
if [[ -n $2 ]] && dpkg --compare-versions $2 lt 0.3.2-1; then
# This is ugly, but I messed up. Clean up old configuration.
for i in phidgets phidgets.in phidgets.usermap; do
[[ -f /etc/hotplug/usb/$i ]] \
&& mv /etc/hotplug/usb/$i /etc/hotplug/usb/$i.dpkg-old
done
fi
ucf --debconf-ok /usr/share/libphidgets0/default $CONFFILE
[[ -f $CONFFILE ]] && . $CONFFILE
[[ -n $PREVGROUP ]] && PHIDGETS_GROUP=$PREVGROUP
db_get libphidgets0/group || true
NEWGROUP=$RET
MEMBERS=''
if do_rename_group; then
db_get libphidgets0/grouprenamemigrate || true
if [[ $RET = true ]]; then
MEMBERS=$(getent group $PHIDGETS_GROUP | cut -d: -f4 | tr , ' ')
fi
db_get libphidgets0/grouprenamedelete || true
[[ $RET = true ]] && delgroup $PHIDGETS_GROUP || true
fi
db_get libphidgets0/groupcreate || true
if [[ $RET = true ]]; then
db_get libphidgets0/group || true
addgroup --system $NEWGROUP
for user in $MEMBERS; do
adduser $user $NEWGROUP
done
fi
set_option PHIDGETS_GROUP $NEWGROUP
db_get libphidgets0/groupdelete || true
set_option PHIDGETS_GROUPDELETE $RET
chmod 0644 $CONFFILE
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
#DEBHELPER#
exit 0
|