check if kernel is updated

This commit is contained in:
James Barnett 2017-04-18 20:00:44 -05:00
parent d92c259b70
commit 4151fcb35c
No known key found for this signature in database
GPG key ID: E4B5E45AA3B8C5C3
3 changed files with 11 additions and 2 deletions

View file

@ -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

View file

@ -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

View file

@ -18,6 +18,13 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 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 DESC_LIMIT=48
declare -r name="snap-pac"
@ -72,14 +79,14 @@ for CONFIG in $SNAPPER_CONFIGS; do
if [[ "$pre_or_post" == "pre" ]]; then
x=$($snapper_cmd "$(truncate_description $PACMAN_PRE_DESCRIPTION)")
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
find /usr/lib/modules -xtype l -delete
find /boot/old -xtype l -delete
ln -s /.snapshots/$x/snapshot/boot/vmlinuz-linux/boot/old/vmlinuz-linux-$(uname -r)
fi
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)
ln -s /.snapshots/$x/snapshot/usr/lib/modules/$(uname -r) /usr/lib/modules/
kver=$(pacman -Q linux | awk '{print $2}')-ARCH