Last active
August 23, 2023 20:51
-
-
Save Carlgo11/c7d5c6ba37cb5b0aa54dcfa779a12170 to your computer and use it in GitHub Desktop.
APK Update cron job with auto-reboot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# This script runs apk (Alpine Package Keeper) upgrade and checks if the installed kernel version differs from the running. | |
# If the versions differ, the system reboots. | |
# Script only runs on Alpine Linux. | |
apk -U upgrade | |
sync | |
installed_version=$(apk -I list | grep '^linux-lts' | sed -n 's/.*-\([0-9.]\+\)-r.*/\1/p') | |
running_version=$(uname -r | sed 's/\([0-9.]\+\)-.*/\1/') | |
if [ "$installed_version" != "$running_version" ]; then | |
reboot | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment