- Ajout des droits pfx

This commit is contained in:
Frogg 2026-05-09 21:30:29 +02:00
parent 821583fb2d
commit 1397607a10
1 changed files with 28 additions and 30 deletions

View File

@ -650,42 +650,40 @@ do_deb_sys_cert_install(){
# 1. On s'assure que le groupe technique existe
groupadd -f ssl-cert
# 2. On boucle sur la liste des services de ta config
for SVC in $CONFIG_DEB_INSTALL_DEFAULT_CA_SERVICES; do
for SVC in $CONFIG_DEB_INSTALL_DEFAULT_CA_SERVICES; do
# TEST D'EXISTENCE : On vérifie si le fichier .service existe
if systemctl list-unit-files "${SVC}.service" >/dev/null 2>&1; then
UNIT="${SVC}.service"
# Si le service existe, on vérifie s'il est actif
if systemctl is-active --quiet "$SVC"; then
# Récupération de l'utilisateur
PID=$(pgrep -f "$SVC" | head -n1)
if [ -n "$PID" ]; then
SVC_USER=$(ps -o user= -p "$PID" | tr -d ' ')
# Vérifie réellement si le service existe (runtime + installé)
if ! systemctl list-unit-files --type=service | grep -q "^${UNIT}"; then
continue
fi
if [ -n "$SVC_USER" ] && [ "$SVC_USER" != "root" ]; then
msg_info "🔧 Configuration de $SVC (Utilisateur : $SVC_USER)"
# Vérifie s'il est actif
if systemctl is-active --quiet "$UNIT"; then
# Ajout au groupe ssl-cert
usermod -aG ssl-cert "$SVC_USER"
PID=$(pgrep -f "$SVC" | head -n1)
# Application des droits sur les fichiers (Clé et PFX)
chown root:ssl-cert /etc/ssl/wildcard/server.key /etc/ssl/wildcard/server.pfx
chmod 640 /etc/ssl/wildcard/server.key /etc/ssl/wildcard/server.pfx
chmod 644 /etc/ssl/wildcard/server.crt
if [ -n "$PID" ]; then
SVC_USER=$(ps -o user= -p "$PID" | tr -d ' ')
# Redémarrage réel
systemctl restart "$SVC"
msg_success "Service $SVC redémarré avec succès."
fi
fi
fi
else
# SI LE SERVICE N'EXISTE PAS : On ne fait rien.
# Le script passe au suivant sans générer d'erreur dans la console.
continue
fi
done
if [ -n "$SVC_USER" ] && [ "$SVC_USER" != "root" ]; then
msg_info "🔧 Configuration de $SVC (Utilisateur : $SVC_USER)"
usermod -aG ssl-cert "$SVC_USER"
chown root:ssl-cert /etc/ssl/wildcard/server.key /etc/ssl/wildcard/server.pfx
chmod 640 /etc/ssl/wildcard/server.key /etc/ssl/wildcard/server.pfx
chmod 644 /etc/ssl/wildcard/server.crt
systemctl restart "$UNIT"
msg_success "Service $SVC redémarré avec succès."
fi
fi
fi
done
# ==================================================================
# [6/6] PLANIFICATION & GÉNÉRATION PFX