Compare commits

...
2 Commits
5 changed files with 49 additions and 13 deletions

No files matched your search

+5 -3
View File
@@ -61,7 +61,8 @@ apt-get install -y --no-install-recommends \
acl \ acl \
ffmpeg \ ffmpeg \
rsync \ rsync \
sox sox \
sshpass
# Vérification et installation d'Asterisk # Vérification et installation d'Asterisk
echo -e "${C_GREEN} -> Installation du moteur Asterisk PBX...${C_RESET}" echo -e "${C_GREEN} -> Installation du moteur Asterisk PBX...${C_RESET}"
@@ -187,7 +188,7 @@ setfacl -R -d -m u:www-data:rwx,g:asterisk:rwx /etc/asterisk /var/lib/asterisk/s
# Droits sudoers pour l'interface web (www-data) # Droits sudoers pour l'interface web (www-data)
cat << 'EOF' > /etc/sudoers.d/nexus-pbx cat << 'EOF' > /etc/sudoers.d/nexus-pbx
# Privilèges spécifiques NexusPBX pour l'utilisateur Web www-data # Privilèges spécifiques NexusPBX pour l'utilisateur Web www-data
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 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 EOF
chmod 0440 /etc/sudoers.d/nexus-pbx chmod 0440 /etc/sudoers.d/nexus-pbx
@@ -425,9 +426,10 @@ chmod 0644 /etc/cron.d/nexus-backup
touch /var/log/nexus_backup.log && chown www-data:asterisk /var/log/nexus_backup.log && chmod 664 /var/log/nexus_backup.log touch /var/log/nexus_backup.log && chown www-data:asterisk /var/log/nexus_backup.log && chmod 664 /var/log/nexus_backup.log
# CLI symlinks # CLI symlinks
chmod +x "$TARGET_DIR/scripts/nexus-firewall" "$TARGET_DIR/scripts/nexus-banner.sh" chmod +x "$TARGET_DIR/scripts/nexus-firewall" "$TARGET_DIR/scripts/nexus-banner.sh" "$TARGET_DIR/scripts/update.sh"
ln -sf "$TARGET_DIR/scripts/nexus-firewall" /usr/local/bin/nexus-firewall ln -sf "$TARGET_DIR/scripts/nexus-firewall" /usr/local/bin/nexus-firewall
ln -sf "$TARGET_DIR/scripts/nexus-banner.sh" /usr/local/bin/nexus-banner ln -sf "$TARGET_DIR/scripts/nexus-banner.sh" /usr/local/bin/nexus-banner
ln -sf "$TARGET_DIR/scripts/update.sh" /usr/local/bin/nexus-update
# Bannière interactive lors de chaque connexion terminal (SSH / Console) # Bannière interactive lors de chaque connexion terminal (SSH / Console)
cat << 'EOF' > /etc/profile.d/nexus-motd.sh cat << 'EOF' > /etc/profile.d/nexus-motd.sh
+3 -3
View File
@@ -16,8 +16,8 @@ cd /var/www/nexus-pbx
git fetch origin main git fetch origin main
git reset --hard origin/main git reset --hard origin/main
echo "-> Installation des dépendances système indispensables (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 || (apt-get update -y && apt-get install -y --no-install-recommends acl ffmpeg rsync sox) 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..." 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 mkdir -p /etc/fail2ban/filter.d /etc/asterisk /var/log/asterisk /var/log/nexus-pbx /var/www/nexus-pbx/storage/backups
@@ -85,7 +85,7 @@ chmod 0664 /etc/fail2ban/jail.local /etc/nginx/sites-available/nexus-pbx 2>/dev/
setfacl -m u:www-data:rw /etc/fail2ban/jail.local /etc/nginx/sites-available/nexus-pbx 2>/dev/null || true setfacl -m u:www-data:rw /etc/fail2ban/jail.local /etc/nginx/sites-available/nexus-pbx 2>/dev/null || true
cat << 'EOF' > /etc/sudoers.d/nexus-pbx cat << 'EOF' > /etc/sudoers.d/nexus-pbx
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 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 EOF
chmod 0440 /etc/sudoers.d/nexus-pbx chmod 0440 /etc/sudoers.d/nexus-pbx
+12 -2
View File
@@ -95,12 +95,22 @@ echo -e "${C_GRAY}[2/6] Déploiement des nouveaux fichiers de code...${C_RESET}"
git reset --hard "${GIT_REMOTE}/${GIT_BRANCH}" git reset --hard "${GIT_REMOTE}/${GIT_BRANCH}"
chown -R www-data:asterisk "$APP_DIR" chown -R www-data:asterisk "$APP_DIR"
chmod 2775 "$APP_DIR/storage" "$APP_DIR/storage/backups" "$APP_DIR/storage/sounds" 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
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
# 3. Vérification des dépendances Debian # 3. Vérification des dépendances Debian
echo -e "${C_GRAY}[3/6] Vérification des composants et outils système...${C_RESET}" 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..." 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
} }
# 4. Exécution des migrations SQLite et régénération Dialplan # 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 // 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 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; $sshOptions = "-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=8 -p " . (int)$port;
$target = escapeshellarg("{$user}@{$host}"); $target = escapeshellarg("{$user}@{$host}");
if ($authType === 'password') { 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); $fullCmd = "sshpass -p " . escapeshellarg($password) . " ssh {$sshOptions} {$target} " . escapeshellarg($cmd);
} else { } else {
$fullCmd = "ssh {$sshOptions} {$target} " . escapeshellarg($cmd); $fullCmd = "ssh {$sshOptions} {$target} " . escapeshellarg($cmd);
@@ -713,6 +725,12 @@ class BackupManager
$src = escapeshellarg($localFile); $src = escapeshellarg($localFile);
if ($authType === 'password') { 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}"; $scpCmd = "sshpass -p " . escapeshellarg($password) . " scp {$scpOptions} {$src} {$dest}";
} else { } else {
$scpCmd = "scp {$scpOptions} {$src} {$dest}"; $scpCmd = "scp {$scpOptions} {$src} {$dest}";
@@ -742,6 +760,12 @@ class BackupManager
$dest = escapeshellarg($localDest); $dest = escapeshellarg($localDest);
if ($authType === 'password') { 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}"; $scpCmd = "sshpass -p " . escapeshellarg($password) . " scp {$scpOptions} {$src} {$dest}";
} else { } else {
$scpCmd = "scp {$scpOptions} {$src} {$dest}"; $scpCmd = "scp {$scpOptions} {$src} {$dest}";
+5 -5
View File
@@ -1,12 +1,12 @@
{ {
"version": "1.3.2", "version": "1.3.4",
"codename": "Helios", "codename": "Helios",
"release_date": "2026-11-04", "release_date": "2026-11-04",
"min_php_version": "8.2", "min_php_version": "8.2",
"changelog": [ "changelog": [
"Suppression complète des données de démonstration au déploiement (base 100% propre)", "Ajout automatique du paquet sshpass dans install.sh et le processus de mise à jour pour les sauvegardes distantes SCP/SSH",
"Résolution du bug de réapparition intempestive des postes, groupes, IVR, paging et routes supprimés", "Détection et message explicite lors des sauvegardes si l'utilitaire sshpass est manquant",
"Synchronisation robuste de l'annuaire d'entreprise lors de la suppression des extensions", "Autorisation sudoers www-data automatique pour les mises à jour 1-clic depuis l'interface Web",
"Destination entrante par défaut configurée sur raccrochage propre (terminate-hangup)" "Suppression complète des données de démonstration au déploiement (base 100% propre)"
] ]
} }