Compare commits

..

No commits in common. "b3777abadca5a49a5d355ffeb4fdd9bde36cedf4" and "858a00176db77c18d0f6bdf336ffd2d3f77c3719" have entirely different histories.

4 changed files with 30 additions and 58 deletions

View File

@ -4,13 +4,6 @@
- All LXC instances created using this repository come pre-installed with Midnight Commander, which is a command-line tool (`mc`) that offers a user-friendly file and directory management interface for the terminal environment.
## 2023-09-06
### Changed
- **Proxmox VE LXC Cleaner**
- Added a new menu that allows you to choose which containers you want to exclude from the clean process.
## 2023-09-05
### Changed

View File

@ -1,7 +1,8 @@
<h3><p align="center"><a href="https://github.com/tteck/Proxmox/blob/main/.github/CONTRIBUTING.md">Contributing to Proxmox VE Helper Scripts</a></p></h3>
<sub>These scripts empower users to create a Linux container or virtual machine interactively, providing choices for both simple and advanced configurations. The basic setup adheres to default settings, while the advanced setup gives users the ability to customize these defaults. Utilizing the whiptail command, options are displayed to users in a dialog box format. Once the user makes their selections, the script collects and validates their input to generate the final configuration for the container or virtual machine.</sub>
<sub>These scripts enable users to build a Linux container or virtual machine in an interactive manner, offering options for both basic and advanced configurations. The basic setup utilizes default settings, whereas the advanced setup empowers users to alter these default settings. Through the use of the whiptail command, options are presented to users in a dialog box format. After the user makes their selections, the script collects and verifies the user's input in order to generate the final configuration for the container or virtual machine.</sub>
<h1><p align="center"><a href="https://tteck.github.io/Proxmox/">Proxmox VE Helper Scripts</a></p></h1>
<sub><p align="center"><a href="https://github.com/tteck/Proxmox/blob/main/CODE-AUDIT.md">Exercise caution and conduct a comprehensive assessment of scripts and automation tasks acquired from external sources.</a></p></sub>
<sub><div align="center"> Be cautious and thoroughly evaluate scripts and automation tasks obtained from external sources. </div></sub>
<sub><p align="center"><a href="https://github.com/tteck/Proxmox/blob/main/CODE-AUDIT.md">Be cautious and thoroughly evaluate scripts and automation tasks obtained from external sources.</a></p></sub>
<sub><div align="center"> Proxmox® is a registered trademark of Proxmox Server Solutions GmbH. </div></sub>

View File

