Обновить install.sh
Add safe stack uninstall and redact public IP
This commit is contained in:
+15
-2
@@ -11,6 +11,7 @@ ADMIN_PASSWORD=""
|
||||
ALLOW_DNS_MISMATCH=0
|
||||
ADOPT_EXISTING=0
|
||||
DRY_RUN=0
|
||||
UNINSTALL=0
|
||||
|
||||
log() { printf '\033[1;34m[DNS]\033[0m %s\n' "$*"; }
|
||||
warn() { printf '\033[1;33m[WARN]\033[0m %s\n' "$*" >&2; }
|
||||
@@ -27,6 +28,7 @@ Usage: install.sh [options]
|
||||
--stack-dir PATH Installation directory (default: /opt/stacks/adguard-doh)
|
||||
--allow-dns-mismatch Continue when DNS does not yet point to this VPS
|
||||
--adopt-existing Adopt a compatible unmarked stack directory
|
||||
--uninstall Stop and remove this stack; preserve its files
|
||||
--check Validate only; do not write or start containers
|
||||
-h, --help Show this help
|
||||
|
||||
@@ -44,6 +46,7 @@ while (($#)); do
|
||||
--stack-dir) STACK_DIR="${2:-}"; shift 2 ;;
|
||||
--allow-dns-mismatch) ALLOW_DNS_MISMATCH=1; shift ;;
|
||||
--adopt-existing) ADOPT_EXISTING=1; shift ;;
|
||||
--uninstall) UNINSTALL=1; shift ;;
|
||||
--check) DRY_RUN=1; shift ;;
|
||||
-h|--help) usage; exit 0 ;;
|
||||
*) die "Unknown option: $1" ;;
|
||||
@@ -52,6 +55,16 @@ done
|
||||
|
||||
[[ ${EUID:-$(id -u)} -eq 0 ]] || die "Run as root (sudo)."
|
||||
|
||||
if ((UNINSTALL)); then
|
||||
[[ -f "$STACK_DIR/.berloga-adguard-installer" ]] || die "No Berloga-managed AdGuard stack found at $STACK_DIR. Nothing was changed."
|
||||
if command -v docker >/dev/null 2>&1 && [[ -f "$STACK_DIR/compose.yaml" ]]; then
|
||||
docker compose -f "$STACK_DIR/compose.yaml" --project-name "$PROJECT_NAME" down --remove-orphans
|
||||
fi
|
||||
log "AdGuard DoH containers and network removed."
|
||||
log "Configuration and backups were preserved at $STACK_DIR. Docker and other stacks were not changed."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
read_tty() {
|
||||
local prompt="$1" value=""
|
||||
[[ -r /dev/tty ]] || die "No terminal available; pass domains as arguments."
|
||||
@@ -112,9 +125,9 @@ for domain in "$DOH_DOMAIN" "$ADMIN_DOMAIN"; do
|
||||
resolved="$(getent ahostsv4 "$domain" 2>/dev/null | awk 'NR==1{print $1}')"
|
||||
if [[ -z "$resolved" || (-n "$PUBLIC_IP" && "$resolved" != "$PUBLIC_IP") ]]; then
|
||||
if ((ALLOW_DNS_MISMATCH)); then
|
||||
warn "$domain currently resolves to '${resolved:-nothing}', VPS public IP is '${PUBLIC_IP:-unknown}'. Caddy will retry certificate issuance."
|
||||
warn "$domain does not currently resolve to this VPS. Caddy will retry certificate issuance."
|
||||
else
|
||||
die "$domain does not point to this VPS (${PUBLIC_IP:-unknown}). Add A records first or use --allow-dns-mismatch. Nothing was changed."
|
||||
die "$domain does not point to this VPS. Add A records first or use --allow-dns-mismatch. Nothing was changed."
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user