mirror of https://github.com/tteck/Proxmox.git
Update update-lxcs.sh
List containers that require a reboot
This commit is contained in:
parent
40ea76c066
commit
87e3c7581d
|
@ -36,6 +36,21 @@ while read -r TAG ITEM; do
|
||||||
EXCLUDE_MENU+=("$TAG" "$ITEM " "OFF")
|
EXCLUDE_MENU+=("$TAG" "$ITEM " "OFF")
|
||||||
done < <(pct list | awk 'NR>1')
|
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
|
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() {
|
function update_container() {
|
||||||
container=$1
|
container=$1
|
||||||
header_info
|
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" ;;
|
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
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
containers_needing_reboot=()
|
||||||
header_info
|
header_info
|
||||||
for container in $(pct list | awk '{if(NR>1) print $1}'); do
|
for container in $(pct list | awk '{if(NR>1) print $1}'); do
|
||||||
if [[ " ${excluded_containers[@]} " =~ " $container " ]]; then
|
if [[ " ${excluded_containers[@]} " =~ " $container " ]]; then
|
||||||
|
@ -75,8 +92,18 @@ for container in $(pct list | awk '{if(NR>1) print $1}'); do
|
||||||
elif [ "$status" == "status: running" ]; then
|
elif [ "$status" == "status: running" ]; then
|
||||||
update_container $container
|
update_container $container
|
||||||
fi
|
fi
|
||||||
|
if pct exec "$container" -- [ -e "/var/run/reboot-required" ]; then
|
||||||
|
containers_needing_reboot+=("$container")
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
wait
|
wait
|
||||||
header_info
|
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 ""
|
||||||
|
|
Loading…
Reference in New Issue