mirror of https://github.com/tteck/Proxmox.git
Compare commits
6 Commits
858a00176d
...
b3777abadc
Author | SHA1 | Date |
---|---|---|
|
b3777abadc | |
|
544f163e15 | |
|
b8ebc36c51 | |
|
9cfa051700 | |
|
4362b74a34 | |
|
fb57234263 |
|
@ -4,6 +4,13 @@
|
|||
|
||||
- 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
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
<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 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>
|
||||
<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>
|
||||
|
||||
<h1><p align="center"><a href="https://tteck.github.io/Proxmox/">Proxmox VE Helper Scripts</a></p></h1>
|
||||
<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><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"> Proxmox® is a registered trademark of Proxmox Server Solutions GmbH. </div></sub>
|
||||
|
|
|
@ -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 all LXC Containers. Proceed(y/n)?" yn
|
||||
read -p "This Will Clean logs, cache and update apt lists on selected LXC Containers. Proceed(y/n)?" yn
|
||||
case $yn in
|
||||
[Yy]*) break ;;
|
||||
[Nn]*) exit ;;
|
||||
|
@ -33,6 +33,21 @@ 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
|
||||
|
@ -40,8 +55,12 @@ 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
|
||||
|
@ -49,6 +68,7 @@ for container in $(pct list | awk '{if(NR>1) print $1}'); do
|
|||
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
|
||||
|
@ -62,7 +82,9 @@ for container in $(pct list | awk '{if(NR>1) print $1}'); do
|
|||
elif [ "$status" == "status: running" ]; then
|
||||
clean_container $container
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
wait
|
||||
header_info
|
||||
echo -e "${GN} Finished, Containers Cleaned. ${CL} \n"
|
||||
|
|
|
@ -34,7 +34,7 @@ while true; do
|
|||
esac
|
||||
done
|
||||
clear
|
||||
TITLE="Containers on node"
|
||||
NODE=$(hostname)
|
||||
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 "$TITLE" --checklist \
|
||||
excluded_containers=$(whiptail --title "Containers on $NODE" --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
|
||||
|
|
Loading…
Reference in New Issue