diff --git a/RebuildBdd/Checkup/check-postgresql.sh b/RebuildBdd/Checkup/check-postgresql.sh index faac0a0..ab9b0d1 100755 --- a/RebuildBdd/Checkup/check-postgresql.sh +++ b/RebuildBdd/Checkup/check-postgresql.sh @@ -70,12 +70,12 @@ if ! require_cmd "$SUDO_BIN"; then fail "sudo absent sur la cible" fi -if ! "$SUDO_BIN" -n /usr/bin/systemctl --version >/dev/null 2>&1; then - fail "sudo non interactif indisponible pour systemctl" +if ! "$SUDO_BIN" /usr/bin/systemctl --version >/dev/null 2>&1; then + fail "sudo indisponible pour systemctl" fi -if ! "$SUDO_BIN" -n -u postgres /usr/bin/psql -d postgres -c "SELECT 1;" >/dev/null 2>&1; then - fail "sudo -n -u postgres indisponible" +if ! "$SUDO_BIN" -u postgres /usr/bin/psql -d postgres -c "SELECT 1;" >/dev/null 2>&1; then + fail "sudo -u postgres indisponible" fi if [[ ! "$PGPORT" =~ ^[0-9]+$ ]]; then @@ -88,37 +88,37 @@ if ! require_cmd psql || ! require_cmd pg_restore || ! require_cmd createdb || ! [[ "${AUTO_INSTALL_POSTGRES,,}" == "yes" ]] || fail "PostgreSQL absent et AUTO_INSTALL_POSTGRES=no" log "PostgreSQL absent : installation en cours..." - "$SUDO_BIN" -n apt update >/dev/null 2>&1 || fail "échec de apt update" - "$SUDO_BIN" -n apt install -y $POSTGRES_PACKAGE_LIST >/dev/null 2>&1 || fail "échec de l'installation PostgreSQL" + "$SUDO_BIN" apt update >/dev/null 2>&1 || fail "échec de apt update" + "$SUDO_BIN" apt install -y $POSTGRES_PACKAGE_LIST >/dev/null 2>&1 || fail "échec de l'installation PostgreSQL" POSTGRES_INSTALLED="yes" log "Installation PostgreSQL terminée." else log "PostgreSQL déjà installé." fi -if ! "$SUDO_BIN" -n systemctl is-active --quiet "$POSTGRES_SERVICE_NAME"; then +if ! "$SUDO_BIN" systemctl is-active --quiet "$POSTGRES_SERVICE_NAME"; then log "Démarrage du service PostgreSQL..." - "$SUDO_BIN" -n systemctl start "$POSTGRES_SERVICE_NAME" >/dev/null 2>&1 || fail "impossible de démarrer PostgreSQL" + "$SUDO_BIN" systemctl start "$POSTGRES_SERVICE_NAME" >/dev/null 2>&1 || fail "impossible de démarrer PostgreSQL" else log "Service PostgreSQL déjà actif." fi log "Vérification de la disponibilité de PostgreSQL..." for _ in {1..20}; do - if "$SUDO_BIN" -n -u postgres psql -d postgres -c "SELECT 1;" >/dev/null 2>&1; then + if "$SUDO_BIN" -u postgres psql -d postgres -c "SELECT 1;" >/dev/null 2>&1; then log "PostgreSQL répond correctement." break fi sleep 1 done -if ! "$SUDO_BIN" -n -u postgres psql -d postgres -c "SELECT 1;" >/dev/null 2>&1; then +if ! "$SUDO_BIN" -u postgres psql -d postgres -c "SELECT 1;" >/dev/null 2>&1; then fail "PostgreSQL ne répond pas correctement" fi if [[ "${AUTO_CREATE_PGUSER,,}" == "yes" ]]; then ROLE_EXISTS="$( - "$SUDO_BIN" -n -u postgres psql -d postgres -tAc \ + "$SUDO_BIN" -u postgres psql -d postgres -tAc \ "SELECT 1 FROM pg_roles WHERE rolname='${PGUSER//\'/\'\'}'" 2>/dev/null || true )" @@ -130,7 +130,7 @@ if [[ "${AUTO_CREATE_PGUSER,,}" == "yes" ]]; then ROLE_ATTRIBUTES="LOGIN SUPERUSER CREATEDB CREATEROLE" fi - "$SUDO_BIN" -n -u postgres psql -d postgres -c \ + "$SUDO_BIN" -u postgres psql -d postgres -c \ "CREATE ROLE \"${PGUSER}\" WITH ${ROLE_ATTRIBUTES} PASSWORD '${PGPASSWORD//\'/\'\'}';" \ >/dev/null 2>&1 || fail "échec de création du rôle ${PGUSER}" @@ -144,4 +144,4 @@ if ! psql -h "$PGHOST" -p "$PGPORT" -U "$PGUSER" -d postgres -c "SELECT 1;" >/de fail "connexion PostgreSQL locale impossible avec PGUSER=${PGUSER}" fi -log "Check PostgreSQL terminé avec succès." \ No newline at end of file +log "Check PostgreSQL terminé avec succès." diff --git a/RebuildBdd/Checkup/check-target-readiness.sh b/RebuildBdd/Checkup/check-target-readiness.sh index 0bc61e8..3e9ebc6 100755 --- a/RebuildBdd/Checkup/check-target-readiness.sh +++ b/RebuildBdd/Checkup/check-target-readiness.sh @@ -229,8 +229,8 @@ install_sudoers_if_allowed() { return 0 fi - if ! sudo -n true >/dev/null 2>&1; then - fail "AUTO_CONFIGURE_SUDOERS=yes mais sudo -n n'est pas disponible ; configuration initiale manuelle requise" + if ! sudo true >/dev/null 2>&1; then + fail "AUTO_CONFIGURE_SUDOERS=yes mais sudo n'est pas disponible ; configuration initiale manuelle requise" fi require_cmd visudo @@ -260,10 +260,10 @@ EOF } check_sudo_non_interactive() { - sudo -n true >/dev/null 2>&1 || \ - fail "sudo non interactif indisponible pour ${USER}" + sudo true >/dev/null 2>&1 || \ + fail "sudo indisponible pour ${USER}" - log "sudo non interactif validé." + log "sudo validé." } run_postgresql_check() { @@ -278,7 +278,7 @@ run_postgresql_check() { --non-interactive \ >>"$LOG_FILE" 2>&1 || fail "échec de préparation PostgreSQL" - sudo -n -u postgres true >/dev/null 2>&1 || fail "sudo -n -u postgres indisponible après préparation PostgreSQL" + sudo -u postgres true >/dev/null 2>&1 || fail "sudo -u postgres indisponible après préparation PostgreSQL" log "Préparation PostgreSQL validée." } @@ -315,4 +315,4 @@ check_sudo_non_interactive run_postgresql_check log "Machine cible prête pour le rebuild." -print_json_and_exit "success" "machine cible prête" 0 \ No newline at end of file +print_json_and_exit "success" "machine cible prête" 0 diff --git a/RebuildBdd/bootstrap-target-host.sh b/RebuildBdd/bootstrap-target-host.sh index 339a701..82b429a 100755 --- a/RebuildBdd/bootstrap-target-host.sh +++ b/RebuildBdd/bootstrap-target-host.sh @@ -260,8 +260,8 @@ run_root() { fi if command -v sudo >/dev/null 2>&1; then - sudo -n \"\$@\" || { - echo 'sudo -n indisponible pour le bootstrap' >&2 + sudo \"\$@\" || { + echo 'sudo indisponible pour le bootstrap' >&2 exit 1 } return 0 @@ -403,8 +403,8 @@ run_root() { fi if command -v sudo >/dev/null 2>&1; then - sudo -n \"\$@\" || { - echo 'sudo -n indisponible pour installer sudoers' >&2 + sudo \"\$@\" || { + echo 'sudo indisponible pour installer sudoers' >&2 exit 1 } return 0 @@ -484,15 +484,15 @@ command -v sudo >/dev/null 2>&1 || { echo 'sudo absent sur la cible' >&2 exit 1 } -sudo -n /usr/bin/systemctl --version >/dev/null 2>&1 || { - echo 'sudo -n indisponible pour systemctl' >&2 +sudo /usr/bin/systemctl --version >/dev/null 2>&1 || { + echo 'sudo indisponible pour systemctl' >&2 exit 1 } " -log "Validation initiale de sudo -n" +log "Validation initiale de sudo" ssh "${SSH_OPTS[@]}" "$REMOTE" "$REMOTE_VALIDATE_SUDO_ROOT_CMD" \ - || fail "sudo -n invalide sur la cible" + || fail "sudo invalide sur la cible" REMOTE_RUN_CHECK_PG_CMD=" set -euo pipefail @@ -516,14 +516,14 @@ ssh "${SSH_OPTS[@]}" "$REMOTE" "$REMOTE_RUN_CHECK_PG_CMD" \ REMOTE_VALIDATE_SUDO_POSTGRES_CMD=" set -euo pipefail -sudo -n -u postgres /usr/bin/psql -d postgres -c 'SELECT 1;' >/dev/null 2>&1 || { - echo 'sudo -n -u postgres indisponible après préparation PostgreSQL' >&2 +sudo -u postgres /usr/bin/psql -d postgres -c 'SELECT 1;' >/dev/null 2>&1 || { + echo 'sudo -u postgres indisponible après préparation PostgreSQL' >&2 exit 1 } " -log "Validation finale de sudo -n -u postgres" +log "Validation finale de sudo -u postgres" ssh "${SSH_OPTS[@]}" "$REMOTE" "$REMOTE_VALIDATE_SUDO_POSTGRES_CMD" \ - || fail "sudo -n -u postgres invalide sur la cible" + || fail "sudo -u postgres invalide sur la cible" success "bootstrap initial terminé pour ${TARGET_NAME}"