Update cron-update-lxcs.sh

tweak
This commit is contained in:
tteckster 2023-07-18 04:38:50 -04:00 committed by GitHub
parent 3a920bbceb
commit a5b70669c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 36 additions and 36 deletions

View File

@ -4,55 +4,55 @@
# Author: tteck (tteckster)
# License: MIT
# 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
cat <<"EOF"
__ __ __ __ __ _ ________ ______
/ / / /___ ____/ /___ _/ /____ / / | |/ / ____/____ / ____/________ ____
/ / / / __ \/ __ / __ `/ __/ _ \ / / | / / / ___/ / / / ___/ __ \/ __ \
/ /_/ / /_/ / /_/ / /_/ / /_/ __/ / /___/ / /___(__ ) / /___/ / / /_/ / / / /
\____/ .___/\__,_/\__,_/\__/\___/ /_____/_/|_\____/____/ \____/_/ \____/_/ /_/
______ __ __ __ __ __ _ ________
/ ____/________ ____ / / / /___ ____/ /___ _/ /____ / / | |/ / ____/____
/ / / ___/ __ \/ __ \ / / / / __ \/ __ / __ `/ __/ _ \ / / | / / / ___/
/ /___/ / / /_/ / / / / / /_/ / /_/ / /_/ / /_/ / /_/ __/ / /___/ / /___(__ )
\____/_/ \____/_/ /_/ \____/ .___/\__,_/\__,_/\__/\___/ /_____/_/|_\____/____/
/_/
EOF
set -euo pipefail
shopt -s inherit_errexit nullglob
add() {
while true; do
read -p "This script will schedule a cron job that updates all LXCs every Sunday at midnight. Proceed(y/n)?" yn
while true; do
read -p "This script will add a crontab schedule that updates all LXCs every Sunday at midnight. Proceed(y/n)?" yn
case $yn in
[Yy]*) break ;;
[Nn]*) exit ;;
*) echo "Please answer yes or no." ;;
esac
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 -'
clear
echo -e "\n To view Update LXCs Cron logs: cat /var/log/update-lxcs-cron.log"
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 -'
clear
echo -e "\n To view Cron Update LXCs logs: cat /var/log/update-lxcs-cron.log"
}
remove() {
(crontab -l | grep -v "github.com/tteck/Proxmox/raw/main/misc/update-lxcs-cron.sh") | crontab -
rm /var/log/update-lxcs-cron.log
echo "Removed Update LXCs Cron from Proxmox VE"
echo "Removed Crontab Schedule from Proxmox VE"
}
# Define options for the whiptail menu
OPTIONS=(Add "Add Update LXCs Cron to Proxmox VE" \
Remove "Remove Update LXCs Cron from Proxmox VE")
OPTIONS=(Add "Add Crontab Schedule"
Remove "Remove Crontab Schedule")
# 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 \
CHOICE=$(whiptail --title "Cron Update LXCs" --menu "Select an option:" 10 58 2 \
"${OPTIONS[@]}" 3>&1 1>&2 2>&3)
# Check the user's choice and perform the corresponding action
case $CHOICE in
"Add")
"Add")
add
;;
"Remove")
"Remove")
remove
;;
*)
*)
echo "Exiting..."
exit 0
;;