Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
eole-wol
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
primtux-eole
Plan de cuques
eole-wol
Commits
a8876c38
Verified
Commit
a8876c38
authored
6 years ago
by
David Beniamine
Browse files
Options
Downloads
Patches
Plain Diff
Better solution using two containers
parent
cb91ceaa
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
wol/scripts/sendmac.sh
+20
-0
20 additions, 0 deletions
wol/scripts/sendmac.sh
wol/scripts/wakeonlan.sh
+10
-4
10 additions, 4 deletions
wol/scripts/wakeonlan.sh
wol/www/index.php
+8
-4
8 additions, 4 deletions
wol/www/index.php
with
38 additions
and
8 deletions
wol/scripts/sendmac.sh
0 → 100644
+
20
−
0
View file @
a8876c38
#!/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
This diff is collapsed.
Click to expand it.
wol/scripts/wakeonlan.sh
100755 → 100644
+
10
−
4
View file @
a8876c38
...
@@ -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
This diff is collapsed.
Click to expand it.
wol/www/index.php
+
8
−
4
View file @
a8876c38
...
@@ -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"
>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment