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
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
primtux-eole
Grenoble
eole-wol
Commits
e34c06f7
Verified
Commit
e34c06f7
authored
5 years ago
by
David Beniamine
Browse files
Options
Downloads
Patches
Plain Diff
Retrieve logs
parent
a9e501aa
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
wol/scripts/wakeonlanservice.sh
+38
-8
38 additions, 8 deletions
wol/scripts/wakeonlanservice.sh
wol/www/index.php
+41
-13
41 additions, 13 deletions
wol/www/index.php
with
79 additions
and
21 deletions
wol/scripts/wakeonlanservice.sh
+
38
−
8
View file @
e34c06f7
...
...
@@ -21,6 +21,16 @@ getip(){
< /var/lib/dhcp/dhcpd.leases
}
# $1 : file|stdin
answer
(){
if
[
-z
"
$1
"
]
then
netcat
$host
$port
else
stdbuf
-oL
cat
$1
|
while
!
netcat
$host
$port
;
do
sleep
1
;
done
fi
}
IP
=
$(
ip a |
awk
'/inet.*containers/ {print $2}'
|
cut
-d
/
-f
1
)
broadcast
=
$(
ip a |
awk
'/inet.*eth1/ {print $4}'
|
cut
-d
/
-f
1
)
subnet
=
$(
ip a |
awk
'/inet.*containers/ {print $2}'
|
cut
-d
/
-f
1 |
cut
-d
.
-f
1-3
)
...
...
@@ -29,23 +39,23 @@ port=9999
while
true
do
MAC
=
`
netcat
-l
$IP
$port
`
#echo "$
MAC
"
if
[
$(
echo
"
$
MAC
"
| egrep
-c
"^([0-9a-f]{2}:?){6}$"
)
-eq
1
]
LINE
=
`
netcat
-l
$IP
$port
`
#echo "$
LINE
"
if
[
$(
echo
"
$
LINE
"
| egrep
-c
"^([0-9a-f]{2}:?){6}$"
)
-eq
1
]
then
wakeonlan
-i
$broadcast
"
$
MAC
"
wakeonlan
-i
$broadcast
"
$
LINE
"
sleep
3
IPS
=
`
getip
$
MAC
`
IPS
=
`
getip
$
LINE
`
for
ip
in
$IPS
do
ping
-c
3
$ip
if
[
$?
-eq
0
]
then
echo
"
$ip
"
|
netcat
$host
$port
echo
"
$ip
"
|
answer
break
fi
done
elif
[
$MAC
==
"getRegistry"
]
elif
[
"
$LINE
"
==
"getRegistry"
]
then
hostfile
=
"/etc/registry/hosts"
while
read
line
...
...
@@ -58,7 +68,27 @@ do
fi
echo
"
$line
$IPS
"
>>
$hostfile
-
$$
done
<
$hostfile
stdbuf
-oL
cat
$hostfile
-
$$
|
while
!
netcat
$host
$port
;
do
sleep
1
;
done
answer
$hostfile
-
$$
rm
$hostfile
-
$$
elif
[[
"
$LINE
"
=
~
"getLog"
]]
then
cmd
=
$(
echo
$LINE
|
cut
-d
' '
-f
1
)
name
=
$(
echo
$LINE
|
cut
-d
' '
-f
2
)
logfile
=
$(
ls
/var/log/upgrade_all.sh_
*
|
sort
|
tail
-n
1
)
if
[
"
$name
"
==
"
$cmd
"
]
then
answer
$logfile
else
tempfile
=
"/tmp/
$$
"
# 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
answer
$tempfile
rm
$tempfile
fi
elif
[[
"
$LINE
"
=
~
"upgrade"
]]
then
#TODO call directly upgrade script
false
fi
done
This diff is collapsed.
Click to expand it.
wol/www/index.php
+
41
−
13
View file @
e34c06f7
...
...
@@ -64,6 +64,8 @@ if(!isset($action)){
<h2>
Gestion des postes
</h2>
<p>
Vous pouvez trier la table ci dessous en cliquant sur la colonne que vous voulez.
<br
/>
Cliquer une deuxième fois inverser l'ordre de trie
</p>
<div
class=
"table-responsive"
>
<table
class=
"table-striped table-bordered table-hover"
style=
"text-align:center;"
>
...
...
@@ -117,17 +119,17 @@ if(!isset($action)){
</form>
<form
action=
"index.php"
method=
"post"
>
<input
type=
"hidden"
name=
"action"
value=
"upgrade"
>
<input
type=
"hidden"
name=
"
mac
"
value=
"
<?php
echo
$entry
[
1
];
?>
"
>
<input
type=
"hidden"
name=
"
name
"
value=
"
<?php
echo
$entry
[
2
];
?>
"
>
<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=
"
mac
"
value=
"
<?php
echo
$entry
[
1
]
?>
;
"
>
<input
type=
"hidden"
name=
"
name
"
value=
"
<?php
echo
$entry
[
2
];
?>
"
>
<input
type=
"submit"
value=
"Mise à jour config + APT"
title=
"Mettre à jour + apt"
>
</form>
<form
action=
"index.php"
method=
"post"
>
<input
type=
"hidden"
name=
"action"
value=
"getLog"
>
<input
type=
"hidden"
name=
"
mac
"
value=
"
<?php
echo
$entry
[
1
]
?>
;
"
>
<input
type=
"hidden"
name=
"
name
"
value=
"
<?php
echo
$entry
[
2
];
?>
"
>
<input
type=
"submit"
value=
"Log de mise à jour"
title=
"Télécharger le dernier log de mise à jour"
>
</form>
<?php
...
...
@@ -156,7 +158,12 @@ if(!isset($action)){
<?php
}
else
{
echo
"<h2> Action en cours </h2>"
;
$lines
=
array
();
$run
=
false
;
if
(
!
isset
(
$name
)){
$name
=
""
;
}
echo
"<h2> Action en cours :
$action
$name
</h2>"
;
switch
(
$action
){
case
"wake"
:
echo
"<div id='result'><p>Démarrage demandé pour la machine
$mac
, veuillez patienter</p></div>"
;
...
...
@@ -190,24 +197,45 @@ if(!isset($action)){
</script>
<?php
break
;
case
"upgradeAllApt"
:
echo
"Sending request to upgrade all machines with apt"
;
$run
=
true
;
break
;
case
"upgradeAll"
:
echo
"Sending request to upgrade all machines"
;
echo
"Todo see log"
;
case
"upgradeAllApt"
:
echo
"Sending request to upgrade all machines with apt"
;
$run
=
true
;
break
;
case
"getLogAll"
:
echo
"I should download all logs, not implemented yet
"
;
exec
(
"../scripts/action.sh
$action
"
,
$lines
,
$code
)
;
$emptymsg
=
"<p>Pas de log globaux disponibles</p>
"
;
$run
=
true
;
break
;
case
"upgrade"
:
echo
"I should upgrade
$mac
, not implemented yet"
;
case
"upgradeAPT"
:
echo
"I should upgrade
$mac
with apt, not implemented yet"
;
echo
"I should upgrade
$name
with apt, not implemented yet"
;
$run
=
true
;
break
;
case
"upgrade"
:
echo
"I should upgrade
$name
, not implemented yet"
;
$run
=
true
;
break
;
case
"getLog"
:
echo
"I should download logs for
$mac
, not implemented yet
"
;
exec
(
"../scripts/action.sh
$action
"
.
escapeshellarg
(
$mac
),
$lines
,
$code
)
;
$emptymsg
=
"<p>Pas de log disponibles pour
$name
</p>
"
;
$run
=
true
;
break
;
}
if
(
$run
){
exec
(
"../scripts/actions.sh ."
.
escapeshellarg
(
$action
)
.
" "
.
escapeshellarg
(
$name
),
$lines
,
$code
);
if
(
!
empty
(
$lines
)){
echo
"<pre>"
;
foreach
(
$lines
as
$line
){
echo
"
$line
\n
"
;
}
echo
"</pre>"
;
}
else
{
echo
$emptymsg
;
}
}
}
?>
</div>
...
...
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