add option to link kernel modules
This commit is contained in:
commit
ff5554d304
4 changed files with 39 additions and 0 deletions
|
|
@ -28,4 +28,5 @@ Description = Performing snapper pre snapshots for the following configurations.
|
||||||
Depends = snap-pac
|
Depends = snap-pac
|
||||||
When = PreTransaction
|
When = PreTransaction
|
||||||
Exec = /usr/share/libalpm/scripts/snap-pac pre
|
Exec = /usr/share/libalpm/scripts/snap-pac pre
|
||||||
|
NeedsTargets
|
||||||
AbortOnFail
|
AbortOnFail
|
||||||
|
|
|
||||||
|
|
@ -28,3 +28,4 @@ Description = Performing snapper post snapshots for the following configurations
|
||||||
Depends = snap-pac
|
Depends = snap-pac
|
||||||
When = PostTransaction
|
When = PostTransaction
|
||||||
Exec = /usr/share/libalpm/scripts/snap-pac post
|
Exec = /usr/share/libalpm/scripts/snap-pac post
|
||||||
|
NeedsTargets
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,22 @@ Number of characters to limit length of descriptions used for snapper.
|
||||||
Default is "48".
|
Default is "48".
|
||||||
.RE
|
.RE
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
The following are settings used on each specific snapper
|
The following are settings used on each specific snapper
|
||||||
|
=======
|
||||||
|
\fBLINK_MODULES=\fR\fB\fIyes\fR\fR\fB or \fR\fB\fIno\fR\fR
|
||||||
|
.RS 4
|
||||||
|
When set to "yes" this, if the \fIlinux\fR package is updated, then a
|
||||||
|
symlink will be created in the kernel modules directory for the
|
||||||
|
currently running kernel to same directory in the pre snapshot. This
|
||||||
|
is so that the kernel modules will still be available for use before a
|
||||||
|
reboot is required.
|
||||||
|
|
||||||
|
Default is "no".
|
||||||
|
.RE
|
||||||
|
|
||||||
|
The following are possible settings used on each specific snapper
|
||||||
|
>>>>>>> modules
|
||||||
configuration you have. To use them, first create the folder
|
configuration you have. To use them, first create the folder
|
||||||
\fI/etc/snap-pac\fR if it does not already exist. Then create a file
|
\fI/etc/snap-pac\fR if it does not already exist. Then create a file
|
||||||
for the snapper configuration file you want these settings to apply
|
for the snapper configuration file you want these settings to apply
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,18 @@ truncate_description() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
package_updated() {
|
||||||
|
check="$1"
|
||||||
|
for x in ${packages[@]}; do
|
||||||
|
echo $x
|
||||||
|
if [[ "$x" == "$check" ]]; then
|
||||||
|
echo "yes"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo "no"
|
||||||
|
}
|
||||||
|
|
||||||
trap 'traperror ${LINENO} $? "$BASH_COMMAND" $BASH_LINENO "${FUNCNAME[@]}"' ERR
|
trap 'traperror ${LINENO} $? "$BASH_COMMAND" $BASH_LINENO "${FUNCNAME[@]}"' ERR
|
||||||
trap trapkill SIGTERM SIGINT
|
trap trapkill SIGTERM SIGINT
|
||||||
|
|
||||||
|
|
@ -84,6 +96,11 @@ read_config "$SNAPPAC_CONFIG_FILE"
|
||||||
|
|
||||||
readonly DESC_LIMIT=${DESC_LIMIT:-48}
|
readonly DESC_LIMIT=${DESC_LIMIT:-48}
|
||||||
readonly ABORT_ON_FAIL=${ABORT_ON_FAIL:-"no"}
|
readonly ABORT_ON_FAIL=${ABORT_ON_FAIL:-"no"}
|
||||||
|
readonly LINK_MODULES=${LINK_MODULES:-"no"}
|
||||||
|
readonly KERNEL_PACKAGE=${KERNEL_PACKAGE=-"linux"}
|
||||||
|
|
||||||
|
mapfile -t packages
|
||||||
|
kernel_updated=$(package_updated "$KERNEL_PACKAGE")
|
||||||
|
|
||||||
for CONFIG in $SNAPPER_CONFIGS; do
|
for CONFIG in $SNAPPER_CONFIGS; do
|
||||||
|
|
||||||
|
|
@ -112,6 +129,11 @@ for CONFIG in $SNAPPER_CONFIGS; do
|
||||||
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"
|
||||||
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
|
||||||
|
printf "==> Symlinking old kernel modules...\n"
|
||||||
|
find /usr/lib/modules -xtype l -delete -print
|
||||||
|
ln -sv /.snapshots/$(<$prefile)/snapshot/usr/lib/modules/$(uname -r) /usr/lib/modules/
|
||||||
|
fi
|
||||||
x=$($snapper_cmd "$(truncate_description $POST_DESCRIPTION)" --pre-number "$(< "$prefile")")
|
x=$($snapper_cmd "$(truncate_description $POST_DESCRIPTION)" --pre-number "$(< "$prefile")")
|
||||||
printf "==> %s: %s\n" "$CONFIG" "$x"
|
printf "==> %s: %s\n" "$CONFIG" "$x"
|
||||||
rm -f "$prefile"
|
rm -f "$prefile"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue