mirror of
https://github.com/tteck/Proxmox.git
synced 2024-11-22 00:04:13 +01:00
Update update-lxcs-cron.sh
tweak
This commit is contained in:
parent
07895a7c23
commit
b129cb1767
@ -5,24 +5,18 @@
|
|||||||
# License: MIT
|
# License: MIT
|
||||||
# https://github.com/tteck/Proxmox/raw/main/LICENSE
|
# https://github.com/tteck/Proxmox/raw/main/LICENSE
|
||||||
|
|
||||||
echo "$(date)"
|
echo -e "\n $(date)"
|
||||||
excluded_containers=("$@")
|
excluded_containers=("$@")
|
||||||
function update_container() {
|
function update_container() {
|
||||||
container=$1
|
container=$1
|
||||||
name=$(pct exec "$container" hostname)
|
name=$(pct exec "$container" hostname)
|
||||||
|
echo -e "\n [Info] Updating $container : $name \n"
|
||||||
os=$(pct config "$container" | awk '/^ostype/ {print $2}')
|
os=$(pct config "$container" | awk '/^ostype/ {print $2}')
|
||||||
if [[ "$os" == "ubuntu" || "$os" == "debian" ]]; then
|
|
||||||
disk_info=$(pct exec "$container" df /boot | awk 'NR==2{gsub("%","",$5); printf "%s %.1fG %.1fG %.1fG", $5, $3/1024/1024, $2/1024/1024, $4/1024/1024 }')
|
|
||||||
read -ra disk_info_array <<<"$disk_info"
|
|
||||||
echo -e "\n[Info] Updating $container : $name - Boot Disk: ${disk_info_array[0]}% full [${disk_info_array[1]}/${disk_info_array[2]} used, ${disk_info_array[3]} free]"
|
|
||||||
else
|
|
||||||
echo -e "\n[Info] Updating $container : $name - [No disk info for ${os}]"
|
|
||||||
fi
|
|
||||||
case "$os" in
|
case "$os" in
|
||||||
alpine) pct exec "$container" -- ash -c "apk update && apk upgrade" ;;
|
alpine) pct exec "$container" -- ash -c "apk update && apk upgrade" ;;
|
||||||
archlinux) pct exec "$container" -- bash -c "pacman -Syyu --noconfirm" ;;
|
archlinux) pct exec "$container" -- bash -c "pacman -Syyu --noconfirm" ;;
|
||||||
fedora | rocky | centos | alma) pct exec "$container" -- bash -c "dnf -y update && dnf -y upgrade" ;;
|
fedora | rocky | centos | alma) pct exec "$container" -- bash -c "dnf -y update && dnf -y upgrade" ;;
|
||||||
ubuntu | debian | devuan) pct exec "$container" -- bash -c "apt-get update 2>/dev/null | grep 'packages.*upgraded'; apt-get upgrade --dry-run && DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::="--force-confold" dist-upgrade -y; rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED" ;;
|
ubuntu | debian | devuan) pct exec "$container" -- bash -c "apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::="--force-confold" dist-upgrade -y; rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED" ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,7 +37,6 @@ for container in $(pct list | awk '{if(NR>1) print $1}'); do
|
|||||||
if [ "$template" == "false" ] && [ "$status" == "status: stopped" ]; then
|
if [ "$template" == "false" ] && [ "$status" == "status: stopped" ]; then
|
||||||
echo -e "[Info] Starting $container"
|
echo -e "[Info] Starting $container"
|
||||||
pct start $container
|
pct start $container
|
||||||
echo -e "[Info] Waiting For $container To Start"
|
|
||||||
sleep 5
|
sleep 5
|
||||||
update_container $container
|
update_container $container
|
||||||
echo -e "[Info] Shutting down $container"
|
echo -e "[Info] Shutting down $container"
|
||||||
@ -54,5 +47,3 @@ for container in $(pct list | awk '{if(NR>1) print $1}'); do
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
wait
|
wait
|
||||||
|
|
||||||
echo -e "Finished, All Containers Updated. \n"
|
|
||||||
|
Loading…
Reference in New Issue
Block a user