@ -10,10 +10,10 @@ function header_info() {
cat <<"EOF"
________ __ _ ________
/ ____/ /__ ____ _____ / / | |/ / ____/
/ / / / _ \/ __ `/ __ \ / / | / /
/ /___/ / __/ /_/ / / / / / /___/ / /___
\____/_/\___/\__,_/_/ /_/ /_____/_/|_\____/
/ / / / _ \/ __ `/ __ \ / / | / /
/ /___/ / __/ /_/ / / / / / /___/ / /___
\____/_/\___/\__,_/_/ /_/ /_____/_/|_\____/
EOF
}
set -e
@ -25,7 +25,7 @@ GN=$(echo "\033[1;92m")
CL=$(echo "\033[m")
header_info
while true; do
read -p "This Will Clean logs, cache and update apt lists on selected LXC Containers. Proceed(y/n)?" yn
read -p "This Will Clean logs, cache and update apt lists on all LXC Containers. Proceed(y/n)?" yn
case $yn in
[Yy]*) break ;;
[Nn]*) exit ;;
@ -33,21 +33,6 @@ while true; do
esac
done
clear
NODE=$(hostname)
while read -r line; do
TAG=$(echo "$line" | awk '{print $1}')
ITEM=$(echo "$line" | awk '{print substr($0,36)}')
OFFSET=2
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET))
fi
CTID_MENU+=("$TAG" "$ITEM " "OFF")
done < <(pct list | awk 'NR>1')
excluded_containers=$(whiptail --title "Containers on $NODE" --checklist \
"\nSelect containers to skip from cleaning:\n" \
16 $(($MSG_MAX_LENGTH + 23)) 6 \
"${CTID_MENU[@]}" 3>&1 1>&2 2>&3 | tr -d '"') || exit
function clean_container() {
container=$1
header_info
@ -55,36 +40,29 @@ function clean_container() {
echo -e "${BL}[Info]${GN} Cleaning ${name} ${CL} \n"
pct exec $container -- bash -c "apt-get -y --purge autoremove && apt-get -y autoclean && bash <(curl -fsSL https://github.com/tteck/Proxmox/raw/main/misc/clean.sh) && rm -rf /var/lib/apt/lists/* && apt-get update"
}
for container in $(pct list | awk '{if(NR>1) print $1}'); do
if [[ " ${excluded_containers[@]} " =~ " $container " ]]; then
header_info
echo -e "${BL}[Info]${GN} Skipping ${BL}$container${CL}"
sleep 1
else
os=$(pct config "$container" | awk '/^ostype/ {print $2}')
if [ "$os" != "debian" ] && [ "$os" != "ubuntu" ]; then
header_info
echo -e "${BL}[Info]${GN} Skipping ${name} ${RD}$container is not Debian or Ubuntu ${CL} \n"
sleep 1
continue
fi
status=$(pct status $container)
template=$(pct config $container | grep -q "template:" && echo "true" || echo "false")
if [ "$template" == "false" ] && [ "$status" == "status: stopped" ]; then
echo -e "${BL}[Info]${GN} Starting${BL} $container ${CL} \n"
pct start $container
echo -e "${BL}[Info]${GN} Waiting For${BL} $container${CL}${GN} To Start ${CL} \n"
sleep 5
clean_container $container
echo -e "${BL}[Info]${GN} Shutting down${BL} $container ${CL} \n"
pct shutdown $container &
elif [ "$status" == "status: running" ]; then
clean_container $container
fi
for container in $(pct list | awk '{if(NR>1) print $1}'); do
os=$(pct config "$container" | awk '/^ostype/ {print $2}')
if [ "$os" != "debian" ] && [ "$os" != "ubuntu" ]; then
header_info
echo -e "${BL}[Info]${GN} Skipping ${name} ${RD}$container is not Debian or Ubuntu ${CL} \n"
sleep 1
continue
fi
status=$(pct status $container)
template=$(pct config $container | grep -q "template:" && echo "true" || echo "false")
if [ "$template" == "false" ] && [ "$status" == "status: stopped" ]; then
echo -e "${BL}[Info]${GN} Starting${BL} $container ${CL} \n"
pct start $container
echo -e "${BL}[Info]${GN} Waiting For${BL} $container${CL}${GN} To Start ${CL} \n"
sleep 5
clean_container $container
echo -e "${BL}[Info]${GN} Shutting down${BL} $container ${CL} \n"
pct shutdown $container &
elif [ "$status" == "status: running" ]; then
clean_container $container
fi
done
wait
header_info
echo -e "${GN} Finished, Containers Cleaned. ${CL} \n"

View File

@ -34,7 +34,7 @@ while true; do
esac
done
clear
NODE=$(hostname)
TITLE="Containers on node"
while read -r line; do
TAG=$(echo "$line" | awk '{print $1}')
ITEM=$(echo "$line" | awk '{print substr($0,36)}')
@ -44,7 +44,7 @@ while read -r line; do
fi
CTID_MENU+=("$TAG" "$ITEM " "OFF")
done < <(pct list | awk 'NR>1')
excluded_containers=$(whiptail --title "Containers on $NODE" --checklist \
excluded_containers=$(whiptail --title "$TITLE" --checklist \
"\nSelect containers to skip from updates:\n" \
16 $(($MSG_MAX_LENGTH + 23)) 6 \
"${CTID_MENU[@]}" 3>&1 1>&2 2>&3 | tr -d '"') || exit