Compare commits

..

No commits in common. "5da67255d6eb99af601770f6903c2a83729fe2e4" and "ba966fdff88d15938920cc06441403fb420744f8" have entirely different histories.

3 changed files with 49 additions and 46 deletions

View File

@ -65,9 +65,9 @@ function msg_error() {
} }
function PVE_CHECK() { function PVE_CHECK() {
if ! pveversion | grep -Eq "pve-manager/(7\.[2-9]|8\.[0-9])"; then if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then
echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported"
echo -e "Requires PVE Version 7.2 or higher" echo -e "Requires PVE Version 7.0 or higher"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit

View File

@ -4,21 +4,21 @@
# Author: tteck (tteckster) # Author: tteck (tteckster)
# License: MIT # License: MIT
# https://github.com/tteck/Proxmox/raw/main/LICENSE # https://github.com/tteck/Proxmox/raw/main/LICENSE
# bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/misc/cron-update-lxcs.sh)"
clear clear
cat <<"EOF" cat <<"EOF"
__ __ __ __ __ _ ________ ______ __ __ __ __ __ _ ________ ______
/ ____/________ ____ / / / /___ ____/ /___ _/ /____ / / | |/ / ____/____ / / / /___ ____/ /___ _/ /____ / / | |/ / ____/____ / ____/________ ____
/ / / ___/ __ \/ __ \ / / / / __ \/ __ / __ `/ __/ _ \ / / | / / / ___/ / / / / __ \/ __ / __ `/ __/ _ \ / / | / / / ___/ / / / ___/ __ \/ __ \
/ /___/ / / /_/ / / / / / /_/ / /_/ / /_/ / /_/ / /_/ __/ / /___/ / /___(__ ) / /_/ / /_/ / /_/ / /_/ / /_/ __/ / /___/ / /___(__ ) / /___/ / / /_/ / / / /
\____/_/ \____/_/ /_/ \____/ .___/\__,_/\__,_/\__/\___/ /_____/_/|_\____/____/ \____/ .___/\__,_/\__,_/\__/\___/ /_____/_/|_\____/____/ \____/_/ \____/_/ /_/
/_/ /_/
EOF EOF
add() { add() {
while true; do while true; do
read -p "This script will add a crontab schedule that updates all LXCs every Sunday at midnight. Proceed(y/n)?" yn read -p "This script will schedule a cron job that updates all LXCs every Sunday at midnight. Proceed(y/n)?" yn
case $yn in case $yn in
[Yy]*) break ;; [Yy]*) break ;;
[Nn]*) exit ;; [Nn]*) exit ;;
@ -27,21 +27,24 @@ add() {
done done
sh -c '(crontab -l -u root 2>/dev/null; echo "0 0 * * 0 PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin /bin/bash -c \"\$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/misc/update-lxcs-cron.sh)\" >>/var/log/update-lxcs-cron.log 2>/dev/null") | crontab -u root -' sh -c '(crontab -l -u root 2>/dev/null; echo "0 0 * * 0 PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin /bin/bash -c \"\$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/misc/update-lxcs-cron.sh)\" >>/var/log/update-lxcs-cron.log 2>/dev/null") | crontab -u root -'
clear clear
echo -e "\n To view Cron Update LXCs logs: cat /var/log/update-lxcs-cron.log" echo -e "\n To view Update LXCs Cron logs: cat /var/log/update-lxcs-cron.log"
} }
remove() { remove() {
(crontab -l | grep -v "github.com/tteck/Proxmox/raw/main/misc/update-lxcs-cron.sh") | crontab - (crontab -l | grep -v "github.com/tteck/Proxmox/raw/main/misc/update-lxcs-cron.sh") | crontab -
rm -rf /var/log/update-lxcs-cron.log rm /var/log/update-lxcs-cron.log
echo "Removed Crontab Schedule from Proxmox VE" echo "Removed Update LXCs Cron from Proxmox VE"
} }
OPTIONS=(Add "Add Crontab Schedule" # Define options for the whiptail menu
Remove "Remove Crontab Schedule") OPTIONS=(Add "Add Update LXCs Cron to Proxmox VE" \
Remove "Remove Update LXCs Cron from Proxmox VE")
CHOICE=$(whiptail --title "Cron Update LXCs" --menu "Select an option:" 10 58 2 \ # Show the whiptail menu and save the user's choice
CHOICE=$(whiptail --title "Update LXCs Cron for Proxmox VE" --menu "Select an option:" 10 58 2 \
"${OPTIONS[@]}" 3>&1 1>&2 2>&3) "${OPTIONS[@]}" 3>&1 1>&2 2>&3)
# Check the user's choice and perform the corresponding action
case $CHOICE in case $CHOICE in
"Add") "Add")
add add