check if kernel is updated
This commit is contained in:
parent
d92c259b70
commit
4151fcb35c
3 changed files with 11 additions and 2 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
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,13 @@
|
||||||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
|
||||||
|
kernel_updated="no"
|
||||||
|
while read -r f; do
|
||||||
|
if [[ "$f" == "linux" ]]; then
|
||||||
|
kernel_updated="yes"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
declare -r SNAPPER_CONFIG_FILE=/etc/conf.d/snapper
|
declare -r SNAPPER_CONFIG_FILE=/etc/conf.d/snapper
|
||||||
declare -r DESC_LIMIT=48
|
declare -r DESC_LIMIT=48
|
||||||
declare -r name="snap-pac"
|
declare -r name="snap-pac"
|
||||||
|
|
@ -72,14 +79,14 @@ for CONFIG in $SNAPPER_CONFIGS; do
|
||||||
if [[ "$pre_or_post" == "pre" ]]; then
|
if [[ "$pre_or_post" == "pre" ]]; then
|
||||||
x=$($snapper_cmd "$(truncate_description $PACMAN_PRE_DESCRIPTION)")
|
x=$($snapper_cmd "$(truncate_description $PACMAN_PRE_DESCRIPTION)")
|
||||||
printf "==> %s: $(echo $x | tee "$prefile")\n" "$CONFIG"
|
printf "==> %s: $(echo $x | tee "$prefile")\n" "$CONFIG"
|
||||||
if [[ $CONFIG == "root" && $PACMAN_KEEP_OLD_KERNELS == "yes" ]]; then
|
if [[ $CONFIG == "root" && $PACMAN_KEEP_OLD_KERNELS == "yes" && $kernel_updated == "yes" ]]; then
|
||||||
[[ -d /boot/old ]] && mkdir -p /boot/old
|
[[ -d /boot/old ]] && mkdir -p /boot/old
|
||||||
find /usr/lib/modules -xtype l -delete
|
find /usr/lib/modules -xtype l -delete
|
||||||
find /boot/old -xtype l -delete
|
find /boot/old -xtype l -delete
|
||||||
ln -s /.snapshots/$x/snapshot/boot/vmlinuz-linux/boot/old/vmlinuz-linux-$(uname -r)
|
ln -s /.snapshots/$x/snapshot/boot/vmlinuz-linux/boot/old/vmlinuz-linux-$(uname -r)
|
||||||
fi
|
fi
|
||||||
elif [[ -f $prefile && "$pre_or_post" == "post" ]]; then
|
elif [[ -f $prefile && "$pre_or_post" == "post" ]]; then
|
||||||
if [[ $CONFIG == "root" $PACMAN_KEEP_OLD_KERNELS == "yes" ]]; then
|
if [[ $CONFIG == "root" && $PACMAN_KEEP_OLD_KERNELS == "yes" && $kernel_updated == "yes" ]]; then
|
||||||
x=$(<$prefile)
|
x=$(<$prefile)
|
||||||
ln -s /.snapshots/$x/snapshot/usr/lib/modules/$(uname -r) /usr/lib/modules/
|
ln -s /.snapshots/$x/snapshot/usr/lib/modules/$(uname -r) /usr/lib/modules/
|
||||||
kver=$(pacman -Q linux | awk '{print $2}')-ARCH
|
kver=$(pacman -Q linux | awk '{print $2}')-ARCH
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue