Update setup-apt-cacher-lxcs.sh
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
cat > /root/setup-apt-cacher-lxcs.sh <<'EOF'
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -u
|
||||
@@ -36,7 +35,6 @@ for CTID in $(pct list | awk 'NR>1 {print $1}'); do
|
||||
continue
|
||||
fi
|
||||
|
||||
# Detect operating system
|
||||
OS_ID=$(pct exec "$CTID" -- sh -c \
|
||||
'. /etc/os-release 2>/dev/null && echo "$ID"' \
|
||||
2>/dev/null || true)
|
||||
@@ -54,14 +52,12 @@ for CTID in $(pct list | awk 'NR>1 {print $1}'); do
|
||||
|
||||
echo "Configuring Apt-Cacher-NG..."
|
||||
|
||||
# Backup existing configuration if there is one
|
||||
pct exec "$CTID" -- sh -c "
|
||||
if [ -f '$PROXY_FILE' ]; then
|
||||
cp '$PROXY_FILE' '${PROXY_FILE}.backup-\$(date +%Y%m%d-%H%M%S)'
|
||||
fi
|
||||
"
|
||||
|
||||
# Create proxy configuration
|
||||
pct exec "$CTID" -- sh -c "cat > '$PROXY_FILE' <<'APTCONFIG'
|
||||
Acquire::http::Proxy \"http://${ACNG_SERVER}:${ACNG_PORT}\";
|
||||
Acquire::https::Proxy \"DIRECT\";
|
||||
@@ -82,9 +78,8 @@ APTCONFIG
|
||||
if [[ "$RUN_UPDATE" =~ ^[Yy]$ ]]; then
|
||||
echo
|
||||
echo "Running apt update..."
|
||||
pct exec "$CTID" -- apt-get update
|
||||
|
||||
if [[ $? -eq 0 ]]; then
|
||||
if pct exec "$CTID" -- apt-get update; then
|
||||
echo "OK: apt update completed."
|
||||
else
|
||||
echo "WARNING: apt update failed in container $CTID."
|
||||
|
||||
Reference in New Issue
Block a user