Files
scripts/setup-locale-lxcs.sh

60 lines
1.5 KiB
Bash

#!/usr/bin/env bash
set -u
echo
echo "========================================"
echo " Debian Locale Configuration Script"
echo "========================================"
echo
for CTID in $(pct list | awk 'NR>1 {print $1}'); do
STATUS=$(pct status "$CTID" 2>/dev/null | awk '{print $2}')
echo "----------------------------------------"
echo "Container: $CTID"
echo "Status: $STATUS"
if [[ "$STATUS" != "running" ]]; then
echo "SKIP: Container is not running."
continue
fi
OS_ID=$(pct exec "$CTID" -- sh -c \
'. /etc/os-release 2>/dev/null && echo "$ID"' \
2>/dev/null || true)
OS_NAME=$(pct exec "$CTID" -- sh -c \
'. /etc/os-release 2>/dev/null && echo "$PRETTY_NAME"' \
2>/dev/null || true)
echo "OS: ${OS_NAME:-Unknown}"
if [[ "$OS_ID" != "debian" ]]; then
echo "SKIP: Not Debian."
continue
fi
echo "Configuring en_US.UTF-8..."
if ! pct exec "$CTID" -- sh -c "
sed -i 's/^# *en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen &&
locale-gen &&
update-locale LANG=en_US.UTF-8
"; then
echo "ERROR: Locale configuration failed in container $CTID."
continue
fi
echo "OK: Locale configured."
echo "Current locale:"
pct exec "$CTID" -- sh -c 'locale | grep -E "^LANG=" || true'
echo
done
echo "========================================"
echo " Finished"
echo "========================================"