Compare commits

...

4 Commits

Author SHA1 Message Date
tteckster 1517bec1c3
Update update-lxcs.sh
tweak
2023-10-08 12:07:56 -04:00
tteckster 3b4b021c9a
Update update-lxcs.sh
display hostname of containers that require a reboot
2023-10-08 12:01:25 -04:00
tteckster 61773ad6af
Update CHANGELOG.md
- Proxmox VE LXC Updater
2023-10-08 10:44:00 -04:00
tteckster 87e3c7581d
Update update-lxcs.sh
List containers that require a reboot
2023-10-08 10:06:12 -04:00
2 changed files with 37 additions and 1 deletions

View File

@ -5,6 +5,13 @@
- All LXC instances created using this repository come pre-installed with Midnight Commander, which is a command-line tool (`mc`) that offers a user-friendly file and directory management interface for the terminal environment.
## 2023-10-08
### Changed
- **Proxmox VE LXC Updater**
- Now displays which containers require a reboot.
## 2023-10-05
### Changed

View File

@ -36,6 +36,21 @@ while read -r TAG ITEM; do
EXCLUDE_MENU+=("$TAG" "$ITEM " "OFF")
done < <(pct list | awk 'NR>1')
excluded_containers=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "Containers on $NODE" --checklist "\nSelect containers to skip from updates:\n" 16 $((MSG_MAX_LENGTH + 23)) 6 "${EXCLUDE_MENU[@]}" 3>&1 1>&2 2>&3 | tr -d '"') || exit
function needs_reboot() {
local container=$1
local os=$(pct config "$container" | awk '/^ostype/ {print $2}')
local reboot_required_file="/var/run/reboot-required.pkgs"
if [ -f "$reboot_required_file" ]; then
if [[ "$os" == "ubuntu" || "$os" == "debian" ]]; then
if pct exec "$container" -- [ -s "$reboot_required_file" ]; then
return 0
fi
fi
fi
return 1
}
function update_container() {
container=$1
header_info
@ -55,6 +70,8 @@ function update_container() {
ubuntu | debian | devuan) pct exec "$container" -- bash -c "apt-get update 2>/dev/null | grep 'packages.*upgraded'; apt list --upgradable && apt-get -y dist-upgrade" ;;
esac
}
containers_needing_reboot=()
header_info
for container in $(pct list | awk '{if(NR>1) print $1}'); do
if [[ " ${excluded_containers[@]} " =~ " $container " ]]; then
@ -75,8 +92,20 @@ for container in $(pct list | awk '{if(NR>1) print $1}'); do
elif [ "$status" == "status: running" ]; then
update_container $container
fi
if pct exec "$container" -- [ -e "/var/run/reboot-required" ]; then
# Get the container's hostname and add it to the list
container_hostname=$(pct exec "$container" hostname)
containers_needing_reboot+=("$container ($container_hostname)")
fi
fi
done
wait
header_info
echo -e "${GN} Finished, Selected Containers Updated. ${CL} \n"
echo -e "${GN}The process is complete, and the selected containers have been updated.${CL}\n"
if [ "${#containers_needing_reboot[@]}" -gt 0 ]; then
echo -e "${RD}The following containers require a reboot:${CL}"
for container_name in "${containers_needing_reboot[@]}"; do
echo "$container_name"
done
fi
echo ""