diff --git a/registry/scripts/upgrade_all.sh b/registry/scripts/upgrade_all.sh index a3b8eb83c2d55bbcc2d099d2485be34356ceb87f..cdf32243f175827d5bc851bc33cbae1ac2f2f1d5 100755 --- a/registry/scripts/upgrade_all.sh +++ b/registry/scripts/upgrade_all.sh @@ -45,12 +45,44 @@ broadcast=$(ip a | awk '/inet.*eth1/ {print $4}' | cut -d / -f 1) wait_time=120 wait_step=5 -cmd="cd /opt/primtux-eole/; export HTTPS_PROXY='http://dnsproxy:3128'; git pull; ./upgrade-session.sh $1" +if [ ! -z "$2" ] +then + # $1 == Apt, $2 == hostname or $@ == command + if [ "$1" == "Apt" ] + then + arg="apt" + host="$2" + else + arg="$@" + fi +elif [ ! -z "$1" ] +then + # $1 == Apt, hostname or $@ == command + if [ "$1" == "Apt" ] + then + arg="apt" + elif [ ! -z "$(grep $1 /etc/registry/hosts)" ] + then + host="$1" + else + arg="$@" + fi +fi + +cmd="cd /opt/primtux-eole/; export HTTPS_PROXY='http://dnsproxy:3128'; git pull; ./upgrade-session.sh $arg" +echo $cmd declare -A HOSTS declare -A IPTOMACS declare -A DOWNS -while read date mac name +if [ -z "$host" ] +then + catcmd="cat $conf_file" +else + catcmd="grep $host $conf_file" +fi + +while read date mac name endline do # Boot machine if [ ! -z "$date" ] @@ -62,9 +94,9 @@ do wakeonlan -i $broadcast "$mac" done sleep 5 - MACS+=" $mac" + MACS="$MACS $mac" fi -done < $conf_file +done < <($catcmd) # Wait for boot log "Wakeonlan sent, waiting" diff --git a/wol/scripts/actions.sh b/wol/scripts/actions.sh index 630027d1559c1f060b69cd3abe5bb1b356fd7dd2..308a9362319737a72ef92209ab4e6c91b0a27ced 100755 --- a/wol/scripts/actions.sh +++ b/wol/scripts/actions.sh @@ -27,8 +27,4 @@ host=$subnet.52 echo $@ | netcat $host $port -# If action is "get" something, read answer -if [[ "$1" =~ "get" ]] -then - stdbuf -i0 -o0 -e0 $netcat -fi +stdbuf -i0 -o0 -e0 $netcat diff --git a/wol/scripts/wakeonlanservice.sh b/wol/scripts/wakeonlanservice.sh index 4c824f3af2fa3af1913f1ef85016dc8dc83d81e5..678c66a862a0dccf2303acf02c066d89f4789dcc 100755 --- a/wol/scripts/wakeonlanservice.sh +++ b/wol/scripts/wakeonlanservice.sh @@ -88,7 +88,9 @@ do fi elif [[ "$LINE" =~ "upgrade" ]] then - #TODO call directly upgrade script - false + DIR="$(realpath $(dirname $0))/../../registry/scripts/" + subactions="$(echo $LINE | sed -e 's/^upgrade//' -e 's/All//')" + nohup $DIR/upgrade_all.sh $subactions & + echo "Started 'upgrade_all.sh $subactions' in background on $(date)" | answer fi done diff --git a/wol/www/index.php b/wol/www/index.php index 1a77e9c4974dcf1a225066c8be24615e40d722c6..258e75eef6c055a1219a7fa6d67128963f88db12 100644 --- a/wol/www/index.php +++ b/wol/www/index.php @@ -232,7 +232,7 @@ if(!isset($action)){ }else{ if(in_array($action, $allowedActions)){ $lines = array(); - exec("../scripts/actions.sh .".escapeshellarg($action)." " + exec("../scripts/actions.sh ".escapeshellarg($action)." " .escapeshellarg($name), $lines, $code); echo "<p>Action effectuée, code : $code</p>"; if(!empty($lines)){ @@ -242,11 +242,7 @@ if(!isset($action)){ } echo "</pre>"; }else{ - if(preg_match('/^getLog/', $action)){ - echo "<p>Pas de log globaux disponibles</p>"; - }else{ - echo "<p>Not implemented yet</p><p>Cette action n'affiche pas de message.<br />Vous pouvez demander les logs depuis <a href='/wol/'>la page principale<a></p>"; - } + echo "<p>Erreur : pas de réponse</p>"; } } }