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 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
|
#! /bin/sh
# postinst script for plex86-kernel
#
# see: dh_installdeb(1)
set -e
# summary of how this script can be called:
# * <postinst> `configure' <most-recently-configured-version>
# * <old-postinst> `abort-upgrade' <new version>
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
# <new-version>
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
# <failed-install-package> <version> `removing'
# <conflicting-package> <version>
# for details, see /usr/share/doc/packaging-manual/
#
# quoting from the policy:
# Any necessary prompting should almost always be confined to the
# post-installation script, and should be protected with a conditional
# so that unnecessary prompting doesn't happen if a package's
# installation fails and the `postinst' is called with `abort-upgrade',
# `abort-remove' or `abort-deconfigure'.
# Load the debconf libs
. /usr/share/debconf/confmodule
case "$1" in
configure)
# Create the Plex86 group
if ! grep -q plex86 /etc/group; then adduser --group plex86; fi
# Fill it with users
db_get plex86-kernel/group/users
for i in $RET; do
if ! grep plex86 /etc/group | grep -q $i;
then adduser $i plex86; fi;
done
# Check if the module is already loaded
if grep -q plex86 /proc/devices ; then /sbin/rmmod plex86 ; fi
# Remove any stale device nodes
# (extend for any minor devices created in the future)
#rm -f /dev/plex86
# Load up the module with insmod
kernel=`uname -s`
version=`uname -r`
if test -f /lib/modules/$version/misc/plex86.o
then /sbin/insmod plex86
else
echo "Error: no plex86 module found for $kernel $version"
fi
# Check if the module loaded
major=`grep plex86 /proc/devices | awk '/plex86/ {print $1;}'`
if test -z "$major"; then
echo "The kernel module failed to load!"
exit 1;
fi
# Do we have permission to create /dev/plex86?
RET="true" # RET won't be set if it already exists (see config)
db_get plex86-kernel/device/create || true
# get out of my device
if fuser -k15 /dev/plex86; then
sleep 2
# I mean it!
fuser -k9 /dev/plex86;
fi
# now we remove it. (will think of a cleaner solution)
rm -f /dev/plex86
# Create the device node and set its permissions
# (extend for any minor devices created in the future)
if [ $RET = "true" ]; then
/bin/mknod /dev/plex86 c $major 0;
chown root.plex86 /dev/plex86
chmod 660 /dev/plex86;
else
echo "Plex86 won't work untill you create its device."
echo "Use dpkg-reconfigure plex86-kernel-{version} to generate it later.";
fi
# We don't want module loaded from here (but from init.d)
/sbin/rmmod plex86
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 0
;;
esac
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
#DEBHELPER#
exit 0
|