mirror of
https://github.com/tteck/Proxmox.git
synced 2024-11-30 02:14:34 +01:00
Update clean-lxcs.sh
tweak
This commit is contained in:
parent
15f5285120
commit
1dc63002ad
@ -6,8 +6,8 @@
|
|||||||
# https://github.com/tteck/Proxmox/raw/main/LICENSE
|
# https://github.com/tteck/Proxmox/raw/main/LICENSE
|
||||||
|
|
||||||
function header_info() {
|
function header_info() {
|
||||||
clear
|
clear
|
||||||
cat <<"EOF"
|
cat <<"EOF"
|
||||||
________ __ _ ________
|
________ __ _ ________
|
||||||
/ ____/ /__ ____ _____ / / | |/ / ____/
|
/ ____/ /__ ____ _____ / / | |/ / ____/
|
||||||
/ / / / _ \/ __ `/ __ \ / / | / /
|
/ / / / _ \/ __ `/ __ \ / / | / /
|
||||||
@ -34,7 +34,6 @@ while true; do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
clear
|
clear
|
||||||
containers=$(pct list | tail -n +2 | cut -f1 -d' ')
|
|
||||||
function clean_container() {
|
function clean_container() {
|
||||||
container=$1
|
container=$1
|
||||||
header_info
|
header_info
|
||||||
@ -43,7 +42,7 @@ function clean_container() {
|
|||||||
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"
|
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 $containers; do
|
for container in $(pct list | awk '{if(NR>1) print $1}'); do
|
||||||
os=$(pct config "$container" | awk '/^ostype/ {print $2}')
|
os=$(pct config "$container" | awk '/^ostype/ {print $2}')
|
||||||
if [ "$os" != "debian" ] && [ "$os" != "ubuntu" ]; then
|
if [ "$os" != "debian" ] && [ "$os" != "ubuntu" ]; then
|
||||||
header_info
|
header_info
|
||||||
@ -53,16 +52,16 @@ for container in $containers; do
|
|||||||
fi
|
fi
|
||||||
status=$(pct status $container)
|
status=$(pct status $container)
|
||||||
template=$(pct config $container | grep -q "template:" && echo "true" || echo "false")
|
template=$(pct config $container | grep -q "template:" && echo "true" || echo "false")
|
||||||
if [ "$template" == "false" ] && [ "$status" == "status: stopped" ]; then
|
if [ "$template" == "false" ] && [ "$status" == "status: stopped" ]; then
|
||||||
echo -e "${BL}[Info]${GN} Starting${BL} $container ${CL} \n"
|
echo -e "${BL}[Info]${GN} Starting${BL} $container ${CL} \n"
|
||||||
pct start $container
|
pct start $container
|
||||||
echo -e "${BL}[Info]${GN} Waiting For${BL} $container${CL}${GN} To Start ${CL} \n"
|
echo -e "${BL}[Info]${GN} Waiting For${BL} $container${CL}${GN} To Start ${CL} \n"
|
||||||
sleep 5
|
sleep 5
|
||||||
clean_container $container
|
clean_container $container
|
||||||
echo -e "${BL}[Info]${GN} Shutting down${BL} $container ${CL} \n"
|
echo -e "${BL}[Info]${GN} Shutting down${BL} $container ${CL} \n"
|
||||||
pct shutdown $container &
|
pct shutdown $container &
|
||||||
elif [ "$status" == "status: running" ]; then
|
elif [ "$status" == "status: running" ]; then
|
||||||
clean_container $container
|
clean_container $container
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
wait
|
wait
|
||||||
|
Loading…
Reference in New Issue
Block a user