Compare commits

...
2 Commits
5 changed files with 51 additions and 20 deletions

No files matched your search

+5 -3
View File
@@ -61,7 +61,8 @@ apt-get install -y --no-install-recommends \
acl \
ffmpeg \
rsync \
sox
sox \
sshpass
# Vérification et installation d'Asterisk
echo -e "${C_GREEN} -> Installation du moteur Asterisk PBX...${C_RESET}"
@@ -191,14 +192,15 @@ www-data ALL=(ALL) NOPASSWD: /usr/sbin/asterisk, /usr/sbin/nginx, /usr/bin/syste
EOF
chmod 0440 /etc/sudoers.d/nexus-pbx
# Autorisation d'écriture systemd pour PHP-FPM (Debian 12/13 ProtectSystem=full)
# Autorisation d'écriture systemd pour PHP-FPM (Debian 12/13 ProtectSystem)
for fpm_svc in /lib/systemd/system/php*-fpm.service /usr/lib/systemd/system/php*-fpm.service; do
if [ -f "$fpm_svc" ]; then
svc_name=$(basename "$fpm_svc")
mkdir -p "/etc/systemd/system/${svc_name}.d"
cat << 'EOF_OVERRIDE' > "/etc/systemd/system/${svc_name}.d/override.conf"
[Service]
ReadWritePaths=/etc/asterisk /etc/fail2ban /etc/nginx /var/log /var/lib/asterisk /var/spool/asterisk
ProtectSystem=false
ReadWritePaths=/etc/asterisk /etc/fail2ban /etc/nginx /var/log /var/lib/asterisk /var/spool/asterisk /var/www /usr/local/bin /etc/sudoers.d
EOF_OVERRIDE
fi
done
+4 -3
View File
@@ -16,8 +16,8 @@ cd /var/www/nexus-pbx
git fetch origin main
git reset --hard origin/main
echo "-> Installation des dépendances système indispensables (ACL, ffmpeg, rsync, sox)..."
which ffmpeg >/dev/null 2>&1 && which rsync >/dev/null 2>&1 && which setfacl >/dev/null 2>&1 || (apt-get update -y && apt-get install -y --no-install-recommends acl ffmpeg rsync sox)
echo "-> Installation des dépendances système indispensables (ACL, ffmpeg, rsync, sox, sshpass)..."
which ffmpeg >/dev/null 2>&1 && which rsync >/dev/null 2>&1 && which setfacl >/dev/null 2>&1 && which sshpass >/dev/null 2>&1 || (apt-get update -y && apt-get install -y --no-install-recommends acl ffmpeg rsync sox sshpass)
echo "-> Création des dossiers et des fichiers de journalisation..."
mkdir -p /etc/fail2ban/filter.d /etc/asterisk /var/log/asterisk /var/log/nexus-pbx /var/www/nexus-pbx/storage/backups
@@ -96,7 +96,8 @@ for fpm_svc in /lib/systemd/system/php*-fpm.service /usr/lib/systemd/system/php*
mkdir -p "/etc/systemd/system/${svc_name}.d"
cat << 'EOF_OVERRIDE' > "/etc/systemd/system/${svc_name}.d/override.conf"
[Service]
ReadWritePaths=/etc/asterisk /etc/fail2ban /etc/nginx /var/log /var/lib/asterisk /var/spool/asterisk
ProtectSystem=false
ReadWritePaths=/etc/asterisk /etc/fail2ban /etc/nginx /var/log /var/lib/asterisk /var/spool/asterisk /var/www /usr/local/bin /etc/sudoers.d
EOF_OVERRIDE
fi
done
+13 -9
View File
@@ -93,24 +93,28 @@ echo -e "${C_GREEN} ✓ Sauvegarde de sécurité créée : $(basename "$BACKUP_
# 2. Application des derniers fichiers de code Git
echo -e "${C_GRAY}[2/6] Déploiement des nouveaux fichiers de code...${C_RESET}"
git reset --hard "${GIT_REMOTE}/${GIT_BRANCH}"
chown -R www-data:asterisk "$APP_DIR"
chown -R www-data:asterisk "$APP_DIR" 2>/dev/null || true
chmod 2775 "$APP_DIR/storage" "$APP_DIR/storage/backups" "$APP_DIR/storage/sounds" 2>/dev/null || true
chmod +x "$APP_DIR/scripts/update.sh" "$APP_DIR/scripts/nexus-firewall" "$APP_DIR/scripts/nexus-banner.sh" 2>/dev/null || true
ln -sf "$APP_DIR/scripts/update.sh" /usr/local/bin/nexus-update
ln -sf "$APP_DIR/scripts/nexus-firewall" /usr/local/bin/nexus-firewall
ln -sf "$APP_DIR/scripts/nexus-banner.sh" /usr/local/bin/nexus-banner
# Mise à jour des privilèges sudoers (www-data)
cat << 'EOF_SUDO' > /etc/sudoers.d/nexus-pbx
# Liens symboliques CLI (non-bloquants si exécuté sous sandbox PHP ProtectSystem)
ln -sf "$APP_DIR/scripts/update.sh" /usr/local/bin/nexus-update 2>/dev/null || true
ln -sf "$APP_DIR/scripts/nexus-firewall" /usr/local/bin/nexus-firewall 2>/dev/null || true
ln -sf "$APP_DIR/scripts/nexus-banner.sh" /usr/local/bin/nexus-banner 2>/dev/null || true
# Mise à jour des privilèges sudoers (www-data) si accessible en écriture
if [ -w /etc/sudoers.d ]; then
cat << 'EOF_SUDO' > /etc/sudoers.d/nexus-pbx 2>/dev/null || true
www-data ALL=(ALL) NOPASSWD: /usr/sbin/asterisk, /usr/sbin/nginx, /usr/bin/systemctl, /usr/bin/fail2ban-client, /bin/fail2ban-client, /var/www/nexus-pbx/scripts/nexus-firewall, /usr/bin/certbot, /usr/sbin/nft, /usr/sbin/iptables, /var/www/nexus-pbx/scripts/update.sh, /usr/local/bin/nexus-update
EOF_SUDO
chmod 0440 /etc/sudoers.d/nexus-pbx
chmod 0440 /etc/sudoers.d/nexus-pbx 2>/dev/null || true
fi
# 3. Vérification des dépendances Debian
echo -e "${C_GRAY}[3/6] Vérification des composants et outils système...${C_RESET}"
which ffmpeg >/dev/null 2>&1 && which rsync >/dev/null 2>&1 && which sox >/dev/null 2>&1 || {
which ffmpeg >/dev/null 2>&1 && which rsync >/dev/null 2>&1 && which sox >/dev/null 2>&1 && which sshpass >/dev/null 2>&1 || {
echo -e " -> Installation de paquets complémentaires..."
apt-get update -y -qq && apt-get install -y -qq --no-install-recommends acl ffmpeg rsync sox
(apt-get update -y -qq && apt-get install -y -qq --no-install-recommends acl ffmpeg rsync sox sshpass) 2>/dev/null || true
}
# 4. Exécution des migrations SQLite et régénération Dialplan
+24
View File
@@ -659,12 +659,24 @@ class BackupManager
// MÉTHODES PRIVÉES / UTILITAIRES
// =========================================================================
private static function isSshpassInstalled(): bool
{
return file_exists('/usr/bin/sshpass') || !empty(trim((string)shell_exec('which sshpass 2>/dev/null')));
}
private static function runSshCommand(string $host, int $port, string $user, string $authType, string $password, string $cmd): array
{
$sshOptions = "-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=8 -p " . (int)$port;
$target = escapeshellarg("{$user}@{$host}");
if ($authType === 'password') {
if (!self::isSshpassInstalled()) {
return [
'exit_code' => 1,
'output' => '',
'error' => "Le paquet 'sshpass' n'est pas installé sur le système pour l'authentification SSH par mot de passe. Installez-le avec : apt install -y sshpass",
];
}
$fullCmd = "sshpass -p " . escapeshellarg($password) . " ssh {$sshOptions} {$target} " . escapeshellarg($cmd);
} else {
$fullCmd = "ssh {$sshOptions} {$target} " . escapeshellarg($cmd);
@@ -713,6 +725,12 @@ class BackupManager
$src = escapeshellarg($localFile);
if ($authType === 'password') {
if (!self::isSshpassInstalled()) {
return [
'success' => false,
'message' => "Le paquet 'sshpass' n'est pas installé sur le système pour l'authentification SSH par mot de passe. Installez-le avec : apt install -y sshpass",
];
}
$scpCmd = "sshpass -p " . escapeshellarg($password) . " scp {$scpOptions} {$src} {$dest}";
} else {
$scpCmd = "scp {$scpOptions} {$src} {$dest}";
@@ -742,6 +760,12 @@ class BackupManager
$dest = escapeshellarg($localDest);
if ($authType === 'password') {
if (!self::isSshpassInstalled()) {
return [
'success' => false,
'message' => "Le paquet 'sshpass' n'est pas installé sur le système pour l'authentification SSH par mot de passe. Installez-le avec : apt install -y sshpass",
];
}
$scpCmd = "sshpass -p " . escapeshellarg($password) . " scp {$scpOptions} {$src} {$dest}";
} else {
$scpCmd = "scp {$scpOptions} {$src} {$dest}";
+5 -5
View File
@@ -1,12 +1,12 @@
{
"version": "1.3.3",
"version": "1.3.5",
"codename": "Helios",
"release_date": "2026-11-04",
"min_php_version": "8.2",
"changelog": [
"Autorisation sudoers www-data automatique pour les mises à jour 1-clic depuis l'interface Web",
"Création systématique du lien symbolique CLI nexus-update à l'installation et à la mise à jour",
"Suppression complète des données de démonstration au déploiement (base 100% propre)",
"Résolution du bug de réapparition intempestive des postes, groupes, IVR, paging et routes supprimés"
"Désactivation du bac à sable ProtectSystem=full sur PHP-FPM pour autoriser les écritures système lors des mises à jour",
"Sécurisation non-bloquante de la création des liens symboliques /usr/local/bin/ dans le script de mise à jour",
"Ajout automatique du paquet sshpass dans install.sh et le processus de mise à jour pour les sauvegardes distantes",
"Autorisation sudoers www-data automatique pour les mises à jour 1-clic depuis l'interface Web"
]
}