From fa7bb47538de9c817568b28b3bcca5a164e0d854 Mon Sep 17 00:00:00 2001 From: David Beniamine <david.beniamine@tetras-libre.fr> Date: Mon, 5 Aug 2019 15:56:03 +0200 Subject: [PATCH] Put all ligne in registry --- registry/scripts/registry.sh | 6 +++--- wol/www/index.php | 17 ++++++++++++++++- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/registry/scripts/registry.sh b/registry/scripts/registry.sh index ce2f0de..725cf1e 100755 --- a/registry/scripts/registry.sh +++ b/registry/scripts/registry.sh @@ -46,12 +46,12 @@ do then date=$(date +%Y%m%d) rIP=$(echo $line | cut -d ' ' -f 3) - line=$(echo $line | cut -d ' ' -f 1-2) - res=$(grep "$line" $conf_file) + sline=$(echo $line | cut -d ' ' -f 1-2) + res=$(grep "$sline" $conf_file) if [ ! -z "$res" ] then # Update - sed -i -e "s/^.*$line$/$date $line/" $conf_file + sed -i -e "s/^.*$sline$/$date $line/" $conf_file else # Add echo "$date $line" >> $conf_file diff --git a/wol/www/index.php b/wol/www/index.php index 2597973..ef085d5 100644 --- a/wol/www/index.php +++ b/wol/www/index.php @@ -35,7 +35,22 @@ extract($_POST); if(!isset($action)){ $lines=explode(PHP_EOL, shell_exec("../scripts/get_registry.sh")); ?> - <p> <?php echo count($lines); ?> postes sont inscrits sur ce serveur </p> + <p> + <?php + $n=count($lines); + if(empty($lines)){ + echo "Impossible de récupérer le registre"; + ob_start(); + shell_exec("../scripts/get_registry.sh"); + $lines=ob_get_clean(); + echo "$lines"; + }else if ($n == 1){ + echo "$n poste est enregistré sur ce serveur"; + }else{ + echo "$n postes sont enregistrés sur ce serveur"; + } +?> + </p> <h2> Actions globables </h2> <form action="index.php" method="post"> <input type="hidden" name="action" value="upgradeAll"> -- GitLab