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

View file

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