From bfc95354862bb92e108cd99920d3411df4057f7b Mon Sep 17 00:00:00 2001 From: Ludovic Brun Date: Thu, 24 Jun 2021 14:09:30 +0200 Subject: [PATCH] corrections diverses --- README.md | 12 +- version | 2 +- www/class/Log.php | 52 +- www/class/Planification.php | 63 +- www/class/Repo.php | 25 +- www/class/inclusions/changeEnv.php | 2 + www/class/inclusions/cleanArchives.php | 119 +++ www/class/inclusions/duplicate.php | 67 +- www/class/inclusions/op_finalize.php | 2 + www/class/inclusions/op_getPackages.php | 147 ++-- www/class/inclusions/op_signPackages.php | 136 +-- www/class/inclusions/restore.php | 4 +- www/common-groupslist.inc.php | 2 +- www/common-header.inc.php | 148 +++- www/common-repos-archive-list.inc.php | 12 +- www/common-repos-list-filter-groups.inc.php | 12 +- www/common-repos-list.inc.php | 7 +- www/configuration.php | 38 +- www/functions/common-functions.php | 614 +++++++------- www/functions/load_common_variables.php | 4 +- www/functions/profiles_functions.php | 4 +- www/operations/check_running.php | 40 +- .../checkArguments.inc.php | 14 - www/planifications.php | 772 +++++++++--------- www/planifications/plan.php | 2 +- www/profiles.php | 2 +- www/repomanager | 5 +- www/run.php | 67 +- www/styles/css-common.css | 207 ++--- 29 files changed, 1499 insertions(+), 1082 deletions(-) create mode 100644 www/class/inclusions/cleanArchives.php diff --git a/README.md b/README.md index 777b87b3..617ae0d3 100644 --- a/README.md +++ b/README.md @@ -6,12 +6,11 @@ Conçu pour un usage en entreprise et pour faciliter le déploiement de mises à Principales fonctionnalités : -- Créer des miroirs de repos, les mettre à jour, les dupliquer, les déployer sur les serveurs clients. +- Créer des miroirs de repos, les mettre à jour, les dupliquer, les rendre accessibles aux serveurs clients. - Signer ses repos de paquets avec GPG. -- Système d'environnements (ex preprod, prod) permettant de rendre accessible les miroirs à des environnements de serveurs particuliers (nb d'environnement illimité). -- Planifications automatiques permettant d'exécuter les actions ci-dessus à n'importe quelle date/heure. +- Système d'environnements (ex: preprod, prod...) permettant de rendre accessible les miroirs à des environnements de serveurs particuliers +- Planifications automatiques permettant d'exécuter les actions ci-dessus à une date/heure souhaitée. -(voir tableau ci-dessous pour la liste complète) ![alt text](https://github.com/lbr38/repomanager/blob/beta/repomanager.png?raw=true) @@ -23,9 +22,9 @@ Le CPU et la RAM sont essentiellement sollicités pendant la création de miroir L'espace disque est à adapter en fonction du nombre de miroirs créés / nombre de paquets qu'ils contiennent. -

Beta version

+

Version beta

-Compatible avec les systèmes Redhat/CentOS et Debian/Ubuntu : +Installation compatible sur les systèmes Redhat/CentOS et Debian/Ubuntu : - Debian 10, Ubuntu bionic - CentOS 7, 8, Fedora 33 @@ -78,6 +77,7 @@ apt update && apt install nginx php-fpm php-cli php7.4-sqlite3 sqlite3 SQLite + S'assurer que l'extension sqlite pour php est activée (généralement dans /etc/php.d/) :
diff --git a/version b/version
index b2f6c9fb..b5a9b699 100644
--- a/version
+++ b/version
@@ -1 +1 @@
-v2.0.2-beta
+v2.0.3-beta
diff --git a/www/class/Log.php b/www/class/Log.php
index 4182dd07..ee2f0fab 100644
--- a/www/class/Log.php
+++ b/www/class/Log.php
@@ -6,7 +6,7 @@ class Log {
     public $time;
     public $name;       // Nom complet du fichier de log (repomanager_... ou plan_...)
     public $location;   // Emplacement du fichier de log
-    public $title;
+    public $action;
     public $pid;
     public $steplog;
 
@@ -18,6 +18,8 @@ public function __construct(string $type) {
             throw new Error('Erreur : le type de fichier de log ne peut pas être vide');
         }
 
+        if (!empty($action)) { $this->action = $action; }
+
         /**
          *  Génération d'un PID
          */
@@ -47,8 +49,11 @@ public function __construct(string $type) {
          *   Création du fichier PID
          */
         
-        touch("${PID_DIR}/{$this->pid}.pid");
-        file_put_contents("${PID_DIR}/{$this->pid}.pid", "PID=\"{$this->pid}\"LOG=\"$this->name\"");
+        //touch("${PID_DIR}/{$this->pid}.pid");
+        file_put_contents("${PID_DIR}/{$this->pid}.pid", "PID=\"{$this->pid}\"\nLOG=\"$this->name\"".PHP_EOL);
+        if (!empty($this->action)) {
+            file_put_contents("${PID_DIR}/{$this->pid}.pid", "ACTION=\"{$this->action}\"".PHP_EOL, FILE_APPEND);
+        }
 
         /**
          *  Génération du fichier de log
@@ -69,16 +74,55 @@ public function __construct(string $type) {
         exec("ln -sfn $this->location ${MAIN_LOGS_DIR}/lastlog.log");
     }
 
+    /**
+     *  Ajout d'un subpid au fichier de PID principal
+     */
+    public function addsubpid(string $pid) {
+        global $PID_DIR;
+        file_put_contents("${PID_DIR}/{$this->pid}.pid", "SUBPID=\"${pid}\"".PHP_EOL, FILE_APPEND);
+    }
+
+    /**
+     *  Ajout de l'action en cours de traitement au fichier de PID principal
+     */
+    public function addaction(string $action) {
+        global $PID_DIR;
+        file_put_contents("${PID_DIR}/{$this->pid}.pid", "ACTION=\"${action}\"".PHP_EOL, FILE_APPEND);
+    }
+
+    /**
+     *  Ajout de la cible en cours de traitement au fichier de PID principal
+     */
+    public function addtarget(array $variables = []) {
+        global $PID_DIR;
+        global $OS_FAMILY;
+        extract($variables);
+        
+        // Si la cible en cours de traitement est un groupe
+        if (!empty($group)) {
+            file_put_contents("${PID_DIR}/{$this->pid}.pid", "GROUP=\"${group}\"".PHP_EOL, FILE_APPEND);
+        }
+        // Si la cible en cours de traitement est un repo
+        if (!empty($name)) {
+            if ($OS_FAMILY == "Redhat") {
+                file_put_contents("${PID_DIR}/{$this->pid}.pid", "NAME=\"${name}\"".PHP_EOL, FILE_APPEND);
+            }
+            if ($OS_FAMILY == "Debian") {
+                file_put_contents("${PID_DIR}/{$this->pid}.pid", "NAME=\"${name}\"\nDIST=\"${dist}\"\nSECTION=\"${section}\"".PHP_EOL, FILE_APPEND);
+            }
+        }
+    }
+
     public function write(string $content) {
         file_put_contents($this->location, $content);
     }
 
     public function close() {
         global $PID_DIR;
+
         /**
          *  Suppression du fichier PID
          */
-
         if (file_exists("${PID_DIR}/{$this->pid}.pid")) {
             unlink("${PID_DIR}/{$this->pid}.pid");
         }
diff --git a/www/class/Planification.php b/www/class/Planification.php
index 075cc28d..99d5698d 100644
--- a/www/class/Planification.php
+++ b/www/class/Planification.php
@@ -185,6 +185,7 @@ public function exec() {
                 $this->checkAction_update_allowed();
                 $this->checkAction_update_gpgCheck();
                 $this->checkAction_update_gpgResign();
+                $this->log->addaction('update'); // ajout de l'action au fichier de PID principal
             }
 
             /**
@@ -192,6 +193,7 @@ public function exec() {
              */
             if (strpos($this->action, '->') !== false) {
                 $this->checkAction_env_allowed();
+                $this->log->addaction('->'); // ajout de l'action au fichier de PID principal
             }
             
             /**
@@ -229,40 +231,46 @@ public function exec() {
 
         // TRAITEMENT //
 
-            /**
-             *  1. Cas où on traite 1 repo seulement
-             */
-            if (!empty($this->repo->name) AND empty($this->group->name)) {
-                // Si $this->action = update alors on met à jour le repo
-                if ($this->action == "update") {
-                    if ($this->repo->update() === false) {
-                        $this->close(2, 'Une erreur est survenue pendant le traitement, voir les logs');
-                    }
+        /**
+         *  1. Cas où on traite 1 repo seulement
+         */
+        if (!empty($this->repo->name) AND empty($this->group->name)) {
+            // Ajout de la cible dans le fichier de PID principal de la planification
+            if ($OS_FAMILY == "Redhat") { $this->log->addtarget(array('name' => $this->repo->name)); }
+            if ($OS_FAMILY == "Debian") { $this->log->addtarget(array('name' => $this->repo->name, 'dist' => $this->repo->dist, 'section' => $this->repo->section)); }
+
+            // Si $this->action = update alors on met à jour le repo
+            if ($this->action == "update") {
+                if ($this->repo->update() === false) {
+                    $this->close(2, 'Une erreur est survenue pendant le traitement, voir les logs');
                 }
+            }
 
-                // Si $this->action contient '->' alors il s'agit d'un changement d'env
-                if (strpos($this->action, '->') !== false) {
-                    // Récupération de l'environnement source et de l'environnement cible
-                    $this->repo->env = exec("echo '$this->action' | awk -F '->' '{print $1}'");
-                    $this->repo->newEnv = exec("echo '$this->action' | awk -F '->' '{print $2}'");
-                    if (empty($this->repo->env) OR empty($this->repo->newEnv)) {
-                        $this->close(1, 'Erreur (EP04) : Environnement(s) non défini(s)'); // On sort avec 1 car on considère que c'est une erreur de type vérification
-                    }
+            // Si $this->action contient '->' alors il s'agit d'un changement d'env
+            if (strpos($this->action, '->') !== false) {
+                // Récupération de l'environnement source et de l'environnement cible
+                $this->repo->env = exec("echo '$this->action' | awk -F '->' '{print $1}'");
+                $this->repo->newEnv = exec("echo '$this->action' | awk -F '->' '{print $2}'");
+                if (empty($this->repo->env) OR empty($this->repo->newEnv)) {
+                    $this->close(1, 'Erreur (EP04) : Environnement(s) non défini(s)'); // On sort avec 1 car on considère que c'est une erreur de type vérification
+                }
 
-                    // Traitement
-                    if ($OS_FAMILY == "Redhat") { $this->log->title = 'NOUVEL ENVIRONNEMENT DE REPO'; }
-                    if ($OS_FAMILY == "Debian") { $this->log->title = 'NOUVEL ENVIRONNEMENT DE SECTION'; }
-                    if ($this->repo->changeEnv() === false) {
-                        $this->close(2, 'Une erreur est survenue pendant le traitement, voir les logs');
-                    }
+                // Traitement
+                if ($OS_FAMILY == "Redhat") { $this->log->title = 'NOUVEL ENVIRONNEMENT DE REPO'; }
+                if ($OS_FAMILY == "Debian") { $this->log->title = 'NOUVEL ENVIRONNEMENT DE SECTION'; }
+                if ($this->repo->changeEnv() === false) {
+                    $this->close(2, 'Une erreur est survenue pendant le traitement, voir les logs');
                 }
             }
-        
+        }
 
         /**
          *  2. Cas où on traite un groupe de repos/sections
          */
         if (!empty($this->group->name) AND !empty($this->groupList)) {
+            // Ajout de la cible dans le fichier de PID principal de la planification
+            $this->log->addtarget(array('group' => $this->group->name));
+
             // Comme on boucle pour traiter plusieurs repos/sections, on ne peut pas tout quitter en cas d'erreur tant qu'on a pas bouclé sur tous les repos.
             // Du coup on initialise une variable qu'on incrémentera en cas d'erreur.
             // A la fin si cette variable > 0 alors on pourra quitter ce script en erreur ($this->close 1)
@@ -336,7 +344,7 @@ public function generateReminders() {
         //$planFile = "plan-{$this->id}.conf";
               
         /**
-         *  1. Récupération des informations de la planification toto
+         *  1. Récupération des informations de la planification
          */
         $this->getInfo();
      
@@ -464,6 +472,9 @@ public function sendMail($title, $template) {
         // Pour envoyer un mail HTML il faut inclure ces headers
         $headers[] = 'MIME-Version: 1.0';
         $headers[] = 'Content-type: text/html; charset=utf8';
+        $headers[] = "From: noreply@${WWW_HOSTNAME}";
+        $headers[] = "X-Sender: noreply@${WWW_HOSTNAME}";
+        $headers[] = "Reply-To: noreply@${WWW_HOSTNAME}";
         mail($EMAIL_DEST, $title, $template, implode("\r\n", $headers));
     }
 
@@ -522,7 +533,7 @@ public function close($planError, $plan_msg_error) {
                 if (!empty($this->logList)) {
                     foreach ($this->logList as $log) {
                         $content = $content . file_get_contents($log);
-                        // On supprime le sous-fichier de log puisque son contenu vient d'ere récupéré et qu'il sera intégré au fichier de log de la planification
+                        // On supprime le sous-fichier de log puisque son contenu vient d'etre récupéré et qu'il sera intégré au fichier de log de la planification
                         unlink($log);
                     }
                 }
diff --git a/www/class/Repo.php b/www/class/Repo.php
index 5a8331dd..e3f68376 100644
--- a/www/class/Repo.php
+++ b/www/class/Repo.php
@@ -17,6 +17,7 @@
 include_once("${WWW_DIR}/class/inclusions/duplicate.php");
 include_once("${WWW_DIR}/class/inclusions/deleteArchive.php");
 include_once("${WWW_DIR}/class/inclusions/restore.php");
+include_once("${WWW_DIR}/class/inclusions/cleanArchives.php");
 
 class Repo {
     public $db;
@@ -46,7 +47,7 @@ class Repo {
      *  Import des traits nécessaires pour les opérations sur les repos/sections
      */
     use op_printDetails, op_getPackages, op_signPackages, op_createRepo, op_archive, op_finalize;
-    use changeEnv, duplicate, delete, deleteDist, deleteSection, deleteArchive, restore;
+    use changeEnv, duplicate, delete, deleteDist, deleteSection, deleteArchive, restore, cleanArchives;
 
     public function __construct(array $variables = []) {
         global $OS_FAMILY;
@@ -137,17 +138,26 @@ public function new() {
         global $TEMP_DIR;
         global $OS_FAMILY;
         global $WWW_DIR;
+        global $PID_DIR;
 
         /**
          *  Création d'un fichier de log principal + un fichier PID
          */
         $this->log = new Log('repomanager');
 
+        /**
+         *  Ajout du PID de ce processus dans le fichier PID ainsi que l'action effectuée et la cible (le repo)
+         */
+        $this->log->addsubpid(getmypid());
+        $this->log->addaction('new');
+        if ($OS_FAMILY == "Redhat") { $this->log->addtarget(array('name' => $this->name)); }
+        if ($OS_FAMILY == "Debian") { $this->log->addtarget(array('name' => $this->name, 'dist' => $this->dist, 'section' => $this->section)); }
+
         /**
          *  Lancement du script externe qui va construire le fichier de log principal à partir des petits fichiers de log de chaque étape
          */
         $steps = 5;
-        exec("php ${WWW_DIR}/operations/check_running.php {$this->log->location} $TEMP_DIR/{$this->log->pid} $steps >/dev/null 2>/dev/null &");
+        exec("php ${WWW_DIR}/operations/check_running.php ${PID_DIR}/{$this->log->pid}.pid {$this->log->location} $TEMP_DIR/{$this->log->pid} $steps >/dev/null 2>/dev/null &");
 
         try {
             /**
@@ -199,17 +209,26 @@ public function update() {
         global $TEMP_DIR;
         global $OS_FAMILY;
         global $WWW_DIR;
+        global $PID_DIR;
 
         /**
          *  Création d'un fichier de log principal + un fichier PID
          */
         $this->log = new Log('repomanager');
 
+        /**
+         *  Ajout du PID de ce processus dans le fichier PID ainsi que l'action effectuée et la cible (le repo)
+         */
+        $this->log->addsubpid(getmypid());
+        $this->log->addaction('update');
+        if ($OS_FAMILY == "Redhat") { $this->log->addtarget(array('name' => $this->name)); }
+        if ($OS_FAMILY == "Debian") { $this->log->addtarget(array('name' => $this->name, 'dist' => $this->dist, 'section' => $this->section)); }
+
         /**
          *  Lancement du script externe qui va construire le fichier de log principal à partir des petits fichiers de log de chaque étape
          */
         $steps = 6;
-        exec("php ${WWW_DIR}/operations/check_running.php {$this->log->location} ${TEMP_DIR}/{$this->log->pid} $steps >/dev/null 2>/dev/null &");
+        exec("php ${WWW_DIR}/operations/check_running.php ${PID_DIR}/{$this->log->pid}.pid {$this->log->location} ${TEMP_DIR}/{$this->log->pid} $steps >/dev/null 2>/dev/null &");
 
         try {
             /**
diff --git a/www/class/inclusions/changeEnv.php b/www/class/inclusions/changeEnv.php
index 76848802..3fc6dccc 100644
--- a/www/class/inclusions/changeEnv.php
+++ b/www/class/inclusions/changeEnv.php
@@ -319,6 +319,8 @@ public function changeEnv() {
         }
 
         echo '

Terminé

'; + + $this->cleanArchives(); } } ?> \ No newline at end of file diff --git a/www/class/inclusions/cleanArchives.php b/www/class/inclusions/cleanArchives.php new file mode 100644 index 00000000..4cebb6bb --- /dev/null +++ b/www/class/inclusions/cleanArchives.php @@ -0,0 +1,119 @@ +db->countRows("SELECT DISTINCT Name FROM repos_archived") == 0) { + return; + } + $result = $this->db->query("SELECT DISTINCT Name FROM repos_archived"); + } + if ($OS_FAMILY == "Debian") { + if ($this->db->countRows("SELECT DISTINCT Name, Dist, Section FROM repos_archived") == 0) { + return; + } + $result = $this->db->query("SELECT DISTINCT Name, Dist, Section FROM repos_archived"); + } + + /** + * 5. Sinon on récupère leur nom + */ + while ($data = $result->fetchArray()) { + $reposArchived[] = $data; + } + + /** + * 6. Avec cette liste, on va traiter chaque repo individuellement, en les triant par date puis en supprimant les plus vieux (on conserve X copie du repo, X étant défini par $RETENTION) + */ + foreach($reposArchived as $repoArchived) { + $dates = []; + $repoName = $repoArchived['Name']; + if ($OS_FAMILY == "Debian") { + $repoDist = $repoArchived['Dist']; + $repoSection = $repoArchived['Section']; + } + + /** + * 7. Pour chaque repo, on récupère les dates qui vont au delà du paramètre de retention renseigné + */ + if (!empty($repoName)) { + if ($OS_FAMILY == "Redhat") { + if ($this->db->countRows("SELECT Date FROM repos_archived WHERE Name = '$repoName' ORDER BY Date DESC LIMIT -1 OFFSET $RETENTION") == 0) { + continue; + } else { + $result = $this->db->query("SELECT Date FROM repos_archived WHERE Name = '$repoName' ORDER BY Date DESC LIMIT -1 OFFSET $RETENTION"); + } + } + if ($OS_FAMILY == "Debian") { + if ($this->db->countRows("SELECT Date FROM repos_archived WHERE Name = '$repoName' AND Dist = '$repoDist' AND Section = '$repoSection' ORDER BY Date DESC LIMIT -1 OFFSET $RETENTION") == 0) { + continue; + } else { + $result = $this->db->query("SELECT Date FROM repos_archived WHERE Name = '$repoName' AND Dist = '$repoDist' AND Section = '$repoSection' ORDER BY Date DESC LIMIT -1 OFFSET $RETENTION"); + } + } + while ($data = $result->fetchArray()) { + $dates[] = $data; + } + + foreach($dates as $date) { + $repoDate = $date['Date']; + $repoDateFormatted = DateTime::createFromFormat('Y-m-d', $date['Date'])->format('d-m-Y'); + if (!empty($repoDateFormatted)) { + if ($OS_FAMILY == "Redhat") { echo "

Suppression du repo archivé $repoName en date du $repoDateFormatted

"; } + if ($OS_FAMILY == "Debian") { echo "

Suppression de la section archivée $repoSection du repo $repoName (distribution $repoDist) en date du $repoDateFormatted

"; } + /** + * 8. Suppression du miroir + */ + if ($OS_FAMILY == "Redhat") { exec("rm '${REPOS_DIR}/archived_${repoDateFormatted}_${repoName}' -rf", $output, $return); } + if ($OS_FAMILY == "Debian") { exec("rm '${REPOS_DIR}/${repoName}/${repoDist}/archived_${repoDateFormatted}_${repoSection}' -rf", $output, $return); } + if ($return != 0) { + echo "

Erreur lors de la suppression du repo $repoName en date du $repoDateFormatted

"; + continue; // On traite la date suivante + } + /** + * 9. Nettoyage du fichier de liste + */ + if ($OS_FAMILY == "Redhat") { $this->db->exec("DELETE FROM repos_archived WHERE Name = '$repoName' AND Date = '$repoDate'"); } + if ($OS_FAMILY == "Debian") { $this->db->exec("DELETE FROM repos_archived WHERE Name = '$repoName' AND Dist = '$repoDist' AND Section = '$repoSection' AND Date = '$repoDate'"); } + } + } + } + } + } +} \ No newline at end of file diff --git a/www/class/inclusions/duplicate.php b/www/class/inclusions/duplicate.php index 5c597c4b..9732f93b 100644 --- a/www/class/inclusions/duplicate.php +++ b/www/class/inclusions/duplicate.php @@ -5,9 +5,12 @@ trait duplicate { */ public function duplicate() { global $REPOS_DIR; - global $DEFAULT_ENV; global $WWW_USER; + global $WWW_HOSTNAME; global $OS_FAMILY; + global $GPGHOME; + global $GPG_KEYID; + global $DATE_JMA; /** * 1. On vérifie que le nouveau nom du repo n'est pas vide @@ -126,10 +129,10 @@ public function duplicate() { * Anti-slash devant la commande cp pour forcer l'écrasement */ if ($OS_FAMILY == "Redhat") { - exec("\cp -r ${REPOS_DIR}/{$this->dateFormatted}_{$this->name} ${REPOS_DIR}/{$this->dateFormatted}_{$this->newName}", $output, $result); + exec("\cp -r ${REPOS_DIR}/{$this->dateFormatted}_{$this->name}/* ${REPOS_DIR}/{$this->dateFormatted}_{$this->newName}/", $output, $result); } if ($OS_FAMILY == "Debian") { - exec("\cp -r ${REPOS_DIR}/{$this->name}/{$this->dist}/{$this->dateFormatted}_{$this->section} ${REPOS_DIR}/{$this->newName}/{$this->dist}/{$this->dateFormatted}_{$this->section}", $output, $result); + exec("\cp -r ${REPOS_DIR}/{$this->name}/{$this->dist}/{$this->dateFormatted}_{$this->section}/* ${REPOS_DIR}/{$this->newName}/{$this->dist}/{$this->dateFormatted}_{$this->section}/", $output, $result); } if ($result != 0) { echo '

Erreur : copie du répertoire impossible

'; @@ -140,18 +143,62 @@ public function duplicate() { * 6. Création du lien symbolique */ if ($OS_FAMILY == "Redhat") { - exec("cd ${REPOS_DIR}/ && ln -s {$this->dateFormatted}_{$this->newName}/ {$this->newName}_${DEFAULT_ENV}", $output, $result); + exec("cd ${REPOS_DIR}/ && ln -sfn {$this->dateFormatted}_{$this->newName}/ {$this->newName}_{$this->env}", $output, $result); } if ($OS_FAMILY == "Debian") { - exec("cd ${REPOS_DIR}/{$this->newName}/{$this->dist}/ && ln -s {$this->dateFormatted}_{$this->section}/ {$this->section}_${DEFAULT_ENV}", $output, $result); + exec("cd ${REPOS_DIR}/{$this->newName}/{$this->dist}/ && ln -sfn {$this->dateFormatted}_{$this->section}/ {$this->section}_{$this->env}", $output, $result); } if ($result != 0) { - echo '

Erreur :création du lien symbolique impossible

'; + echo '

Erreur : création du lien symbolique impossible

'; return; } /** - * 7. Insertion en BDD du nouveau repo + * 7. On re-crée le repo avec les nouvelles informations (nouveau nom) et on resigne le repo avec GPG (Release.gpg). On fait ça uniquement sur Debian car avec Redhat/CentOS, ce sont les paquets qui sont + * signés, donc cela n'a pas d'incidence si le nom du repo a changé + */ + if ($this->signed == "yes" OR $this->gpgResign == "yes") { + if ($OS_FAMILY == "Debian") { + // On va utiliser un répertoire temporaire pour travailler + $TMP_DIR = '/tmp/deb_packages'; + mkdir($TMP_DIR, 0770, true); + // On se mets à la racine de la section + // On recherche tous les paquets .deb et on les déplace dans le répertoire temporaire + exec("cd ${REPOS_DIR}/{$this->newName}/{$this->dist}/{$this->dateFormatted}_{$this->section}/ && find . -name '*.deb' -exec mv '{}' $TMP_DIR \;"); + // Après avoir déplacé tous les paquets on peut supprimer tout le contenu de la section + exec("rm -rf ${REPOS_DIR}/{$this->newName}/{$this->dist}/{$this->dateFormatted}_{$this->section}/*"); + // Création du répertoire conf et des fichiers de conf du repo + mkdir("${REPOS_DIR}/{$this->newName}/{$this->dist}/{$this->dateFormatted}_{$this->section}/conf", 0770, true); + // Création du fichier "distributions" + if (!file_put_contents("${REPOS_DIR}/{$this->newName}/{$this->dist}/{$this->dateFormatted}_{$this->section}/conf/distributions", "Origin: Repo $this->newName sur ${WWW_HOSTNAME}\nLabel: apt repository\nCodename: {$this->dist}\nArchitectures: i386 amd64\nComponents: {$this->section}\nDescription: Miroir du repo {$this->newName}, distribution {$this->dist}, section {$this->section}\nSignWith: ${GPG_KEYID}\nPull: {$this->section}".PHP_EOL)) { + echo '

Erreur : impossible de créer le fichier de configuration du repo (distributions)

'; + return; + } + // Création du fichier "options" + if (!file_put_contents("${REPOS_DIR}/{$this->newName}/{$this->dist}/{$this->dateFormatted}_{$this->section}/conf/options", "basedir ${REPOS_DIR}/{$this->newName}/{$this->dist}/{$this->dateFormatted}_{$this->section}\nask-passphrase".PHP_EOL)) { + echo '

Erreur : impossible de créer le fichier de configuration du repo (options)

'; + return; + } + + // Création du repo en incluant les paquets deb du répertoire temporaire, et signature du fichier Release + exec("cd ${REPOS_DIR}/{$this->newName}/{$this->dist}/{$this->dateFormatted}_{$this->section}/ && /usr/bin/reprepro --gnupghome ${GPGHOME} includedeb {$this->dist} ${TMP_DIR}/*.deb", $output, $result); + + // Suppression du répertoire temporaire + exec("rm -rf '$TMP_DIR'"); + if ($result != 0) { + echo "

Erreur : la signature de la section $this->section du repo $this->newName a échouée"; + echo '
Suppression de ce qui a été fait : '; + exec("rm -rf '${REPOS_DIR}/{$this->newName}/{$this->dist}/{$this->dateFormatted}_{$this->section}'"); + exec("rm -rf $TMP_DIR"); + echo 'OK'; + echo '

'; + return; + } + } + } + + /** + * 8. Insertion en BDD du nouveau repo */ if ($OS_FAMILY == "Redhat") { $this->db->exec("INSERT INTO repos (Name, Source, Env, Date, Time, Description, Signed, Type) VALUES ('$this->newName', '$this->source', '$this->env', '$this->date', '$this->time', '$this->description', '$this->signed', 'mirror')"); @@ -161,14 +208,14 @@ public function duplicate() { } /** - * 8. Application des droits sur le nouveau repo créé + * 9. Application des droits sur le nouveau repo créé */ exec("find ${REPOS_DIR}/{$this->newName}/ -type f -exec chmod 0660 {} \;"); exec("find ${REPOS_DIR}/{$this->newName}/ -type d -exec chmod 0770 {} \;"); exec("chown -R ${WWW_USER}:repomanager ${REPOS_DIR}/{$this->newName}/"); /** - * 9. Ajout de la section à un groupe si un groupe a été renseigné + * 10. Ajout de la section à un groupe si un groupe a été renseigné */ if (!empty($this->group)) { if ($OS_FAMILY == "Redhat") { @@ -196,7 +243,7 @@ public function duplicate() { } /** - * 10. Génération du fichier de conf repo en local (ces fichiers sont utilisés pour les profils) + * 11. Génération du fichier de conf repo en local (ces fichiers sont utilisés pour les profils) * Pour les besoins de la fonction, on set $this->name = $this->newName (sinon ça va générer un fichier pour le repo source, ce qu'on ne veut pas) */ $this->name = $this->newName; diff --git a/www/class/inclusions/op_finalize.php b/www/class/inclusions/op_finalize.php index 620212dc..760de632 100644 --- a/www/class/inclusions/op_finalize.php +++ b/www/class/inclusions/op_finalize.php @@ -89,6 +89,8 @@ public function op_finalize($op_type) { echo '

Terminé

'; + $this->cleanArchives(); + $this->logcontent = ob_get_clean(); file_put_contents($this->log->steplog, $this->logcontent, FILE_APPEND); return true; diff --git a/www/class/inclusions/op_getPackages.php b/www/class/inclusions/op_getPackages.php index 6bb53a4e..786c0f3a 100644 --- a/www/class/inclusions/op_getPackages.php +++ b/www/class/inclusions/op_getPackages.php @@ -1,8 +1,8 @@ existsDateEnv($this->name, $this->date, $DEFAULT_ENV) === true) { - throw new Exception("

Erreur : la section $this->section du repo $this->name existe déjà en ${DEFAULT_ENV}

"); + throw new Exception("

Erreur : la repo $this->name existe déjà en ${DEFAULT_ENV} au $this->date

"); } } if ($OS_FAMILY == "Debian") { if ($this->section_existsDateEnv($this->name, $this->dist, $this->section, $this->date, $DEFAULT_ENV) === true) { - throw new Exception("

Erreur : la section $this->section du repo $this->name existe déjà en ${DEFAULT_ENV}

"); + throw new Exception("

Erreur : la section $this->section du repo $this->name existe déjà en ${DEFAULT_ENV} au $this->date

"); } } } @@ -72,7 +73,9 @@ public function op_getPackages($op_type) { //// TRAITEMENT //// - // Création du répertoire du repo/section + /** + * 2. Création du répertoire du repo/section + */ if ($OS_FAMILY == "Redhat") { if (is_dir("${REPOS_DIR}/${DATE_JMA}_{$this->name}")) { throw new Exception("

Erreur : le répertoire ${REPOS_DIR}/${DATE_JMA}_{$this->name} existe déjà

"); @@ -82,7 +85,6 @@ public function op_getPackages($op_type) { throw new Exception("

Erreur : la création du répertoire ${REPOS_DIR}/${DATE_JMA}_{$this->name} a échouée

"); } } - if ($OS_FAMILY == "Debian") { if (is_dir("${REPOS_DIR}/{$this->name}/{$this->dist}/${DATE_JMA}_{$this->section}")) { throw new Exception("

Erreur : le répertoire ${REPOS_DIR}/{$this->name}/{$this->dist}/${DATE_JMA}_{$this->section} existe déjà

"); @@ -95,81 +97,120 @@ public function op_getPackages($op_type) { $this->logcontent = ob_get_clean(); file_put_contents($this->log->steplog, $this->logcontent, FILE_APPEND); ob_start(); - // Récupération des paquets + /** + * 3. Récupération des paquets + */ echo '
Récupération des paquets '; echo 'en cours'; echo '
';
         $this->logcontent = ob_get_clean(); file_put_contents($this->log->steplog, $this->logcontent, FILE_APPEND); ob_start();
+
+        // File descriptors for each subprocess. http://phptutorial.info/?proc-open
+        /* $descriptors = [
+            0 => array("pipe", "r"),  // stdin is a pipe that the child will read from
+            1 => array("pipe", "w"),  // stdout is a pipe that the child will write to
+            2 => array("file", "{$this->log->steplog}", "a") // stderr is a file to write to
+        ];*/
+        // https://gist.github.com/swichers/027d5ae903350cbd4af8
+        $descriptors = array(
+            // Must use php://stdin(out) in order to allow display of command output
+            // and the user to interact with the process.
+            0 => array('file', 'php://stdin', 'r'),
+            1 => array('file', 'php://stdout', 'w'),
+            2 => array('pipe', 'w'),
+        );
+
         if ($OS_FAMILY == "Redhat") {
+            /**
+             *  Note : pour reposync il faut impérativement rediriger la sortie standard vers la sortie d'erreur car c'est uniquement cette dernière qui est capturée par proc_open. On fait ça pour avoir non seulement les erreurs mais aussi tout le déroulé normal de reposync.
+             */
             if ($this->gpgCheck == "no") {
                 if ($OS_VERSION == "7") {
-                    exec("cd '${REPOS_DIR}/${DATE_JMA}_{$this->name}' && reposync --config=${REPOMANAGER_YUM_DIR}/repomanager.conf -l --repoid={$this->source} --norepopath --download_path='${REPOS_DIR}/${DATE_JMA}_{$this->name}/' >> {$this->log->steplog}", $output, $result);
+                    //exec("reposync --config=${REPOMANAGER_YUM_DIR}/repomanager.conf -l --repoid={$this->source} --norepopath --download_path='${REPOS_DIR}/${DATE_JMA}_{$this->name}/' >> {$this->log->steplog}", $output, $result);
+                    $process = proc_open("exec reposync --config=${REPOMANAGER_YUM_DIR}/repomanager.conf -l --repoid={$this->source} --norepopath --download_path='${REPOS_DIR}/${DATE_JMA}_{$this->name}/' 1>&2", $descriptors, $pipes);
                 }
                 if ($OS_VERSION == "8") {
-                    exec("cd '${REPOS_DIR}/${DATE_JMA}_{$this->name}' && reposync --config=${REPOMANAGER_YUM_DIR}/repomanager.conf --nogpgcheck --repoid={$this->source} --download-path '${REPOS_DIR}/${DATE_JMA}_{$this->name}/' >> {$this->log->steplog}", $output, $result);
+                    //exec("reposync --config=${REPOMANAGER_YUM_DIR}/repomanager.conf --nogpgcheck --repoid={$this->source} --download-path '${REPOS_DIR}/${DATE_JMA}_{$this->name}/' >> {$this->log->steplog}", $output, $result);
+                    $process = proc_open("exec reposync --config=${REPOMANAGER_YUM_DIR}/repomanager.conf --nogpgcheck --repoid={$this->source} --download-path '${REPOS_DIR}/${DATE_JMA}_{$this->name}/' 1>&2", $descriptors, $pipes);
                 }
             } else { // Dans tous les autres cas (même si rien n'a été précisé) on active gpgcheck
                 if ($OS_VERSION == "7") {
-                    exec("cd '${REPOS_DIR}/${DATE_JMA}_{$this->name}' && reposync --config=${REPOMANAGER_YUM_DIR}/repomanager.conf --gpgcheck -l --repoid={$this->source} --norepopath --download_path='${REPOS_DIR}/${DATE_JMA}_{$this->name}/' >> {$this->log->steplog}", $output, $result);
+                    //exec("reposync --config=${REPOMANAGER_YUM_DIR}/repomanager.conf --gpgcheck -l --repoid={$this->source} --norepopath --download_path='${REPOS_DIR}/${DATE_JMA}_{$this->name}/' >> {$this->log->steplog}", $output, $result);
+                    $process = proc_open("exec reposync --config=${REPOMANAGER_YUM_DIR}/repomanager.conf --gpgcheck -l --repoid={$this->source} --norepopath --download_path='${REPOS_DIR}/${DATE_JMA}_{$this->name}/' 1>&2", $descriptors, $pipes);
                 }
                 if ($OS_VERSION == "8") {
-                    exec("cd '${REPOS_DIR}/${DATE_JMA}_{$this->name}' && reposync --config=${REPOMANAGER_YUM_DIR}/repomanager.conf --repoid={$this->source} --download-path '${REPOS_DIR}/${DATE_JMA}_{$this->name}/' >> {$this->log->steplog}", $output, $result);
+                    //exec("reposync --config=${REPOMANAGER_YUM_DIR}/repomanager.conf --repoid={$this->source} --download-path '${REPOS_DIR}/${DATE_JMA}_{$this->name}/' >> {$this->log->steplog}", $output, $result);
+                    $process = proc_open("exec reposync --config=${REPOMANAGER_YUM_DIR}/repomanager.conf --repoid={$this->source} --download-path '${REPOS_DIR}/${DATE_JMA}_{$this->name}/' 1>&2", $descriptors, $pipes);
                 }
             }
-            echo '
'; - - $this->logcontent = ob_get_clean(); file_put_contents($this->log->steplog, $this->logcontent, FILE_APPEND); ob_start(); - - if ($result == 0) { - echo ''; - } else { - echo ''; - echo '
Erreur : reposync a rencontré un problème lors de la création du miroir'; - echo '
Suppression de ce qui a été fait : '; - exec("rm -rf '${REPOS_DIR}/${DATE_JMA}_{$this->name}'"); - echo 'OK'; - $this->logcontent = ob_get_clean(); file_put_contents($this->log->steplog, $this->logcontent, FILE_APPEND); ob_start(); - throw new Exception(); - } - $this->logcontent = ob_get_clean(); file_put_contents($this->log->steplog, $this->logcontent, FILE_APPEND); ob_start(); } if ($OS_FAMILY == "Debian") { // Dans le cas où on a précisé de ne pas vérifier les signatures GPG : if ($this->gpgCheck == "no") { - exec("/usr/bin/debmirror --no-check-gpg --nosource --passive --method=http --rsync-extra=none --root={$this->rootUrl} --dist={$this->dist} --host={$this->hostUrl} --section={$this->section} --arch=amd64 ${REPOS_DIR}/{$this->name}/{$this->dist}/${DATE_JMA}_{$this->section} --getcontents --ignore-release-gpg --progress --i18n --include='Translation-fr.*\.bz2' --postcleanup >> {$this->log->steplog}", $output, $result); + // à conserver (ancienne méthode) : + //exec("/usr/bin/debmirror --no-check-gpg --nosource --passive --method=http --rsync-extra=none --root={$this->rootUrl} --dist={$this->dist} --host={$this->hostUrl} --section={$this->section} --arch=amd64 ${REPOS_DIR}/{$this->name}/{$this->dist}/${DATE_JMA}_{$this->section} --getcontents --ignore-release-gpg --progress --i18n --include='Translation-fr.*\.bz2' --postcleanup >> {$this->log->steplog}", $output, $result); + $process = proc_open("exec /usr/bin/debmirror --no-check-gpg --nosource --passive --method=http --rsync-extra=none --root={$this->rootUrl} --dist={$this->dist} --host={$this->hostUrl} --section={$this->section} --arch=amd64 ${REPOS_DIR}/{$this->name}/{$this->dist}/${DATE_JMA}_{$this->section} --getcontents --ignore-release-gpg --progress --i18n --include='Translation-fr.*\.bz2' --postcleanup", $descriptors, $pipes); } else { // Dans tous les autres cas (même si rien n'a été précisé) - exec("/usr/bin/debmirror --check-gpg --keyring=${GPGHOME}/trustedkeys.gpg --nosource --passive --method=http --rsync-extra=none --root={$this->rootUrl} --dist={$this->dist} --host={$this->hostUrl} --section={$this->section} --arch=amd64 ${REPOS_DIR}/{$this->name}/{$this->dist}/${DATE_JMA}_{$this->section} --getcontents --ignore-release-gpg --progress --i18n --include='Translation-fr.*\.bz2' --postcleanup >> {$this->log->steplog}", $output, $result); + // à conserver (ancienne méthode) : + //exec("/usr/bin/debmirror --check-gpg --keyring=${GPGHOME}/trustedkeys.gpg --nosource --passive --method=http --rsync-extra=none --root={$this->rootUrl} --dist={$this->dist} --host={$this->hostUrl} --section={$this->section} --arch=amd64 ${REPOS_DIR}/{$this->name}/{$this->dist}/${DATE_JMA}_{$this->section} --getcontents --ignore-release-gpg --progress --i18n --include='Translation-fr.*\.bz2' --postcleanup >> {$this->log->steplog}", $output, $result); + $process = proc_open("exec /usr/bin/debmirror --check-gpg --keyring=${GPGHOME}/trustedkeys.gpg --nosource --passive --method=http --rsync-extra=none --root={$this->rootUrl} --dist={$this->dist} --host={$this->hostUrl} --section={$this->section} --arch=amd64 ${REPOS_DIR}/{$this->name}/{$this->dist}/${DATE_JMA}_{$this->section} --getcontents --ignore-release-gpg --progress --i18n --include='Translation-fr.*\.bz2' --postcleanup", $descriptors, $pipes); } - echo '
'; + } - $this->logcontent = ob_get_clean(); file_put_contents($this->log->steplog, $this->logcontent, FILE_APPEND); ob_start(); + // Récupération du pid et du status du process lancé + $proc_details = proc_get_status($process); + // Ecriture du pid de reposync/debmirror (lancé par proc_open) dans le fichier PID principal, ceci afin qu'il puisse être killé si l'utilisateur le souhaites + file_put_contents("${PID_DIR}/{$this->log->pid}.pid", "SUBPID=\"".$proc_details['pid']."\"".PHP_EOL, FILE_APPEND); + + /** + * Tant que le process (lancé par proc_open) n'est pas terminé, on boucle afin de ne pas continuer les étapes suivantes + */ + do { + $status = proc_get_status($process); - if ($result == 0) { - echo ''; - } else { - echo ''; - echo '
Erreur : debmirror a rencontré un problème lors de la création du miroir'; - echo '
Suppression de ce qui a été fait : '; - exec("rm -rf '${REPOS_DIR}/{$this->name}/{$this->dist}/${DATE_JMA}_{$this->section}'"); - echo 'OK'; - $this->logcontent = ob_get_clean(); file_put_contents($this->log->steplog, $this->logcontent, FILE_APPEND); ob_start(); - throw new Exception(); + // If our stderr pipe has data, grab it for use later. + if (!feof($pipes[2])) { + + // We're acting like passthru would and displaying errors as they come in. + $error_line = fgets($pipes[2]); + file_put_contents($this->log->steplog, $error_line, FILE_APPEND); } + } while ($status['running'] === true); + + /** + * Clôture du process + */ + proc_close($process); + echo ''; + $this->logcontent = ob_get_clean(); file_put_contents($this->log->steplog, $this->logcontent, FILE_APPEND); ob_start(); + + /** + * Récupération du code d'erreur de reposync/debmirror + */ + $return = $status['exitcode']; + + if ($return == 0) { + echo ''; + } else { + echo ''; + if ($OS_FAMILY == "Redhat") { echo '
Erreur : reposync a rencontré un problème lors de la création du miroir'; } + if ($OS_FAMILY == "Debian") { echo '
Erreur : debmirror a rencontré un problème lors de la création du miroir'; } + echo '
Suppression de ce qui a été fait : '; + if ($OS_FAMILY == "Redhat") { exec("rm -rf '${REPOS_DIR}/${DATE_JMA}_{$this->name}'"); } + if ($OS_FAMILY == "Debian") { exec("rm -rf '${REPOS_DIR}/{$this->name}/{$this->dist}/${DATE_JMA}_{$this->section}'"); } + echo 'OK'; $this->logcontent = ob_get_clean(); file_put_contents($this->log->steplog, $this->logcontent, FILE_APPEND); ob_start(); + throw new Exception(); } + $this->logcontent = ob_get_clean(); file_put_contents($this->log->steplog, $this->logcontent, FILE_APPEND); ob_start(); + return true; } } diff --git a/www/class/inclusions/op_signPackages.php b/www/class/inclusions/op_signPackages.php index 72787f62..c17ad72c 100644 --- a/www/class/inclusions/op_signPackages.php +++ b/www/class/inclusions/op_signPackages.php @@ -12,6 +12,7 @@ public function op_signPackages() { global $GPG_KEYID; global $PASSPHRASE_FILE; global $TEMP_DIR; + global $PID_DIR; ob_start(); @@ -19,6 +20,12 @@ public function op_signPackages() { // Si c'est Redhat/Centos on resigne les paquets // Si c'est Debian on signe le repo (Release.gpg) if ($this->signed == "yes" OR $this->gpgResign == "yes") { + $descriptors = array( + 0 => array('file', 'php://stdin', 'r'), + 1 => array('file', 'php://stdout', 'w'), + 2 => array('pipe', 'w') + ); + if ($OS_FAMILY == "Redhat") { echo '
Signature des paquets (GPG) '; echo 'en cours'; @@ -29,32 +36,10 @@ public function op_signPackages() { // On se mets à la racine du repo // Activation de globstar (**), cela permet à bash d'aller chercher des fichiers .rpm récursivement, peu importe le nb de sous-répertoires if (file_exists("/usr/bin/rpmresign")) { - exec("shopt -s globstar && cd '${REPOS_DIR}/${DATE_JMA}_{$this->name}' && /usr/bin/rpmresign --path '${GPGHOME}' --name '${GPG_KEYID}' --passwordfile '${PASSPHRASE_FILE}' **/*.rpm >> {$this->log->steplog} 2>&1", $output, $result); - } else { - exec("shopt -s globstar && cd '${REPOS_DIR}/${DATE_JMA}_{$this->name}' && rpmsign --addsign **/*.rpm >> {$this->log->steplog} 2>&1", $output, $result); // Sinon on utilise rpmsign et on demande le mdp à l'utilisateur (pas possible d'utiliser un fichier passphrase) - } - echo ''; - - $this->logcontent = ob_get_clean(); file_put_contents($this->log->steplog, $this->logcontent, FILE_APPEND); ob_start(); - - if ($result == 0) { - echo ''; - } else { - echo ''; - echo '
Erreur : la signature des paquets a échouée'; - echo '
Suppression de ce qui a été fait : '; - exec ("rm -rf '${REPOS_DIR}/${DATE_JMA}_{$this->name}'"); - echo 'OK'; - $this->logcontent = ob_get_clean(); file_put_contents($this->log->steplog, $this->logcontent, FILE_APPEND); ob_start(); - throw new Exception(); - } - $this->logcontent = ob_get_clean(); file_put_contents($this->log->steplog, $this->logcontent, FILE_APPEND); + //exec("shopt -s globstar && cd '${REPOS_DIR}/${DATE_JMA}_{$this->name}' && /usr/bin/rpmresign --path '${GPGHOME}' --name '${GPG_KEYID}' --passwordfile '${PASSPHRASE_FILE}' **/*.rpm >> {$this->log->steplog} 2>&1", $output, $result); + $process = proc_open("shopt -s globstar && cd '${REPOS_DIR}/${DATE_JMA}_{$this->name}' && /usr/bin/rpmresign --path '${GPGHOME}' --name '${GPG_KEYID}' --passwordfile '${PASSPHRASE_FILE}' **/*.rpm 1>&2", $descriptors, $pipes); + } //else { utilisation de rpm-sign (ne fonctionne pas car affiche un prompt pour demander la passphrase) + //exec("shopt -s globstar && cd '${REPOS_DIR}/${DATE_JMA}_{$this->name}' && rpmsign --addsign **/*.rpm >> {$this->log->steplog} 2>&1", $output, $result); // Sinon on utilise rpmsign et on demande le mdp à l'utilisateur (pas possible d'utiliser un fichier passphrase) } if ($OS_FAMILY == "Debian") { @@ -73,40 +58,83 @@ public function op_signPackages() { // Après avoir déplacé tous les paquets on peut supprimer tout le contenu de la section exec("rm -rf ${REPOS_DIR}/{$this->name}/{$this->dist}/${DATE_JMA}_{$this->section}/*"); // Création du répertoire conf et des fichiers de conf du repo - mkdir("${REPOS_DIR}/{$this->name}/{$this->dist}/${DATE_JMA}_{$this->section}/conf", 0770, true); + if (!mkdir("${REPOS_DIR}/{$this->name}/{$this->dist}/${DATE_JMA}_{$this->section}/conf", 0770, true)) { + throw new Exception("

Erreur : impossible de créer le répertoire de configuration du repo (conf)

"); + } // Création du fichier "distributions" - // echo -e "Origin: Repo $this->name sur ${WWW_HOSTNAME}\nLabel: apt repository\nCodename: {$this->dist}\nArchitectures: i386 amd64\nComponents: {$this->section}\nDescription: Miroir du repo {$this->name}, distribution {$this->dist}, section {$this->section}\nSignWith: ${GPG_KEYID}\nPull: {$this->section}" > conf/distributions - file_put_contents("${REPOS_DIR}/{$this->name}/{$this->dist}/${DATE_JMA}_{$this->section}/conf/distributions", "Origin: Repo $this->name sur ${WWW_HOSTNAME}\nLabel: apt repository\nCodename: {$this->dist}\nArchitectures: i386 amd64\nComponents: {$this->section}\nDescription: Miroir du repo {$this->name}, distribution {$this->dist}, section {$this->section}\nSignWith: ${GPG_KEYID}\nPull: {$this->section}".PHP_EOL); + if (!file_put_contents("${REPOS_DIR}/{$this->name}/{$this->dist}/${DATE_JMA}_{$this->section}/conf/distributions", "Origin: Repo $this->name sur ${WWW_HOSTNAME}\nLabel: apt repository\nCodename: {$this->dist}\nArchitectures: i386 amd64\nComponents: {$this->section}\nDescription: Miroir du repo {$this->name}, distribution {$this->dist}, section {$this->section}\nSignWith: ${GPG_KEYID}\nPull: {$this->section}".PHP_EOL)) { + throw new Exception('

Erreur : impossible de créer le fichier de configuration du repo (distributions)

'); + } // Création du fichier "options" - // echo -e "basedir ${REPOS_DIR}/{$this->name}/{$this->dist}/${DATE_JMA}_{$this->section}\nask-passphrase" > conf/options - file_put_contents("${REPOS_DIR}/{$this->name}/{$this->dist}/${DATE_JMA}_{$this->section}/conf/options", "basedir ${REPOS_DIR}/{$this->name}/{$this->dist}/${DATE_JMA}_{$this->section}\nask-passphrase".PHP_EOL); + if (!file_put_contents("${REPOS_DIR}/{$this->name}/{$this->dist}/${DATE_JMA}_{$this->section}/conf/options", "basedir ${REPOS_DIR}/{$this->name}/{$this->dist}/${DATE_JMA}_{$this->section}\nask-passphrase".PHP_EOL)) { + throw new Exception('

Erreur : impossible de créer le fichier de configuration du repo (options)

'); + } // Création du repo en incluant les paquets deb du répertoire temporaire, et signature du fichier Release - exec("cd ${REPOS_DIR}/{$this->name}/{$this->dist}/${DATE_JMA}_{$this->section}/ && /usr/bin/reprepro --gnupghome ${GPGHOME} includedeb {$this->dist} ${TMP_DIR}/*.deb >> {$this->log->steplog} 2>&1", $output, $result); - echo ''; - - $this->logcontent = ob_get_clean(); file_put_contents($this->log->steplog, $this->logcontent, FILE_APPEND); ob_start(); + //exec("cd ${REPOS_DIR}/{$this->name}/{$this->dist}/${DATE_JMA}_{$this->section}/ && /usr/bin/reprepro --gnupghome ${GPGHOME} includedeb {$this->dist} ${TMP_DIR}/*.deb >> {$this->log->steplog} 2>&1", $output, $result); + $process = proc_open("exec /usr/bin/reprepro --basedir ${REPOS_DIR}/{$this->name}/{$this->dist}/${DATE_JMA}_{$this->section}/ --gnupghome ${GPGHOME} includedeb {$this->dist} ${TMP_DIR}/*.deb 1>&2", $descriptors, $pipes); + } - // Suppression du répertoire temporaire - exec("rm -rf '$TMP_DIR'"); - if ($result == 0) { - echo ''; - } else { - echo ''; - echo "
Erreur : la signature de la section $this->section du repo $this->name a échouée"; - echo '
Suppression de ce qui a été fait : '; - exec("rm -rf '${REPOS_DIR}/{$this->name}/{$this->dist}/${DATE_JMA}_{$this->section}'"); - echo 'OK'; - $this->logcontent = ob_get_clean(); file_put_contents($this->log->steplog, $this->logcontent, FILE_APPEND); ob_start(); - throw new Exception(); + // Récupération du pid et du status du process lancé + $proc_details = proc_get_status($process); + // Ecriture du pid de reposync/debmirror (lancé par proc_open) dans le fichier PID principal, ceci afin qu'il puisse être killé si l'utilisateur le souhaites + file_put_contents("${PID_DIR}/{$this->log->pid}.pid", "SUBPID=\"".$proc_details['pid']."\"".PHP_EOL, FILE_APPEND); + + /** + * Tant que le process (lancé par proc_open) n'est pas terminé, on boucle afin de ne pas continuer les étapes suivantes + */ + do { + $status = proc_get_status($process); + + // If our stderr pipe has data, grab it for use later. + if (!feof($pipes[2])) { + + // We're acting like passthru would and displaying errors as they come in. + $error_line = fgets($pipes[2]); + file_put_contents($this->log->steplog, $error_line, FILE_APPEND); } - $this->logcontent = ob_get_clean(); file_put_contents($this->log->steplog, $this->logcontent, FILE_APPEND); + } while ($status['running'] === true); + + /** + * Clôture du process + */ + proc_close($process); + echo ''; + $this->logcontent = ob_get_clean(); file_put_contents($this->log->steplog, $this->logcontent, FILE_APPEND); ob_start(); + + /** + * Suppression du répertoire temporaire + */ + if ($OS_FAMILY == "Debian") { + exec("rm -rf '$TMP_DIR'"); } + + /** + * Récupération du code d'erreur de reposync/debmirror + */ + $return = $status['exitcode']; + + if ($return == 0) { + echo ''; + } else { + echo ''; + if ($OS_FAMILY == "Redhat") { echo '
Erreur : la signature des paquets a échouée'; } + if ($OS_FAMILY == "Debian") { echo "
Erreur : la signature de la section $this->section du repo $this->name a échouée"; } + echo '
Suppression de ce qui a été fait : '; + if ($OS_FAMILY == "Redhat") { exec("rm -rf '${REPOS_DIR}/${DATE_JMA}_{$this->name}'"); } + if ($OS_FAMILY == "Debian") { exec("rm -rf '${REPOS_DIR}/{$this->name}/{$this->dist}/${DATE_JMA}_{$this->section}'"); } + echo 'OK'; + $this->logcontent = ob_get_clean(); file_put_contents($this->log->steplog, $this->logcontent, FILE_APPEND); ob_start(); + throw new Exception(); + } + + $this->logcontent = ob_get_clean(); file_put_contents($this->log->steplog, $this->logcontent, FILE_APPEND); ob_start(); + } return true; } diff --git a/www/class/inclusions/restore.php b/www/class/inclusions/restore.php index 18435529..e76647dc 100644 --- a/www/class/inclusions/restore.php +++ b/www/class/inclusions/restore.php @@ -117,12 +117,12 @@ public function restore() { */ if ($OS_FAMILY == "Redhat") { if (!file_exists("${REPOS_DIR}/{$this->name}_{$this->env}")) { - exec("cd ${REPOS_DIR} && ln -s {$this->dateFormatted}_{$this->name}/ {$this->name}_{$this->env}"); + exec("cd ${REPOS_DIR} && ln -sfn {$this->dateFormatted}_{$this->name}/ {$this->name}_{$this->env}"); } } if ($OS_FAMILY == "Debian") { if (!file_exists("${REPOS_DIR}/{$this->name}/{$this->dist}/{$this->name}_{$this->env}")) { - exec("cd ${REPOS_DIR}/{$this->name}/{$this->dist}/ && ln -s {$this->dateFormatted}_{$this->section}/ {$this->section}_{$this->env}"); + exec("cd ${REPOS_DIR}/{$this->name}/{$this->dist}/ && ln -sfn {$this->dateFormatted}_{$this->section}/ {$this->section}_{$this->env}"); } } diff --git a/www/common-groupslist.inc.php b/www/common-groupslist.inc.php index be8493cf..f3413980 100644 --- a/www/common-groupslist.inc.php +++ b/www/common-groupslist.inc.php @@ -25,7 +25,7 @@ ?> -
GESTION DES GROUPES
+
GROUPES

Les groupes permettent de regrouper plusieurs repos afin de les trier ou d'effectuer une action commune.


diff --git a/www/common-header.inc.php b/www/common-header.inc.php index c55ac9e2..1303c13f 100644 --- a/www/common-header.inc.php +++ b/www/common-header.inc.php @@ -1,4 +1,7 @@ Mode debug activé'; if (!empty($_POST)) { @@ -13,48 +16,123 @@ } } ?> -
- +
+ + 0) { echo '
-
- Certains paramètres de configuration de l\'onglet Paramètres sont vides, ce qui pourrait engendrer un dysfonctionnement de Repomanager. Il est recommandé de terminer la configuration avant d\'exécuter quelconque opération. -
+
+ Certains paramètres de configuration de l\'onglet Paramètres sont vides, ce qui pourrait engendrer un dysfonctionnement de Repomanager. Il est recommandé de terminer la configuration avant d\'exécuter quelconque opération. +
'; } ?> diff --git a/www/common-repos-archive-list.inc.php b/www/common-repos-archive-list.inc.php index d9e40b3b..7d828dc4 100644 --- a/www/common-repos-archive-list.inc.php +++ b/www/common-repos-archive-list.inc.php @@ -69,22 +69,22 @@ echo ''; // Si la vue simplifiée est activée (masquage du nom de repo si similaire au précédent) : if ($concatenateReposName == "yes" AND $repoName === $repoLastName) { - echo ''; + echo ''; } else { - echo "$repoName"; + echo "$repoName"; } if ($OS_FAMILY == "Debian") { // Si la vue simplifiée est activée (masquage du nom de repo si similaire au précédent) : if ($concatenateReposName == "yes" AND $repoName === $repoLastName AND $repoDist === $repoLastDist) { - echo ''; + echo ''; } else { - echo "$repoDist"; + echo "$repoDist"; } // Si la vue simplifiée est activée (masquage du nom de repo si similaire au précédent) : if ($concatenateReposName == "yes" AND $repoName === $repoLastName AND $repoDist === $repoLastDist AND $repoSection === $repoLastSection) { - echo ''; + echo ''; } else { - echo "$repoSection"; + echo "$repoSection"; } } echo "$repoDate"; diff --git a/www/common-repos-list-filter-groups.inc.php b/www/common-repos-list-filter-groups.inc.php index 00e66907..87cbb728 100644 --- a/www/common-repos-list-filter-groups.inc.php +++ b/www/common-repos-list-filter-groups.inc.php @@ -119,26 +119,26 @@ // Si la vue simplifiée est activée (masquage du nom de repo si similaire au précédent) : if ($concatenateReposName == "yes" AND $repoName === $repoLastName) { - echo ''; + echo ''; } else { - echo "$repoName"; + echo "$repoName"; } if ($OS_FAMILY == "Debian") { // Si la vue simplifiée est activée (masquage du nom de repo si similaire au précédent) : if ($concatenateReposName == "yes" AND $repoName === $repoLastName AND $repoDist === $repoLastDist) { echo ''; - echo ''; + echo ''; } else { echo ""; // td de toute petite taille, permettra d'afficher une icone 'corbeille' avant chaque distribution - echo "$repoDist"; + echo "$repoDist"; } // Si la vue simplifiée est activée (masquage du nom de repo si similaire au précédent) : if ($concatenateReposName == "yes" AND $repoName === $repoLastName AND $repoDist === $repoLastDist AND $repoSection === $repoLastSection) { echo ""; // td de toute petite taille, permettra d'afficher une icone 'corbeille' avant chaque section - echo ''; + echo ''; } else { echo ""; // td de toute petite taille, permettra d'afficher une icone 'corbeille' avant chaque section - echo "$repoSection"; + echo "$repoSection"; } } diff --git a/www/common-repos-list.inc.php b/www/common-repos-list.inc.php index 0c445e50..44ffc69c 100644 --- a/www/common-repos-list.inc.php +++ b/www/common-repos-list.inc.php @@ -25,7 +25,8 @@
" method="post"> - Informations

+ '; // Valeur par défaut = "off" sauf si celle ci est overwritée par la checkbox cochée "on" if ($printRepoSize == "yes") { @@ -52,7 +53,9 @@ echo ''; } echo '
'; - + ?> +

Filtrage

+ '; // Valeur par défaut = "off" sauf si celle ci est overwritée par la checkbox cochée "on" if ($filterByGroups == "yes") { diff --git a/www/configuration.php b/www/configuration.php index 00d91803..fb1d453a 100644 --- a/www/configuration.php +++ b/www/configuration.php @@ -22,15 +22,18 @@ */ if ($UPDATE_BACKUP_ENABLED == "yes") { if (!is_dir($UPDATE_BACKUP_DIR)) { - if (!mkdir($UPDATE_BACKUP_DIR)) { + if (!mkdir($UPDATE_BACKUP_DIR, 0770, true)) { $error++; $errorMsg = "Erreur : impossible de créer le répertoire de sauvegarde $UPDATE_BACKUP_DIR"; } } else { - exec("tar xzf /tmp/${DATE_AMJ}_${HEURE}_repomanager_backup.tar.gz $WWW_DIR" ,$output, $result); + $backupName = "${DATE_AMJ}_${HEURE}_repomanager_backup.tar.gz"; + exec("tar czf /tmp/${backupName} $WWW_DIR" ,$output, $result); if ($result != 0) { $error++; $errorMsg = 'Erreur lors de la sauvegarde de la configuration actuelle de repomanager'; + } else { + exec("mv /tmp/${backupName} $UPDATE_BACKUP_DIR/"); } } } @@ -140,7 +143,7 @@ } // création du nouveau avec le nouveau prefix : - exec("cd ${PROFILES_MAIN_DIR}/${profileName}/ && ln -s ${REPOS_PROFILES_CONF_DIR}/${newSymlinkName}"); + exec("cd ${PROFILES_MAIN_DIR}/${profileName}/ && ln -sfn ${REPOS_PROFILES_CONF_DIR}/${newSymlinkName}"); } } } @@ -369,7 +372,7 @@ * On écrit toutes les modifications dans le fichier display.ini */ - write_ini_file("$REPOMANAGER_CONF", $repomanager_conf_array); + write_ini_file($REPOMANAGER_CONF, $repomanager_conf_array); /** * On appelle enableCron pour qu'il ré-écrive / supprime les lignes de la crontab @@ -412,14 +415,14 @@ $actualEnvTotal = "${actualEnvTotal}\n${actualEnvName}"; } // On ré-écrit le tout dans le fichier envs.conf - file_put_contents("$ENV_CONF", "[ENVIRONNEMENTS]${actualEnvTotal}".PHP_EOL); + file_put_contents($ENV_CONF, "[ENVIRONNEMENTS]${actualEnvTotal}".PHP_EOL); } // Ajout d'un nouvel environnement if (!empty($_POST['newEnv'])) { $newEnv = validateData($_POST['newEnv']); // On écrit le nouvel env dans le fichier envs.conf, avant 'prod' - file_put_contents("$ENV_CONF", "${newEnv}".PHP_EOL,FILE_APPEND); + file_put_contents($ENV_CONF, "${newEnv}".PHP_EOL,FILE_APPEND); // Puis rechargement de la page pour appliquer les modifications de configuration header('Location: configuration.php'); } @@ -482,15 +485,24 @@ - '; - } - if (!empty($updateStatus)) { echo $updateStatus; } - if (empty($UPDATE_BRANCH)) { echo ''; } + if ($UPDATE_AVAILABLE == "yes") { + echo ''; + echo ''; + echo ''; + } + if (empty($UPDATE_BRANCH)) { echo ''; } + ?> + + '; + echo ''; + echo $updateStatus; + echo ''; + echo ''; + } ?> - Sauvegarde avant mise à jour diff --git a/www/functions/common-functions.php b/www/functions/common-functions.php index 606c232d..3cae0297 100644 --- a/www/functions/common-functions.php +++ b/www/functions/common-functions.php @@ -2,42 +2,42 @@ // Fonction de vérification des données envoyées par formulaire function validateData($data) { - $data = trim($data); - $data = stripslashes($data); - $data = htmlspecialchars($data); - return $data; + $data = trim($data); + $data = stripslashes($data); + $data = htmlspecialchars($data); + return $data; } function clearCache($WWW_CACHE) { - // Suppression du cache serveur - // 2 cas possibles : - // il s'agit d'un répertoire classique sur le disque - // ou il s'agit d'un lien symbolique vers /dev/smh (en ram) - if (file_exists("${WWW_CACHE}/repos-list-filter-group.html")) { unlink("${WWW_CACHE}/repos-list-filter-group.html"); } - if (file_exists("${WWW_CACHE}/repos-list-no-filter.html")) { unlink("${WWW_CACHE}/repos-list-no-filter.html"); } - if (is_link($WWW_CACHE)) { unlink($WWW_CACHE); } - if (is_dir($WWW_CACHE)) { rmdir($WWW_CACHE); } - - // Vidage du cache navigateur - echo ""; + // Suppression du cache serveur + // 2 cas possibles : + // il s'agit d'un répertoire classique sur le disque + // ou il s'agit d'un lien symbolique vers /dev/smh (en ram) + if (file_exists("${WWW_CACHE}/repos-list-filter-group.html")) { unlink("${WWW_CACHE}/repos-list-filter-group.html"); } + if (file_exists("${WWW_CACHE}/repos-list-no-filter.html")) { unlink("${WWW_CACHE}/repos-list-no-filter.html"); } + if (is_link($WWW_CACHE)) { unlink($WWW_CACHE); } + if (is_dir($WWW_CACHE)) { rmdir($WWW_CACHE); } + + // Vidage du cache navigateur + echo ""; } // Fonction permettant d'afficher une bulle d'alerte au mileu de la page function printAlert($message) { - echo '
'; - echo "

${message}

"; - echo '
'; - echo ''; + echo '
'; + echo "

${message}

"; + echo '
'; + echo ''; } // Fonction affichant un message de confirmation avant de supprimer @@ -46,349 +46,307 @@ function printAlert($message) { // $divID = un id unique du div caché contenant le message et les bouton supprimer ou annuler // $aID = une class avec un ID unique du bouton cliquable permettant d'afficher/fermer la div caché. Attention le bouton d'affichage doit être avant l'appel de cette fonction. function deleteConfirm($message, $url, $divID, $aID) { - echo "
"; - echo "

${message}

"; - echo '
'; - echo "Supprimer"; - echo "Annuler"; - echo ""; - echo '
'; - - unset($message, $url, $divID, $aID); + echo "
"; + echo "

${message}

"; + echo '
'; + echo "Supprimer"; + echo "Annuler"; + echo ""; + echo '
'; + unset($message, $url, $divID, $aID); } function operationRunning() { - global $PID_DIR; - - if (!empty(exec("grep 'repomanager_' ${PID_DIR}/*.pid"))) { - return true; - } - return false; + global $PID_DIR; + + $datas = array(); + $pidFiles = shell_exec("grep -l 'repomanager_' ${PID_DIR}/*.pid"); + if (!empty($pidFiles)) { + $pidFiles = explode("\n", trim($pidFiles)); + foreach($pidFiles as $pidFile) { + $pid = exec("grep -h '^PID=' $pidFile | sed 's/PID=//g' | sed 's/\"//g'"); + $logFile = exec("grep -h '^LOG=' $pidFile | sed 's/LOG=//g' | sed 's/\"//g'"); + $action = exec("grep -h '^ACTION=' $pidFile | sed 's/ACTION=//g' | sed 's/\"//g'"); + $name = exec("grep -h '^NAME=' $pidFile | sed 's/NAME=//g' | sed 's/\"//g'"); + $dist = exec("grep -h '^DIST=' $pidFile | sed 's/DIST=//g' | sed 's/\"//g'"); + $section = exec("grep -h '^SECTION=' $pidFile | sed 's/SECTION=//g' | sed 's/\"//g'"); + $data = ['pidFile' => $pidFile, 'pid' => $pid , 'logFile' => $logFile, 'action' => $action, 'name' => $name, 'dist' => $dist, 'section' => $section]; + $datas[] = $data; + } + return $datas; + } + return false; } function planificationRunning() { - global $PID_DIR; - - if (!empty(exec("grep 'plan_' ${PID_DIR}/*.pid"))) { - return true; - } - return false; + global $PID_DIR; + + $datas = array(); + $pidFiles = shell_exec("grep -l 'plan_' ${PID_DIR}/*.pid"); + if (!empty($pidFiles)) { + $pidFiles = explode("\n", trim($pidFiles)); + foreach($pidFiles as $pidFile) { + $pid = exec("grep -h '^PID=' $pidFile | sed 's/PID=//g' | sed 's/\"//g'"); + $logFile = exec("grep -h '^LOG=' $pidFile | sed 's/LOG=//g' | sed 's/\"//g'"); + $action = exec("grep -h '^ACTION=' $pidFile | sed 's/ACTION=//g' | sed 's/\"//g'"); + $name = exec("grep -h '^NAME=' $pidFile | sed 's/NAME=//g' | sed 's/\"//g'"); + $dist = exec("grep -h '^DIST=' $pidFile | sed 's/DIST=//g' | sed 's/\"//g'"); + $section = exec("grep -h '^SECTION=' $pidFile | sed 's/SECTION=//g' | sed 's/\"//g'"); + $data = ['pidFile' => $pidFile, 'pid' => $pid , 'logFile' => $logFile, 'action' => $action, 'name' => $name, 'dist' => $dist, 'section' => $section]; + $datas[] = $data; + } + return $datas; + } + +/* if (!empty(exec("grep 'plan_' ${PID_DIR}/*.pid"))) { + return true; + }*/ + return false; } function selectlogs() { - global $MAIN_LOGS_DIR; - - // Si un fichier de log est actuellement sélectionné (en GET) alors on récupère son nom afin qu'il soit sélectionné dans la liste déroulante (s'il apparait) - if (!empty($_GET['logfile'])) { - $currentLogfile = validateData($_GET['logfile']); - } else { - $currentLogfile = ''; - } - - // On récupère la liste des fichiers de logs en les triant - $logfiles = scandir("$MAIN_LOGS_DIR/", SCANDIR_SORT_DESCENDING); - echo ''; - echo ''; - echo ''; - echo '
'; - - unset($logfiles, $logfile, $logfileDate, $logfileTime); + global $MAIN_LOGS_DIR; + + // Si un fichier de log est actuellement sélectionné (en GET) alors on récupère son nom afin qu'il soit sélectionné dans la liste déroulante (s'il apparait) + if (!empty($_GET['logfile'])) { + $currentLogfile = validateData($_GET['logfile']); + } else { + $currentLogfile = ''; + } + + // On récupère la liste des fichiers de logs en les triant sur la date + $logfiles = explode("\n", shell_exec("cd $MAIN_LOGS_DIR && ls -A1 'repomanager_'* | sort -t _ -k3 -r")); + echo '
'; + echo ''; + echo ''; + echo '
'; + unset($logfiles, $logfile, $logfileDate, $logfileTime); } function selectPlanlogs() { - global $MAIN_LOGS_DIR; - - // Si un fichier de log est actuellement sélectionné (en GET) alors on récupère son nom afin qu'il soit sélectionné dans la liste déroulante (s'il apparait) - if (!empty($_GET['logfile'])) { - $currentLogfile = validateData($_GET['logfile']); - } else { - $currentLogfile = ''; - } - - // On récupère la liste des fichiers de logs en les triant - $logfiles = scandir("$MAIN_LOGS_DIR/", SCANDIR_SORT_DESCENDING); - echo '
'; - echo ''; + echo ""; foreach($logfiles as $logfile) { - // on ne souhaite pas afficher les répertoires '..' '.' ni le fichier lastlog.log (déjà affiché en premier ci-dessus) et on souhaite uniquement afficher les fichier commencant par repomanager_ - if (($logfile != "..") AND ($logfile != ".") AND ($logfile != "lastlog.log") AND preg_match('/^plan_/',$logfile)) { - // Formatage du nom du fichier afin d'afficher quelque chose de plus propre dans la liste - $logfileDate = exec("echo $logfile | awk -F '_' '{print $3}'"); - $logfileDate = DateTime::createFromFormat('Y-m-d', $logfileDate)->format('d-m-Y'); - $logfileTime = exec("echo $logfile | awk -F '_' '{print $4}' | sed 's/.log//g'"); - $logfileTime = DateTime::createFromFormat('H-i-s', $logfileTime)->format('H:i:s'); - if ($logfile === $currentLogfile) { - echo ""; - } else { - echo ""; - } - } + // on ne souhaite pas afficher les répertoires '..' '.' ni le fichier lastlog.log (déjà affiché en premier ci-dessus) et on souhaite uniquement afficher les fichier commencant par repomanager_ + if (($logfile != "..") AND ($logfile != ".") AND ($logfile != "lastlog.log") AND preg_match('/^plan_/',$logfile)) { + // Formatage du nom du fichier afin d'afficher quelque chose de plus propre dans la liste + $logfileDate = exec("echo $logfile | awk -F '_' '{print $3}'"); + $logfileDate = DateTime::createFromFormat('Y-m-d', $logfileDate)->format('d-m-Y'); + $logfileTime = exec("echo $logfile | awk -F '_' '{print $4}' | sed 's/.log//g'"); + $logfileTime = DateTime::createFromFormat('H-i-s', $logfileTime)->format('H:i:s'); + if ($logfile === $currentLogfile) { + echo ""; + } else { + echo ""; + } + } } echo ''; echo ''; - echo '
'; - - unset($logfiles, $logfile, $logfileDate, $logfileTime); + echo ''; + unset($logfiles, $logfile, $logfileDate, $logfileTime); } function reloadPage($actual_uri) { - header("location: $actual_uri"); + header("location: $actual_uri"); } // Rechargement d'une div en fournissant sa class function refreshdiv_class($divclass) { - if (!empty($divclass)) { - echo ''; - } + if (!empty($divclass)) { + echo ''; + } } // Affichage d'une div cachée function showdiv_byclass($divclass) { - echo ''; + echo ''; } function showdiv_byid($divid) { - echo ''; + echo ''; } function animatediv_byid($divid) { - echo ""; -} - -// Suppression d'un repo d'un groupe en particulier -function deleteRepoFromGroup($repoName, $groupName) { - global $GROUPS_CONF; - $error = 0; - - // on formatte la chaine à supprimer à partir des infos récupérées en POST - $groupDelContent = "Name=\"${repoName}\""; - // on supprime le repo en question, situé entre [@groupName] et la prochaine ligne vide - exec("sed -i '/^\[${groupName}\]/,/^$/{/^\(^${groupDelContent}$\)/d}' $GROUPS_CONF"); - // Affichage d'un message - printAlert("Le repo $repoName a été retiré du groupe $groupName"); - - unset($repoName, $groupDelContent, $groupName); -} -// Suppression d'une section d'un groupe en particulier -function deleteSectionFromGroup($repoName, $groupName) { - global $GROUPS_CONF; - $error = 0; - - // Pour Debian, la variable $repoName contient le nom du repo, la dist et la section séparés par un | - // Du coup on explose $addPlanRepo pour en extraire les 3 valeurs - $repoNameExplode = explode('|', $repoName); - $repoName = $repoNameExplode[0]; - $repoDist = $repoNameExplode[1]; - $repoSection = $repoNameExplode[2]; - // Si la distribution comporte un slash, il faut l'échapper - //$repoDist = str_replace('/', '\\\/', $repoDist); - // on formatte la chaine à supprimer à partir des infos récupérées en POST - $groupDelContent = "Name=\"${repoName}\",Dist=\"${repoDist}\",Section=\"${repoSection}\""; - // on supprime le repo en question, situé entre [@groupName] et la prochaine ligne vide - exec("sed -i '/^\[${groupName}\]/,/^$/{/^\(^${groupDelContent}$\)/d}' $GROUPS_CONF"); - // Ré-écrit le contenu dans le fichier de groupes - // Affichage d'un message - printAlert("La section $repoSection du repo $repoName a été retirée du groupe $groupName"); - - unset($repoName, $groupDelContent, $groupName); -} - -// Suppression d'un repo de tous les groupes où il apparait -function deleteRepoFromAllGroup($repoName) { - global $GROUPS_CONF; - - // Récupération du contenu du fichier de groupes - $content = file_get_contents("$GROUPS_CONF"); - $content = preg_replace("/Name=\"${repoName}\".*/", "", $content); - // Ré-écrit le contenu dans le fichier de groupes - file_put_contents("$GROUPS_CONF", $content); - unset($repoName, $content); -} - -// Suppression d'une section de tous les groupes où elle apparait -function deleteSectionFromAllGroup($repoName) { - global $GROUPS_CONF; - - // Pour Debian, la variable $repoName contient le nom du repo, la dist et la section séparés par un | - // Du coup on explose $addPlanRepo pour en extraire les 3 valeurs - $repoNameExplode = explode('|', $repoName); - $repoName = $repoNameExplode[0]; - $repoDist = $repoNameExplode[1]; - $repoSection = $repoNameExplode[2]; - - // Récupération du contenu du fichier de groupes - $content = file_get_contents("$GROUPS_CONF"); - $content = preg_replace("/Name=\"${repoName}\",Dist=\"$repoDist\",Section=\"$repoSection\".*/", "", $content); - // Ré-écrit le contenu dans le fichier de groupes - file_put_contents("$GROUPS_CONF", $content); - unset($repoName, $content); + "; } function checkCronReminder() { - $cronStatus = shell_exec("crontab -l | grep 'planifications/plan.php' | grep -v '#'"); - if (empty($cronStatus)) { - return 'Off'; - } else { - return 'On'; - } + $cronStatus = shell_exec("crontab -l | grep 'planifications/plan.php' | grep -v '#'"); + if (empty($cronStatus)) { + return 'Off'; + } else { + return 'On'; + } } if (!function_exists('write_ini_file')) { - /** - * Write an ini configuration file - * - * @param string $file - * @param array $array - * @return bool - */ - function write_ini_file($file, $array = []) { - // check first argument is string - if (!is_string($file)) { - throw new \InvalidArgumentException('Function argument 1 must be a string.'); - } - - // check second argument is array - if (!is_array($array)) { - throw new \InvalidArgumentException('Function argument 2 must be an array.'); - } - - // process array - $data = array(); - foreach ($array as $key => $val) { - if (is_array($val)) { - $data[] = "[$key]"; - foreach ($val as $skey => $sval) { - if (is_array($sval)) { - foreach ($sval as $_skey => $_sval) { - if (is_numeric($_skey)) { - $data[] = $skey.'[] = '.(is_numeric($_sval) ? $_sval : (ctype_upper($_sval) ? $_sval : '"'.$_sval.'"')); - } else { - $data[] = $skey.'['.$_skey.'] = '.(is_numeric($_sval) ? $_sval : (ctype_upper($_sval) ? $_sval : '"'.$_sval.'"')); - } - } - } else { - $data[] = $skey.' = '.(is_numeric($sval) ? $sval : (ctype_upper($sval) ? $sval : '"'.$sval.'"')); - } - } - } else { - $data[] = $key.' = '.(is_numeric($val) ? $val : (ctype_upper($val) ? $val : '"'.$val.'"')); - } - // empty line - $data[] = null; - } - - // open file pointer, init flock options - $fp = fopen($file, 'w'); - $retries = 0; - $max_retries = 100; - - if (!$fp) { - return false; - } - - // loop until get lock, or reach max retries - do { - if ($retries > 0) { - usleep(rand(1, 5000)); - } - $retries += 1; - } while (!flock($fp, LOCK_EX) && $retries <= $max_retries); - - // couldn't get the lock - if ($retries == $max_retries) { - return false; - } - - // got lock, write data - fwrite($fp, implode(PHP_EOL, $data).PHP_EOL); - - // release lock - flock($fp, LOCK_UN); - fclose($fp); - - return true; - } + /** + * Write an ini configuration file + * + * @param string $file + * @param array $array + * @return bool + */ + function write_ini_file($file, $array = []) { + // check first argument is string + if (!is_string($file)) { + throw new \InvalidArgumentException('Function argument 1 must be a string.'); + } + + // check second argument is array + if (!is_array($array)) { + throw new \InvalidArgumentException('Function argument 2 must be an array.'); + } + + // process array + $data = array(); + foreach ($array as $key => $val) { + if (is_array($val)) { + $data[] = "[$key]"; + foreach ($val as $skey => $sval) { + if (is_array($sval)) { + foreach ($sval as $_skey => $_sval) { + if (is_numeric($_skey)) { + $data[] = $skey.'[] = '.(is_numeric($_sval) ? $_sval : (ctype_upper($_sval) ? $_sval : '"'.$_sval.'"')); + } else { + $data[] = $skey.'['.$_skey.'] = '.(is_numeric($_sval) ? $_sval : (ctype_upper($_sval) ? $_sval : '"'.$_sval.'"')); + } + } + } else { + $data[] = $skey.' = '.(is_numeric($sval) ? $sval : (ctype_upper($sval) ? $sval : '"'.$sval.'"')); + } + } + } else { + $data[] = $key.' = '.(is_numeric($val) ? $val : (ctype_upper($val) ? $val : '"'.$val.'"')); + } + // empty line + $data[] = null; + } + + // open file pointer, init flock options + $fp = fopen($file, 'w'); + $retries = 0; + $max_retries = 100; + + if (!$fp) { + return false; + } + + // loop until get lock, or reach max retries + do { + if ($retries > 0) { + usleep(rand(1, 5000)); + } + $retries += 1; + } while (!flock($fp, LOCK_EX) && $retries <= $max_retries); + + // couldn't get the lock + if ($retries == $max_retries) { + return false; + } + + // got lock, write data + fwrite($fp, implode(PHP_EOL, $data).PHP_EOL); + + // release lock + flock($fp, LOCK_UN); + fclose($fp); + + return true; + } } // Ecrit le contenu de la crontab de $WWW_USER function enableCron() { - global $WWW_DIR; - global $WWW_USER; - global $TEMP_DIR; - global $CRON_DAILY_ENABLED; - global $AUTOMATISATION_ENABLED; - global $CRON_PLAN_REMINDERS_ENABLED; - - // Récupération du contenu de la crontab actuelle dans un fichier temporaire - shell_exec("crontab -l > ${TEMP_DIR}/${WWW_USER}_crontab.tmp"); - - // On supprime toutes les lignes concernant repomanager dans ce fichier pour refaire propre - exec("sed -i '/cronjob_daily.php/d' ${TEMP_DIR}/${WWW_USER}_crontab.tmp"); - exec("sed -i '/plan.php/d' ${TEMP_DIR}/${WWW_USER}_crontab.tmp"); - - // Puis on ajoute les tâches cron suivantes au fichier temporaire - - // Tâche cron journalière - if ($CRON_DAILY_ENABLED == "yes") { - file_put_contents("${TEMP_DIR}/${WWW_USER}_crontab.tmp", "*/5 * * * * php ${WWW_DIR}/operations/cronjob_daily.php".PHP_EOL, FILE_APPEND); - } - - // si on a activé l'automatisation alors on ajoute la tâche cron d'exécution des planifications - if ($AUTOMATISATION_ENABLED == "yes") { - file_put_contents("${TEMP_DIR}/${WWW_USER}_crontab.tmp", "* * * * * php ${WWW_DIR}/planifications/plan.php exec-plans".PHP_EOL, FILE_APPEND); - } - - // si on a activé l'automatisation et les envois de rappels de planifications alors on ajoute la tâche cron d'envoi des rappels - if ($AUTOMATISATION_ENABLED == "yes" AND $CRON_PLAN_REMINDERS_ENABLED == "yes") { - file_put_contents("${TEMP_DIR}/${WWW_USER}_crontab.tmp", "0 0 * * * php ${WWW_DIR}/planifications/plan.php send-reminders".PHP_EOL, FILE_APPEND); - } - - // Enfin on reimporte le contenu du fichier temporaire - exec("crontab ${TEMP_DIR}/${WWW_USER}_crontab.tmp"); // on importe le fichier dans la crontab de $WWW_USER - unlink("${TEMP_DIR}/${WWW_USER}_crontab.tmp"); // puis on supprime le fichier temporaire - - printAlert('Tâches cron redéployées'); + global $WWW_DIR; + global $WWW_USER; + global $TEMP_DIR; + global $CRON_DAILY_ENABLED; + global $AUTOMATISATION_ENABLED; + global $CRON_PLAN_REMINDERS_ENABLED; + + // Récupération du contenu de la crontab actuelle dans un fichier temporaire + shell_exec("crontab -l > ${TEMP_DIR}/${WWW_USER}_crontab.tmp"); + + // On supprime toutes les lignes concernant repomanager dans ce fichier pour refaire propre + exec("sed -i '/cronjob_daily.php/d' ${TEMP_DIR}/${WWW_USER}_crontab.tmp"); + exec("sed -i '/plan.php/d' ${TEMP_DIR}/${WWW_USER}_crontab.tmp"); + + // Puis on ajoute les tâches cron suivantes au fichier temporaire + + // Tâche cron journalière + if ($CRON_DAILY_ENABLED == "yes") { + file_put_contents("${TEMP_DIR}/${WWW_USER}_crontab.tmp", "*/5 * * * * php ${WWW_DIR}/operations/cronjob_daily.php".PHP_EOL, FILE_APPEND); + } + + // si on a activé l'automatisation alors on ajoute la tâche cron d'exécution des planifications + if ($AUTOMATISATION_ENABLED == "yes") { + file_put_contents("${TEMP_DIR}/${WWW_USER}_crontab.tmp", "* * * * * php ${WWW_DIR}/planifications/plan.php exec-plans".PHP_EOL, FILE_APPEND); + } + + // si on a activé l'automatisation et les envois de rappels de planifications alors on ajoute la tâche cron d'envoi des rappels + if ($AUTOMATISATION_ENABLED == "yes" AND $CRON_PLAN_REMINDERS_ENABLED == "yes") { + file_put_contents("${TEMP_DIR}/${WWW_USER}_crontab.tmp", "0 0 * * * php ${WWW_DIR}/planifications/plan.php send-reminders".PHP_EOL, FILE_APPEND); + } + + // Enfin on reimporte le contenu du fichier temporaire + exec("crontab ${TEMP_DIR}/${WWW_USER}_crontab.tmp"); // on importe le fichier dans la crontab de $WWW_USER + unlink("${TEMP_DIR}/${WWW_USER}_crontab.tmp"); // puis on supprime le fichier temporaire + + printAlert('Tâches cron redéployées'); } ?> \ No newline at end of file diff --git a/www/functions/load_common_variables.php b/www/functions/load_common_variables.php index 0b16cbe0..2bda7a13 100644 --- a/www/functions/load_common_variables.php +++ b/www/functions/load_common_variables.php @@ -1,6 +1,8 @@ '; - echo 'Nom de l\'hôte'; - echo ''; - echo ''; - } - if (!empty($_GET['repoSource'])) { - $repoSource = validateData($_GET['repoSource']); - echo ""; - return $repoSource; - } - }*/ // Le nom du repo sera toujours obligatoire if ($argumentName === 'repoName') { if (empty($_GET['repoName'])) { diff --git a/www/planifications.php b/www/planifications.php index 169a0617..ddf07546 100644 --- a/www/planifications.php +++ b/www/planifications.php @@ -21,8 +21,6 @@ $error = 0; // un peu de gestion d'erreur $planDate = validateData($_POST['addPlanDate']); $planTime = validateData($_POST['addPlanTime']); - // on reformate l'heure afin de remplacer ':' par un 'h' (c'est plus parlant) - //$planTime = str_replace(":", "h", $planTime); // on récupère l'action à exécuter $planAction = $_POST['addPlanAction']; // ne pas validateData() car ça transforme '->' en caractères échappés // et les rappels si il y en a @@ -128,7 +126,6 @@ // Cas où on souhaite supprimer une planification if (!empty($_GET['action']) AND (validateData($_GET['action']) == "deletePlan") AND !empty($_GET['planId'])) { $planId = validateData($_GET['planId']); - $planToDelete = new Planification(compact('planId')); $planToDelete->delete(); } @@ -140,428 +137,441 @@
- - -
- -
- -
-
-
PLANIFICATIONS
- '; - } - if ($cronStatus == 'Off') { - echo ''; - }?> -
- -
- - listQueue(); - - /** - * 2. Affichage des planifications si il y en a - */ - if(!empty($planList)) { - echo '

Planifications actives

'; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - if ($OS_FAMILY == "Debian") { - echo ''; - echo ''; - } - echo ''; - - foreach($planList as $plan) { - $planId = $plan['Plan_id']; - $planDate = $plan['Plan_date']; - $planTime = $plan['Plan_time']; - $planAction = $plan['Plan_action']; - $planGroup = $plan['Plan_group']; - $planRepo = $plan['Plan_repo']; - if ($OS_FAMILY == "Debian") { - $planDist = $plan['Plan_dist']; - $planSection = $plan['Plan_section']; - } - $planGpgCheck = $plan['Plan_gpgCheck']; - $planGpgResign = $plan['Plan_gpgResign']; - $planReminder = $plan['Plan_reminder']; - $planStatus = $plan['Plan_status']; - $planLogfile = $plan['Plan_logfile']; - - if (!empty($planGroup) AND empty($planRepo)) { - $planRepoOrGroup = $planGroup; - } - if (empty($planGroup) AND !empty($planRepo)) { - $planRepoOrGroup = $planRepo; - } - if (empty($planReminder)) { - $planReminder = 'Aucun'; - } else { - $planReminder = "$planReminder (jours avant)"; + + + +
+ +
+ + + +
+ +
+ +
+
+
PLANIFICATIONS
+ '; } + if ($cronStatus == 'Off') { + echo ''; + }?> +
+ + +
DateHeureActionRepo ou @groupeDistSection
+ listQueue(); + /** + * 2. Affichage des planifications si il y en a + */ + if(!empty($planList)) { + echo '

Planifications actives

'; echo ''; - echo ""; - echo ""; - echo ""; - echo ""; + echo ''; + echo ''; + echo ''; + echo ''; if ($OS_FAMILY == "Debian") { - if (!empty($planDist)) { - echo ""; - } else { - echo ''; + echo ''; + echo ''; + } + echo ''; + + foreach($planList as $plan) { + $planId = $plan['Plan_id']; + $planDate = $plan['Plan_date']; + $planTime = $plan['Plan_time']; + $planAction = $plan['Plan_action']; + $planGroup = $plan['Plan_group']; + $planRepo = $plan['Plan_repo']; + if ($OS_FAMILY == "Debian") { + $planDist = $plan['Plan_dist']; + $planSection = $plan['Plan_section']; + } + $planGpgCheck = $plan['Plan_gpgCheck']; + $planGpgResign = $plan['Plan_gpgResign']; + $planReminder = $plan['Plan_reminder']; + $planStatus = $plan['Plan_status']; + $planLogfile = $plan['Plan_logfile']; + + if (!empty($planGroup) AND empty($planRepo)) { + $planRepoOrGroup = $planGroup; } - if (!empty($planSection)) { - echo ""; + if (empty($planGroup) AND !empty($planRepo)) { + $planRepoOrGroup = $planRepo; + } + if (empty($planReminder)) { + $planReminder = 'Aucun'; } else { - echo ''; + $planReminder = "$planReminder (jours avant)"; } - } - echo ''; + echo ""; + echo ""; + echo ""; + echo ""; + if ($OS_FAMILY == "Debian") { + if (!empty($planDist)) { + echo ""; + } else { + echo ''; + } + if (!empty($planSection)) { + echo ""; + } else { + echo ''; + } + } + + echo ''; + deleteConfirm("Êtes-vous sûr de vouloir supprimer la planification du $planDate à $planTime", "?action=deletePlan&planId=${planId}", "planDeleteDiv${i}", "planDeleteToggle${i}"); + echo ''; + echo ""; + echo ''; + echo ''; + + // Script JS pour afficher les détails cachés + echo ""; + ++$i; } - if ($planStatus == "running") { - //echo ""; - echo ""; + } ?> +
${planDate}${planTime}${planAction}${planRepoOrGroup}DateHeureActionRepo ou @groupe${planDist}-DistSection
${planSection}-'; - echo ""; - if ($planStatus == "queued") { - echo ""; + echo '
${planDate}${planTime}${planAction}${planRepoOrGroup}${planDist}-${planSection}-'; + echo ""; + if ($planStatus == "queued") { + echo ""; + } + if ($planStatus == "running") { + //echo ""; + echo ""; + } + echo '
'; + echo ''; + if ($planAction == "update") { + echo ""; + echo ""; + } + echo ""; + echo '
GPG Check${planGpgCheck}
GPG Resign${planGpgResign}
Rappels${planReminder}
'; + echo '
+
+
+ +
+

Ajouter une planification

+ + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; - deleteConfirm("Êtes-vous sûr de vouloir supprimer la planification du $planDate à $planTime", "?action=deletePlan&planId=${planId}", "planDeleteDiv${i}", "planDeleteToggle${i}"); echo ''; - echo ""; - echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; echo ''; + echo ''; + echo ''; + echo ''; + echo ""; + ?> + + + +
Date
Heure
Action'; + echo ''; echo '
'; - if ($planAction == "update") { - echo "GPG Check : ${planGpgCheck}
"; - echo "GPG Resign : ${planGpgResign}
"; + echo '
Repo'; + echo ''; + echo 'ou Groupe'; + echo ''; + echo '
GPG check'; + echo ''; + echo ''; + echo ''; + echo ''; + echo '
Re-signer avec GPG'; + if ($GPG_SIGN_PACKAGES == "yes") { + echo ''; + echo ''; + echo ''; + echo ''; + } else { + echo ''; + echo ''; + echo ''; + echo ''; + } echo '
Rappels'; + echo ''; + echo '
+
- // Script JS pour afficher les détails cachés - echo ""; - ++$i; - } - } ?> - - -
- -
-

Ajouter une planification

- '; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo '
Date
Heure
Action'; - echo ''; - echo '
Repo'; - echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + if ($OS_FAMILY == "Debian") { + echo ''; + echo ''; + } + echo ''; + echo ''; + + $i = 0; // Initialisation d'une variable qui servira pour chaque div d'erreur de planification caché, et affiché par js + foreach($plansDone as $plan) { + $planId = $plan['Plan_id']; + $planDate = $plan['Plan_date']; + $planTime = $plan['Plan_time']; + $planAction = $plan['Plan_action']; + $planGroup = $plan['Plan_group']; + $planRepo = $plan['Plan_repo']; if ($OS_FAMILY == "Debian") { - $repoDist = $repo['Dist']; - $repoSection = $repo['Section']; + $planDist = $plan['Plan_dist']; + $planSection = $plan['Plan_section']; } - - // On génère une "; + $planGpgCheck = $plan['Plan_gpgCheck']; + $planGpgResign = $plan['Plan_gpgResign']; + $planReminder = $plan['Plan_reminder']; + $planStatus = $plan['Plan_status']; + $planError = $plan['Plan_error']; + $planLogfile = $plan['Plan_logfile']; + + if (empty($planReminder)) { + $planReminder = 'Aucun'; + } else { + $planReminder = "$planReminder (jours avant)"; } + + if (empty($planDate)) { $planDate = '?'; } + if (empty($planTime)) { $planTime = '?'; } + if (empty($planAction)) { $planAction = '?'; } if ($OS_FAMILY == "Debian") { - echo ""; + if (!empty($planGroup)) { + $planDist = '-'; + $planSection = '-'; + } + if (!empty($planRepo)) { + if (empty($planDist)) { $planDist = '?'; } + if (empty($planSection)) { $planSection = '?'; } + } } - } - } - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ""; - ?> - - - -
DateHeureActionCibleDistSectionStatus
ou Groupe'; - echo ''; - echo '
GPG check'; - echo ''; - echo ''; - echo ''; - echo ''; - echo '
Re-signer avec GPG'; - if ($GPG_SIGN_PACKAGES == "yes") { - echo ''; - echo ''; - echo ''; - echo ''; - } else { - echo ''; - echo ''; - echo ''; - echo ''; - } - echo '
Rappels'; - echo ''; - echo '
- - - listDone(); - if (!empty($plansDone)) { - echo '

Historique des planifications

'; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - if ($OS_FAMILY == "Debian") { - echo ''; - echo ''; - } - echo ''; - echo ''; - - $i = 0; // Initialisation d'une variable qui servira pour chaque div d'erreur de planification caché, et affiché par js - foreach($plansDone as $plan) { - $planId = $plan['Plan_id']; - $planDate = $plan['Plan_date']; - $planTime = $plan['Plan_time']; - $planAction = $plan['Plan_action']; - $planGroup = $plan['Plan_group']; - $planRepo = $plan['Plan_repo']; - if ($OS_FAMILY == "Debian") { - $planDist = $plan['Plan_dist']; - $planSection = $plan['Plan_section']; - } - $planGpgCheck = $plan['Plan_gpgCheck']; - $planGpgResign = $plan['Plan_gpgResign']; - $planReminder = $plan['Plan_reminder']; - $planStatus = $plan['Plan_status']; - $planError = $plan['Plan_error']; - $planLogfile = $plan['Plan_logfile']; - - if (empty($planReminder)) { - $planReminder = 'Aucun'; - } else { - $planReminder = "$planReminder (jours avant)"; - } + if (empty($planGpgCheck)) { $planGpgCheck = '?'; } + if (empty($planGpgResign)) { $planGpgResign = '?'; } + if (empty($planReminder)) { $planReminder = '?'; } + if (empty($planStatus)) { $planStatus = '?'; } - if (empty($planDate)) { $planDate = '?'; } - if (empty($planTime)) { $planTime = '?'; } - if (empty($planAction)) { $planAction = '?'; } - if ($OS_FAMILY == "Debian") { - if (!empty($planGroup)) { - $planDist = '-'; - $planSection = '-'; - } - if (!empty($planRepo)) { - if (empty($planDist)) { $planDist = '?'; } - if (empty($planSection)) { $planSection = '?'; } - } - } - if (empty($planGpgCheck)) { $planGpgCheck = '?'; } - if (empty($planGpgResign)) { $planGpgResign = '?'; } - if (empty($planReminder)) { $planReminder = '?'; } - if (empty($planStatus)) { $planStatus = '?'; } + echo ''; + // Affichage de la date + echo ''; - echo ''; - // Affichage de la date - echo ''; + // Affichage de l'heure + echo ''; - // Affichage de l'heure - echo ''; + // Affichage de l'action + echo ''; - // Affichage de l'action - echo ''; + // Affichage du repo ou du groupe + echo ''; - // Affichage du repo ou du groupe - echo ''; + // Dans le cas de Debian, on affiche la distribution et la section (ou des tirets '-' si la variable précédente était un groupe) + if ($OS_FAMILY == "Debian") { + // Affichage de la distribution + echo ''; + // Affichage de la section + echo ''; + } - // Dans le cas de Debian, on affiche la distribution et la section (ou des tirets '-' si la variable précédente était un groupe) - if ($OS_FAMILY == "Debian") { - // Affichage de la distribution + // Affichage du status echo ''; - // Affichage de la section + + // Affichage des détails echo ''; - } + echo ''; + + echo ""; + echo '
DateHeureActionCibleDistSectionStatus
'; + echo $planDate; + echo '
'; - echo $planDate; - echo ''; + echo $planTime; + echo ''; - echo $planTime; - echo ''; + echo $planAction; + echo ''; - echo $planAction; - echo ''; + if (!empty($planGroup)) { echo $planGroup; } + if (!empty($planRepo)) { echo $planRepo; } + echo ''; - if (!empty($planGroup)) { echo $planGroup; } - if (!empty($planRepo)) { echo $planRepo; } - echo ''; + echo $planDist; + echo ''; + echo $planSection; + echo ''; - echo $planDist; + if ($planStatus === "error") { echo "Error"; } + elseif ($planStatus === "done") { echo 'OK'; } + else { echo '?'; } echo ''; - echo $planSection; + echo ""; echo '
'; + echo ''; + + if ($planStatus === "error") { + echo ""; + } - // Affichage du status - echo ''; + echo ''; - // Affichage des détails - echo ''; - echo ''; - - echo ""; - echo ''; + if ($planAction == "update") { + echo ""; + echo ""; + } + echo ""; + if (!empty($planLogfile)) { + echo ""; + } - // On injecte alors du code js pour pouvoir déployer la ligne cachée par défaut - echo ""; - ++$i; - } - echo '
$planError

'; - if ($planStatus === "error") { - echo "Error"; - } - elseif ($planStatus === "done") { - echo 'OK'; - } else { - echo '?'; - } - echo '
Détails :
'; - echo ""; - echo '
'; - if ($planStatus === "error") { - echo "$planError
"; - } - if ($planAction == "update") { - echo "GPG Check : $planGpgCheck
"; - echo "GPG Resign : $planGpgResign
"; - } - echo "Rappels : $planReminder
"; - if (!empty($planLogfile)) { - echo "Log"; - } - echo '
GPG Check$planGpgCheck
GPG Resign$planGpgResign
Rappels$planReminder
LogVoir
'; - } ?> - + "; + ++$i; + } + echo '
'; + } ?> + - - -
-
- - -
-
- - + + +
+
+ + +
+
+ + +
-
- + +