summarylogtreecommitdiffstats
path: root/post-hook
diff options
context:
space:
mode:
authorJonathan Kotta2020-05-22 21:42:59 -0500
committerJonathan Kotta2020-05-22 21:42:59 -0500
commit122e810023b8711aafef823131e3a4e6b638cd59 (patch)
treec5ff81a8ef31cbdc16d1fbc8f2db4367afbcbb5e /post-hook
parent7067f149f8a3effbe6428afb6307582b52b27f09 (diff)
downloadaur-saved-kernel-modules.tar.gz
bug fixes
mkdir saved-kernel-modules/modules just in case it gets deleted post hook backs up an existing /usr/lib/modules/$(uname -r) packaging bugs cause files to get left behind and then it isn't deleted properly
Diffstat (limited to 'post-hook')
-rwxr-xr-xpost-hook15
1 files changed, 13 insertions, 2 deletions
diff --git a/post-hook b/post-hook
index 91fb9cac846..479bc5c156d 100755
--- a/post-hook
+++ b/post-hook
@@ -8,7 +8,18 @@ cd /usr/lib/modules/saved-kernel-modules
running_kernel=$(uname -r)
-if [ -e modules/"$running_kernel" ] \
- && [ ! -e /usr/lib/modules/"$running_kernel" ] ; then
+if [ -e modules/"$running_kernel" ] ; then
+ if [ -L /usr/lib/modules/"$running_kernel" ] ; then
+ # symlink already there, do nothing
+ exit 0
+ elif [ -d /usr/lib/modules/"$running_kernel" ] ; then
+ # leftover for some reason, make a backup
+ suffix="bck-$(date -u +%FT%T)"
+ mv /usr/lib/modules/"$running_kernel" \
+ /usr/lib/modules/"$running_kernel-${suffix}"
+ echo "This directory was backed up by saved-kernel-modules, it's probably safe to delete." \
+ > /usr/lib/modules/"$running_kernel-${suffix}"/DELETE_THIS_DIR
+ fi
+
ln -s $PWD/modules/"$running_kernel" /usr/lib/modules/"$running_kernel"
fi