-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement the script to deal with Debian's 6.1.0-(29|30) kernel problem
- Loading branch information
Showing
4 changed files
with
205 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
#!/usr/bin/bash | ||
# | ||
# This script is used to manage the kernel and the APT structure | ||
# for ASL3-related systems. It is both platform dependent (Pi vs. not Pi) | ||
# and Debian release dependent (12, 13, etc.) | ||
|
||
if [ ${UID} != 0 ]; then | ||
echo "$0 only runs as root" | ||
exit 1 | ||
fi | ||
|
||
DEBIAN_MAJ_VERSION=$(awk -F '\\.' '{print $1}' /etc/debian_version) | ||
|
||
# | ||
# Do Debian 12 fixes | ||
# | ||
function debian_12(){ | ||
|
||
# Is this a Pi? | ||
is_rpi=$(grep Raspberry /proc/cpuinfo | wc -l) | ||
|
||
# Determine the linux-image and linux-headers | ||
if [ ${is_rpi} -gt 0 ]; then | ||
KERN_META_PKG=linux-image-rpi-v8 | ||
NEEDS_BACKPORTS=0 | ||
else | ||
NEEDS_BACKPORTS=1 | ||
case $(uname -m) in | ||
x86_64) | ||
KERN_META_PKG=linux-image-amd64 | ||
;; | ||
aarch64) | ||
KERN_META_PKG=linux-image-arm64 | ||
;; | ||
esac | ||
|
||
# check if it's a "cloud" kernel | ||
if `uname -a | grep -q cloud`; then | ||
KERN_META_PKG=$(echo ${KERN_META_PKG} | sed 's/image/image-cloud/g') | ||
fi | ||
fi | ||
KERN_META_PKG_HEADS=$(echo ${KERN_META_PKG} | sed 's/image/headers/g') | ||
|
||
# Pretty-print | ||
echo "" | ||
echo " Debian Version: ${1}" | ||
echo " Architecture: $(uname -m)" | ||
echo " Kernel Package: ${KERN_META_PKG}" | ||
echo " Kernel Headers Package: ${KERN_META_PKG_HEADS}" | ||
echo "" | ||
|
||
# Remediate if needing a backport | ||
if [ ${NEEDS_BACKPORTS} -eq 1 ]; then | ||
|
||
# Check to see if Debian 12 is already remediated | ||
if [ -f /etc/asl-kernel-manager/d12-6.1.0-broken ]; then | ||
echo "" | ||
echo "Task d12-6.1.0-broken already completed; no action" | ||
echo "" | ||
exit 0 | ||
fi | ||
|
||
# Enable bookworm-backports | ||
echo " Enabling bookworm-backports for this system" | ||
remove_marked_kernels | ||
enable_bookworm_backports | ||
set_semaphore | ||
echo "" | ||
echo " This system requires a reboot" | ||
echo "" | ||
wall "asl-kernel-manager needs to reboot the system in 60 seconds" | ||
shutdown -r | ||
exit 0 | ||
|
||
else | ||
echo " Not enabling backports for this system" | ||
echo "" | ||
exit 0 | ||
fi | ||
} | ||
|
||
function enable_bookworm_backports() { | ||
|
||
cat - > /etc/apt/sources.list.d/asl3-debian-bookworm-backports.list <<EOF | ||
# | ||
# Enable Bookworm Backports for ASL3 | ||
# | ||
deb http://deb.debian.org/debian bookworm-backports main contrib non-free non-free-firmware | ||
EOF | ||
|
||
DEBIAN_FRONTEND=noninteractive apt update | ||
DEBIAN_FRONTEND=noninteractive \ | ||
apt upgrade -y -t bookworm-backports $KERN_META_PKG $KERN_MEGA_PKG_HEADS | ||
|
||
} | ||
|
||
function remove_marked_kernels() { | ||
HELD_KERNS=$(apt-mark showhold | grep -E '^linux\-(headers|image)') | ||
if [ ! -z "${HELD_KERNS}" ]; then | ||
apt-mark unhold ${HELD_KERNS} | ||
fi | ||
} | ||
|
||
function set_d12_610_semaphore() { | ||
if [ ! -d /etc/asl-kernel-manager ]; then | ||
mkdir /etc/asl-kernel-manager | ||
fi | ||
chmod 700 /etc/asl-kernel-manager | ||
|
||
echo $(date +%s) > /etc/asl-kernel-manager/d12-6.1.0-broken | ||
echo $(date --rfc-3339=seconds) >> /etc/asl-kernel-manager/d12-6.1.0-broken | ||
} | ||
|
||
# | ||
# What Debian version are we on? | ||
# | ||
case ${DEBIAN_MAJ_VERSION} in | ||
12) | ||
debian_12 ${DEBIAN_MAJ_VERSION} | ||
;; | ||
*) | ||
echo "This script does not support Debian ${DEBIAN_MAJ_VERSION}" | ||
exit 1 | ||
;; | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
etc/asl-kernel-manager |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#!/bin/bash | ||
# postinst script for asl3 | ||
# | ||
# see: dh_installdeb(1) | ||
|
||
# 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> | ||
# * <postinst> `abort-remove' | ||
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour' | ||
# <failed-install-package> <version> `removing' | ||
# <conflicting-package> <version> | ||
# for details, see https://www.debian.org/doc/debian-policy/ or | ||
# the debian-policy package | ||
# | ||
|
||
set -e | ||
|
||
function print_kernel_banner() { | ||
echo "" | ||
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" | ||
echo "" | ||
( cat - <<EOM | ||
Some Debian 6.1.0 kernel versions (those after 6.1.0-28) have | ||
exhibited performance issues with OSS-based USB devices like | ||
those used by AllStarLink. | ||
!!! Your system is running one of the affected kernels !!! | ||
To address this issue we recommend that your system be configured | ||
to use Debian Bookworm-Backports to obtain the latest 6.11.0 based | ||
kernel. The newer kernel restores proper Asterisk/app_rpt support | ||
for AllStarLink. | ||
When this upgrade completes, run /usr/bin/asl-kernel-manager | ||
and reboot the system when prompted | ||
EOM | ||
) | fmt | ||
echo "" | ||
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" | ||
echo "" | ||
sleep 5 | ||
} | ||
|
||
function do_configure() { | ||
if [ ! -f /etc/asl-kernel-manager/d12-6.1.0-broken ]; then | ||
is_rpi=$(grep Raspberry /proc/cpuinfo | wc -l) | ||
if [ "${is_rpi}" -eq 0 ]; then | ||
if `dpkg --compare-versions $(uname -r) gt 6.1.0-28-amd64` && | ||
`dpkg --compare-versions $(uname -r) lt 6.11.0`; then | ||
print_kernel_banner | ||
fi | ||
fi | ||
fi | ||
} | ||
|
||
case "$1" in | ||
configure) | ||
do_configure | ||
;; | ||
|
||
abort-upgrade|abort-remove|abort-deconfigure) | ||
;; | ||
|
||
*) | ||
echo "postinst called with unknown argument \`$1'" >&2 | ||
exit 1 | ||
;; | ||
esac | ||
|
||
# dh_installdeb will replace this with shell code automatically | ||
# generated by other debhelper scripts. | ||
|
||
#DEBHELPER# | ||
|
||
exit 0 | ||
|