Forked from Trucido/reinstall-dkms-modules-pluszfs.sh
Created
September 12, 2018 03:45
-
-
Save fermulator/2113fd5e8ae78b3887248ac2b29b469a to your computer and use it in GitHub Desktop.
ugly hacky script to rebuild all dkms modules plus manually force zfs if it's intree for debian/ubuntu
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
#!/usr/bin/env bash | |
# rebuild/reinstall all dkms modules. | |
# double check there's no others missing too afterwards. | |
#template(){ | |
#KVER=x.x.x-arch | |
#ZVER=x.x.x.x-x | |
#dkms status | sed s/,//g | awk '{print "--force -m",$1,"-v",$2}' | while read line; do ls /var/lib/initramfs-tools | xargs -n 1 dkms build --force $line -k; done | |
#dkms status | sed s/,//g | awk '{print "--force -m",$1,"-v",$2}' | while read line; do ls /var/lib/initramfs-tools | xargs -n 1 dkms install --force $line -k; done | |
#dkms build --force -m spl -v $ZVER -k $KVER | |
#dkms build --force -m zfs -v $ZVER -k $KVER | |
#dkms install --force -m spl -v $ZVER -k $KVER | |
#dkms install --force -m zfs -v $ZVER -k $KVER | |
#} | |
if [[ "$(id -u)" -ne 0 ]]; then | |
echo "Must run this script as root, or with sudo." | |
exit 1 | |
fi | |
echo "Listing all dkms modules currently registered" | |
echo "Save this list to compare to the results afterwards" | |
echo "$(dkms status)" | |
sleep "5" | |
echo "Uninstalling all DKMS modules" | |
sleep "1" | |
dkms status | sed s/,//g | awk '{print "--force -m",$1,"-v",$2}' | \ | |
while read line; do ls /var/lib/initramfs-tools | \ | |
xargs -n 1 dkms uninstall $line -k; done | |
echo "Rebuilding all DKS modules" | |
sleep "1" | |
dkms status | sed s/,//g | awk '{print "--force -m",$1,"-v",$2}' | \ | |
while read line; do ls /var/lib/initramfs-tools | \ | |
xargs -n 1 dkms build $line -k; done | |
echo "DKMS Modules built, now installing" | |
sleep "1" | |
dkms status | sed s/,//g | awk '{print "--force -m",$1,"-v",$2}' | \ | |
while read line; do ls /var/lib/initramfs-tools | \ | |
xargs -n 1 dkms install --force $line -k; done | |
# sometimes dkms is stubborn and unregisters zfs completely from dkms | |
# so, i just quickly whipped this up since I got tired of reinstalling it manually | |
# It's ugly and not well tested but seems to work. | |
# could be shorter and more efficient though. | |
# get ARCH | |
if [ ! -z "$(getconf LONG_BIT)" ]; then | |
ARCH="amd64" | |
elif [ ! -z "$(uname -r | grep pae)" ]; then | |
ARCH="686-pae" | |
elif [ -z "$ARCH" ]; then | |
ARCH="686" | |
else | |
echo "[ERROR] Can't find your ARCH" | |
exit 1 | |
fi | |
# get the list of kernels we need to install zfs/spl. Yeah there's better ways of doing this, I know. | |
# this was scripted quickly to support more use cases where multiple source trees exist. | |
KVER="$(ls /usr/src/ | grep "linux-headers" | sed s/-common//g | sed s/linux-headers-//g | grep "$ARCH")" | |
# get the zfs version, the head -n1 is in case for some strange reason there is more than one else you're SOL | |
ZVER="$(ls /usr/src/ | grep zfs | sed s/zfs-//g | head -n1)" | |
# force build spl and zfs | |
for splb in $KVER; do | |
dkms build --force -m spl -v "${ZVER}" -k $splb; | |
done | |
for zfsb in $KVER; do | |
dkms build --force -m spl -v "${ZVER}" -k $zfsb; | |
done | |
# force install spl and zfs | |
for spli in $KVER; do | |
dkms install --force -m spl -v "${ZVER}" -k $spli; | |
done | |
for zfsi in $KVER; do | |
dkms install --force -m zfs -v "${ZVER}" -k $zfsi; | |
done | |
echo "Listing all dkms modules currently registered after rebuild" | |
echo "Compare them with the first list and If any are missing, they probably need manual re-installation." | |
echo "Read the commented template section of this script to get a rough idea of how it works" | |
echo "$(dkms status)" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment