Remove old module symlinks on pre snapshot

Only do this if LINK_MODULES is set to yes. This prevents old symlinks
getting in the way of other packages.

Fixes #21.
This commit is contained in:
Wes Barnett 2018-08-15 20:06:35 -04:00
parent 42f12d216f
commit 39dee2be1f
No known key found for this signature in database
GPG key ID: E4B5E45AA3B8C5C3
2 changed files with 5 additions and 5 deletions

View file

@ -65,10 +65,8 @@ symlink will be created in the kernel modules directory for the
currently running kernel to same directory in the pre snapshot of the
"root" configuration. This is so that the kernel modules will still be
available for use before a reboot is required. snap-pac will also
delete broken symlinks in the kernel modules directory if this is set
to "yes". (snapper
removes configurations according to the specified cleanup algorithm,
so eventually symlinks to old kernel modules directories will break).
delete all symlinks in the kernel modules directory if this is set
to "yes", in order to clean up the directory.
Default is "no".
.RE

View file

@ -129,10 +129,12 @@ for CONFIG in $SNAPPER_CONFIGS; do
if [[ "$pre_or_post" == "pre" ]]; then
x=$($snapper_cmd "$(truncate_description $PRE_DESCRIPTION)")
printf "==> %s: $(echo $x | tee "$prefile")\n" "$CONFIG"
if [[ "$LINK_MODULES" == "yes" && "$CONFIG" == "root" ]]; then
find /usr/lib/modules -xtype l -delete
fi
elif [[ -f $prefile && "$pre_or_post" == "post" ]]; then
if [[ "$LINK_MODULES" == "yes" && "$kernel_updated" == "yes" && "$CONFIG" == "root" ]]; then
printf "==> Symlinking old kernel modules...\n"
find /usr/lib/modules -xtype l -delete
ln -sv /.snapshots/$(<$prefile)/snapshot/usr/lib/modules/$(uname -r) /usr/lib/modules/
fi
x=$($snapper_cmd "$(truncate_description $POST_DESCRIPTION)" --pre-number "$(< "$prefile")")