Skip to content
Snippets Groups Projects
Verified Commit a8876c38 authored by David Beniamine's avatar David Beniamine
Browse files

Better solution using two containers

parent cb91ceaa
No related branches found
No related tags found
No related merge requests found
#!/bin/bash
# Copyright (C) 2018 Tetras Libre <Contact@Tetras-Libre.fr>
# Author: Beniamine, David <David.Beniamine@Tetras-Libre.fr>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
subnet=$(ip a | awk '/inet.*containers/ {print $2}' | cut -d / -f 1 | cut -d . -f 1-3)
echo "$1" | netcat $subnet.52 9999
...@@ -16,10 +16,16 @@ ...@@ -16,10 +16,16 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
X=$(awk '/Allow from .*255.255.255.0/ {print $3}' /etc/apache2/sites-available/phpmyadmin | \ IP=$(ip a | awk '/inet.*containers/ {print $2}' | cut -d / -f 1)
cut -d . -f 3) broadcast=$(ip a | awk '/inet.*eth1/ {print $4}' | cut -d / -f 1)
MAC=$1 netcat -l $IP 9999 | \
for i in $(seq 100 199); do wakeonlan -i 10.20.$X.$i $MAC; done while read MAC
do
if [ $(echo "$MAC" | egrep -c "^([0-9a-f]{2}:?){6}$") -eq 1 ]
then
wakeonlan -i $broadcast "$line"
fi
done
...@@ -20,14 +20,18 @@ ...@@ -20,14 +20,18 @@
//echo "actions '$action', uuid '$uuid', name '$name', dev '$dev'<br/>"; //echo "actions '$action', uuid '$uuid', name '$name', dev '$dev'<br/>";
switch($action){ switch($action){
case "wake" : case "wake" :
$cmd = "../scripts/wakeonlan.sh";
echo "<p>Mac : '$mac'</p>";
$args = escapeshellarg($mac); $args = escapeshellarg($mac);
if(preg_match('/^([0-9a-f]{2}:?){6}$/',$mac)){
$cmd = "../scripts/sendmac.sh";
echo "<p>Mac : '$mac'</p>";
}else{
echo "<p>Adresse MAC invalide : ".$args."</p>";
}
break; break;
} }
if (strcmp($cmd, "")){ if (strcmp($cmd, "")){
echo "<p>execution de ' $cmd $args '</p>"; echo "<p>execution de ' $cmd $args '</p>";
shell_exec("$cmd $args"); echo "<p>".shell_exec("$cmd $args")."</p>";
} }
?> ?>
<div id="box"> <div id="box">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment