Skip to content

Instantly share code, notes, and snippets.

@RPDiep
Last active August 29, 2015 13:56
Show Gist options
  • Save RPDiep/8800027 to your computer and use it in GitHub Desktop.
Save RPDiep/8800027 to your computer and use it in GitHub Desktop.
Apt hook for installing r1soft modules on ubuntu
DPkg::Post-Invoke {"/usr/local/sbin/r1soft-installmodule"}
Create r1soft-installmodule as /usr/local/sbin/r1soft-installmodule ( and make it executable )
Create 98r1soft-installmodule as /etc/apt/apt.conf.d/98r1soft-installmodule
#!/bin/bash
if [[ "$1" == "debug" ]]
then
debug=1
else
debug=0
fi
restart=0
kernelversion=$(uname -r)
kernelvariant=${kernelversion##*-}
exec 5>&1
[[ $debug -eq 0 ]] && exec >/dev/null 2>&1
for dir in /usr/src/linux-headers*${kernelvariant}
do
kernel=${dir##*headers-}
if [ -f /lib/modules/r1soft/hcpdriver-cki-${kernel}.ko ]
then
echo "Kernel module for kernel version ${kernel} exists"
else
echo "Installing r1soft module for kernel version ${kernel} ..." >&5
serverbackup-setup --get-module --kernel-dir ${dir}
restart=1
fi
done
[[ ${restart} -eq 1 ]] && /etc/init.d/cdp-agent restart
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment