Merge branch 'main' into main

This commit is contained in:
Meliox 2023-06-27 20:10:25 +02:00 committed by GitHub
commit f17e6efe7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 68 additions and 2 deletions

View File

@ -1,6 +1,8 @@
# Proxmox mods and script # Proxmox mods and script
A small collection of script and mods for Proxmox A small collection of script and mods for Proxmox
If you find this helpful, a small donation is appreciated, [![Donate](https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=K8XPMSEBERH3W).
## Node temperature view ## Node temperature view
(Test compatibility against 7.x & 8.0) (Test compatibility against 7.x & 8.0)
@ -24,9 +26,17 @@ wget https://github.com/Meliox/PVE-mods/blob/main/pve-mod-gui-temp.sh
![Promxox temp mod](https://github.com/Meliox/PVE-mods/blob/main/pve-mod-temp.png?raw=true) ![Promxox temp mod](https://github.com/Meliox/PVE-mods/blob/main/pve-mod-temp.png?raw=true)
### Configuration
Adjustments are available in the first part of the script, where paths can be edited, cpucore offset and display information. Adjustments are available in the first part of the script, where paths can be edited, cpucore offset and display information.
If you find this helpful, a small donation is appreciated, [![Donate](https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=K8XPMSEBERH3W). ## Scrip to update all containers
(compatible with all)
This script updates all running Proxmox containers, skipping specified excluded containers, and generates a separate log file for each container.
The script first updates the Proxmox host system, then iterates through each container, updates the container, and reboots it if necessary.
Each container's log file is stored in $log_path and the main script log file is named container-upgrade-main.log.
### Install
```
wget https://github.com/Meliox/PVE-mods/blob/main/updateallcontainers.sh
```
Can be added to cron for e.g. monthly update: ```0 6 1 * * /root/scripts/updateallcontainers.sh```

56
updateallcontainers.sh Normal file
View File

@ -0,0 +1,56 @@
#!/bin/bash
# This script updates all running Proxmox containers, skipping specified excluded containers, and generates a separate log file for each container.
# The script first updates the Proxmox host system, then iterates through each container, updates the container, and reboots it if necessary.
# Each container's log file is stored in $log_path and the main script log file is named container-upgrade-main.log.
# list of container ids we need to iterate through
containers=$(pct list | tail -n +2 | cut -f1 -d' ')
log_path="/root/scripts"
# array of container ids to exclude from updates
exclude_containers=("106")
#### CODE BELOW #########
container_main_log_file="${log_path}/container-upgrade-main.log"
echo "[Info] Updating proxmox containers at $(date)"
echo "[Info] Updating proxmox containers at $(date)" >> $container_main_log_file
#function to update individual containers
function update_container() {
container=$1
# log file for individual container
container_log_file="${log_path}/container-upgrade-$container.log"
# log start of update
echo "[Info] Starting update for container $container at $(date)" >> $container_log_file
# perform the update
/usr/sbin/pct exec $container -- bash -c "apt update && apt upgrade -y && apt autoremove -y && reboot" >> $container_log_file 2>&1
# log completion of update
echo "[Info] Completed update for $container at $(date)" >> $container_log_file
echo "--------------------------------------------------------------------------------------------" >> $container_log_file
}
for container in $containers; do
# skip excluded containers
if [[ " ${exclude_containers[@]} " =~ " ${container} " ]]; then
echo "[Info] Skipping excluded container, $container"
echo "[Info] Skipping excluded container, $container" >> $container_main_log_file
continue
fi
status=$(/usr/sbin/pct status $container)
if [ "$status" == "status: stopped" ]; then
echo "[Info] Skipping offline container, $container"
echo "[Info] Skipping offline container, $container" >> $container_main_log_file
elif [ "$status" == "status: running" ]; then
update_container $container
fi
done; wait
# log completion of all updates
echo "[Info] Updating proxmox containers completed at $(date)"
echo "[Info] Updating proxmox containers completed at $(date)" >> $container_main_log_file
echo "--------------------------------------------------------------------------------------------" >> $container_main_log_file