From 4bd42da0736e92a59415b452924dd9ac2f763a95 Mon Sep 17 00:00:00 2001
From: David Beniamine <david.beniamine@tetras-libre.fr>
Date: Mon, 26 Aug 2019 16:26:59 +0200
Subject: [PATCH] Alert forbidden actions

---
 wol/scripts/wakeonlanservice.sh | 5 +++++
 wol/www/index.php               | 9 ++++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/wol/scripts/wakeonlanservice.sh b/wol/scripts/wakeonlanservice.sh
index 32c1e98..fd035e1 100755
--- a/wol/scripts/wakeonlanservice.sh
+++ b/wol/scripts/wakeonlanservice.sh
@@ -85,6 +85,11 @@ do
             # Extract the pertinent part of the log
             awk 'BEGIN{IN=0} /Begin host/{if($4=="'$name'"){IN=1}} {if(IN){print $0}} /End host/{if($4=="'$name'"){IN=0}}' \
                 $logfile > $tempfile
+            if [ ! -s $tempfile ]
+            then
+                # Log file is empty, this happens when we are starting an upgrade on a specific host
+                cp $logfile $tempfile
+            fi
             answer $tempfile
             rm $tempfile
         fi
diff --git a/wol/www/index.php b/wol/www/index.php
index e22934a..80334f6 100644
--- a/wol/www/index.php
+++ b/wol/www/index.php
@@ -126,7 +126,7 @@ if(!isset($action)){
         <input type="submit" value="Mise à jour config" title="Mettre à jour">
     </form>
     <form action="index.php" method="post">
-        <input type="hidden" name="action" value="upgradeAPT">
+        <input type="hidden" name="action" value="upgradeApt">
         <input type="hidden"   name="name" value="<?php echo $entry[2]; ?>">
         <input type="submit" value="Mise à jour config + APT" title="Mettre à jour + apt">
     </form>
@@ -258,8 +258,15 @@ if(!isset($action)){
                 <input type="submit" value="Rafraichir les logs" title="Rafraichir les logs">
                 </form>
                 <?
+            }else{
+                echo "<p><strong>Action '$action' interdite !</strong></p>";
             }
         }
+?>
+       <form action="index.php" method="post">
+       <input type="submit" value="Retour à l'accueil" title="Retour à l'accueil">
+       </form>
+<?php
     }
 ?>
 </div>
-- 
GitLab