diff --git a/hooks/00_snapper-pre.hook b/hooks/00_snapper-pre.hook index 86ed649..79af5f6 100644 --- a/hooks/00_snapper-pre.hook +++ b/hooks/00_snapper-pre.hook @@ -28,4 +28,5 @@ Description = Performing snapper pre snapshots for the following configurations. Depends = snap-pac When = PreTransaction Exec = /usr/share/libalpm/scripts/snap-pac pre +NeedsTargets AbortOnFail diff --git a/hooks/zy_snapper-post.hook b/hooks/zy_snapper-post.hook index f6c67a0..2513dc6 100644 --- a/hooks/zy_snapper-post.hook +++ b/hooks/zy_snapper-post.hook @@ -28,3 +28,4 @@ Description = Performing snapper post snapshots for the following configurations Depends = snap-pac When = PostTransaction Exec = /usr/share/libalpm/scripts/snap-pac post +NeedsTargets diff --git a/man8/snap-pac.8 b/man8/snap-pac.8 index 7e6a39a..a37f8df 100644 --- a/man8/snap-pac.8 +++ b/man8/snap-pac.8 @@ -54,7 +54,22 @@ Number of characters to limit length of descriptions used for snapper. Default is "48". .RE +<<<<<<< HEAD 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 \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 diff --git a/scripts/snap-pac b/scripts/snap-pac index 6f8d09e..8e72e4d 100755 --- a/scripts/snap-pac +++ b/scripts/snap-pac @@ -73,6 +73,18 @@ truncate_description() { 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 trapkill SIGTERM SIGINT @@ -84,6 +96,11 @@ read_config "$SNAPPAC_CONFIG_FILE" readonly DESC_LIMIT=${DESC_LIMIT:-48} 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 @@ -112,6 +129,11 @@ for CONFIG in $SNAPPER_CONFIGS; do x=$($snapper_cmd "$(truncate_description $PRE_DESCRIPTION)") printf "==> %s: $(echo $x | tee "$prefile")\n" "$CONFIG" 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")") printf "==> %s: %s\n" "$CONFIG" "$x" rm -f "$prefile"