2020-03-17 16:47:45 +01:00
|
|
|
#!/bin/sh
|
|
|
|
# Copyright (c) 2020 TUXEDO Computers GmbH
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
module=module-name
|
|
|
|
version=x.x.x
|
|
|
|
|
|
|
|
|
|
|
|
NAME=${module}
|
|
|
|
PACKAGE_NAME=${NAME}
|
|
|
|
|
|
|
|
# From dkms standard postinst
|
|
|
|
# Copyright (C) 2002-2005 Flavio Stanchina
|
|
|
|
# Copyright (C) 2005-2006 Aric Cyr
|
|
|
|
# Copyright (C) 2007 Mario Limonciello
|
|
|
|
# Copyright (C) 2009 Alberto Milone
|
|
|
|
DEB_NAME=$(echo $PACKAGE_NAME | sed 's,_,-,')
|
|
|
|
CVERSION=`dpkg-query -W -f='${Version}' $DEB_NAME | awk -F "-" '{print $1}' | cut -d\: -f2`
|
|
|
|
ARCH=`dpkg --print-architecture`
|
|
|
|
|
|
|
|
dkms_configure () {
|
2020-12-07 16:58:05 +01:00
|
|
|
for POSTINST in /usr/lib/dkms/common.postinst "/usr/share/$PACKAGE_NAME/postinst"; do
|
|
|
|
if [ -f "$POSTINST" ]; then
|
|
|
|
"$POSTINST" "$NAME" "$CVERSION" "/usr/share/$PACKAGE_NAME" "$ARCH" "$2"
|
|
|
|
return $?
|
|
|
|
fi
|
|
|
|
echo "WARNING: $POSTINST does not exist." >&2
|
|
|
|
done
|
|
|
|
echo "ERROR: DKMS version is too old and $PACKAGE_NAME was not" >&2
|
|
|
|
echo "built with legacy DKMS support." >&2
|
|
|
|
echo "You must either rebuild $PACKAGE_NAME with legacy postinst" >&2
|
|
|
|
echo "support or upgrade DKMS to a more current version." >&2
|
|
|
|
return 1
|
2020-03-17 16:47:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# End dkms standard postinst
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
configure)
|
2020-12-07 16:58:05 +01:00
|
|
|
# Run standard dkms build/install for all kernels with headers installed
|
2020-03-17 16:47:45 +01:00
|
|
|
dkms_configure
|
|
|
|
|
2020-12-07 16:58:05 +01:00
|
|
|
# Attempt to (re-)load module immediately, fail silently if not possible at this stage
|
2020-04-14 13:25:02 +02:00
|
|
|
|
2020-12-07 16:58:05 +01:00
|
|
|
# Also stop tccd service if running before
|
|
|
|
echo "Check tccd running status"
|
|
|
|
if systemctl is-active --quiet tccd.service; then
|
|
|
|
TCCD_RUNNING=true
|
|
|
|
else
|
|
|
|
TCCD_RUNNING=false
|
|
|
|
fi
|
2020-04-14 13:25:02 +02:00
|
|
|
|
2020-12-07 16:58:05 +01:00
|
|
|
if $TCCD_RUNNING; then
|
|
|
|
echo "Stop tccd temporarily"
|
|
|
|
systemctl stop tccd 2>&1 || true
|
|
|
|
fi
|
2020-03-17 16:47:45 +01:00
|
|
|
|
2020-12-07 16:58:05 +01:00
|
|
|
echo "(Re)load modules if possible"
|
|
|
|
rmmod tuxedo_io > /dev/null 2>&1 || true
|
2021-09-13 23:58:08 +02:00
|
|
|
rmmod uniwill_wmi > /dev/null 2>&1 || true
|
2020-12-07 16:58:05 +01:00
|
|
|
rmmod clevo_wmi > /dev/null 2>&1 || true
|
|
|
|
rmmod clevo_acpi > /dev/null 2>&1 || true
|
|
|
|
rmmod tuxedo_keyboard > /dev/null 2>&1 || true
|
|
|
|
|
|
|
|
modprobe tuxedo_keyboard > /dev/null 2>&1 || true
|
2021-09-13 23:58:08 +02:00
|
|
|
modprobe uniwill_wmi > /dev/null 2>&1 || true
|
2020-12-07 16:58:05 +01:00
|
|
|
modprobe clevo_wmi > /dev/null 2>&1 || true
|
|
|
|
modprobe clevo_acpi > /dev/null 2>&1 || true
|
|
|
|
modprobe tuxedo_io > /dev/null 2>&1 || true
|
2020-03-17 16:47:45 +01:00
|
|
|
|
2020-12-07 16:58:05 +01:00
|
|
|
# Restart tccd after reload if it was running
|
|
|
|
if $TCCD_RUNNING; then
|
|
|
|
echo "Start tccd again"
|
|
|
|
systemctl start tccd 2>&1 || true
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Install default config if none exist already
|
|
|
|
if [ ! -f "/etc/modprobe.d/tuxedo_keyboard.conf" ]; then
|
|
|
|
cp -f /usr/share/tuxedo-keyboard/tuxedo_keyboard.conf /etc/modprobe.d/tuxedo_keyboard.conf
|
|
|
|
fi
|
|
|
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
abort-upgrade|abort-remove|abort-deconfigure)
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
echo "postinst called with unknown argument \`$1'" >&2
|
|
|
|
exit 1
|
|
|
|
;;
|
2020-03-17 16:47:45 +01:00
|
|
|
esac
|
|
|
|
|
|
|
|
exit 0
|