Compare commits

...
Author SHA1 Message Date
MickLesk a2769df938 Skip a container that will not start instead of ending fstrim
A stopped container the user chose to start for the trim ran pct start
under set -e, so one that failed to start (exit 255) ended the run and
the remaining containers were never trimmed. Report it with pct start's
output, log it and go on; the summary lists the containers left out.
2026-11-20 17:03:51 +01:00
+11 -1
View File
@@ -141,6 +141,7 @@ function trim_container() {
sleep 0.5
}
NOT_STARTED=()
for LINE in "${CTLINES[@]}"; do
CTID=$(awk '{print $1}' <<<"$LINE")
STATUS=$(awk '{print $2}' <<<"$LINE")
@@ -161,7 +162,13 @@ for LINE in "${CTLINES[@]}"; do
if [[ -n "${WAS_STOPPED[$CTID]:-}" ]]; then
header_info
echo -e "${BL}[Info]${GN} Starting $CTID ($NAME) for trim...${CL}"
pct start "$CTID"
if ! start_output=$(pct start "$CTID" 2>&1); then
echo -e "${RD}$CTID ($NAME) did not start, skipping it: ${start_output}${CL}"
echo "$(date '+%Y-%m-%d %H:%M:%S') | CTID=$CTID | Name=$NAME | skipped, did not start: ${start_output//$'\n'/ }" >>"$LOGFILE"
NOT_STARTED+=("$CTID ($NAME)")
sleep 1
continue
fi
sleep 2
else
header_info
@@ -189,6 +196,9 @@ for LINE in "${CTLINES[@]}"; do
done
header_info
if [ ${#NOT_STARTED[@]} -gt 0 ]; then
echo -e "${RD}Not trimmed, did not start: ${NOT_STARTED[*]}${CL}\n"
fi
echo -e "${GN}Finished, LXC Containers Trimmed.${CL} \n"
echo -e "${BL}If you want to see the complete log: cat $LOGFILE${CL}"
exit 0