packaging: Add module restart/install logic

- For clevo interfaces
- For tuxedo_io from tuxedo_cc_wmi
This commit is contained in:
Christoffer Sandberg 2020-12-07 16:58:05 +01:00
parent 596212e17a
commit a8230d47f6
No known key found for this signature in database
GPG key ID: BF563F71B6C7A96D
3 changed files with 91 additions and 31 deletions

View file

@ -3,8 +3,8 @@ Version: x.x.x
Section: admin
Priority: optional
Depends: dkms (>= 1.95)
Conflicts: tuxedo-keyboard-dkms (<= 2.0.0), tuxedo-wmi-dkms (<= 1.5.1), tuxedo-xp-xc-touchpad-key-fix, tuxedo-touchpad-fix (<= 1.0.8), tuxedo-xp-xc-airplane-mode-fix (<= 0.6)
Replaces: tuxedo-keyboard-dkms (<= 2.0.0), tuxedo-wmi-dkms (<= 1.5.1), tuxedo-xp-xc-touchpad-key-fix, tuxedo-touchpad-fix (<= 1.0.8), tuxedo-xp-xc-airplane-mode-fix (<= 0.6)
Conflicts: tuxedo-keyboard-dkms (<= 2.0.0), tuxedo-wmi-dkms (<= 1.5.1), tuxedo-xp-xc-touchpad-key-fix, tuxedo-touchpad-fix (<= 1.0.8), tuxedo-xp-xc-airplane-mode-fix (<= 0.6), tuxedo-cc-wmi
Replaces: tuxedo-keyboard-dkms (<= 2.0.0), tuxedo-wmi-dkms (<= 1.5.1), tuxedo-xp-xc-touchpad-key-fix, tuxedo-touchpad-fix (<= 1.0.8), tuxedo-xp-xc-airplane-mode-fix (<= 0.6), tuxedo-cc-wmi
Maintainer: TUXEDO Computers GmbH <tux@tuxedocomputers.com>
Homepage: https://www.tuxedocomputers.com
Architecture: all

View file

@ -42,8 +42,36 @@ case "$1" in
dkms_configure
# Attempt to (re-)load module immediately, fail silently if not possible at this stage
rmmod ${module} > /dev/null 2>&1 || true
modprobe ${module} > /dev/null 2>&1 || true
# 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
if $TCCD_RUNNING; then
echo "Stop tccd temporarily"
systemctl stop tccd 2>&1 || true
fi
echo "(Re)load modules if possible"
rmmod tuxedo_io > /dev/null 2>&1 || true
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
modprobe clevo_wmi > /dev/null 2>&1 || true
modprobe clevo_acpi > /dev/null 2>&1 || true
modprobe tuxedo_io > /dev/null 2>&1 || true
# 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

View file

@ -31,6 +31,7 @@ Provides: tuxedo_keyboard = %{version}-%{release}
Obsoletes: tuxedo_keyboard < %{version}-%{release}
Obsoletes: tuxedo-xp-xc-touchpad-key-fix
Obsoletes: tuxedo-touchpad-fix <= 1.0.1
Obsoletes: tuxedo-cc-wmi
Requires: dkms >= 1.95
BuildRoot: %{_tmppath}
Packager: Tomte <tux@tuxedocomputers.com>
@ -71,14 +72,45 @@ for POSTINST in /usr/lib/dkms/common.postinst /usr/share/%{module}/postinst; do
if [ -f $POSTINST ]; then
$POSTINST %{module} %{version} /usr/share/%{module}
RET=$?
rmmod %{module} > /dev/null 2>&1 || true
modprobe %{module} > /dev/null 2>&1 || true
# Attempt to (re-)load module immediately, fail silently if not possible at this stage
# 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
if $TCCD_RUNNING; then
echo "Stop tccd temporarily"
systemctl stop tccd 2>&1 || true
fi
echo "(Re)load modules if possible"
rmmod tuxedo_io > /dev/null 2>&1 || true
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
modprobe clevo_wmi > /dev/null 2>&1 || true
modprobe clevo_acpi > /dev/null 2>&1 || true
modprobe tuxedo_io > /dev/null 2>&1 || true
# 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
# Restart tccd after reload if it was running
if $TCCD_RUNNING; then
echo "Start tccd again"
systemctl start tccd 2>&1 || true
fi
exit $RET
fi
echo "WARNING: $POSTINST does not exist."