diff --git a/README.md b/README.md index a955a4b..8c92845 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,10 @@ curl ... | sudo bash -s -- --unattended --dns1 9.9.9.9 --dns2 149.112.112.112 ### Set Admin Password ```bash +# Pi-hole v6+ +pihole setpassword + +# Pi-hole v5 (legacy) pihole -a -p ``` @@ -185,7 +189,7 @@ journalctl -u pihole-FTL -f # Systemd journal ### Reset admin password ```bash -pihole -a -p +pihole setpassword ``` ## Uninstall diff --git a/install.sh b/install.sh index cfa3c08..74318f1 100644 --- a/install.sh +++ b/install.sh @@ -498,12 +498,19 @@ configure_firewall() { set_admin_password() { if [ -n "$ADMIN_PASSWORD" ]; then log "Setting admin password..." - pihole -a -p "$ADMIN_PASSWORD" - success "Admin password set" + # Pi-hole v6 uses 'setpassword' instead of '-a -p' + if pihole setpassword "$ADMIN_PASSWORD" 2>/dev/null; then + success "Admin password set" + elif pihole -a -p "$ADMIN_PASSWORD" 2>/dev/null; then + success "Admin password set (legacy)" + else + warn "Could not set password automatically" + fi elif [ "$UNATTENDED" != true ]; then echo "" echo "Set your Pi-hole admin password:" - pihole -a -p + # Try v6 syntax first, fallback to legacy + pihole setpassword 2>/dev/null || pihole -a -p fi } @@ -581,7 +588,7 @@ case "${1:-help}" in echo "Backup created: $backup_dir/pihole_backup_$timestamp.tar.gz" ;; password) - pihole -a -p + pihole setpassword 2>/dev/null || pihole -a -p ;; *) echo "Pi-hole Management Helper"