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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
primtux-eole
Plan de cuques
eole-wol
Commits
504883e5
Verified
Commit
504883e5
authored
5 years ago
by
David Beniamine
Browse files
Options
Downloads
Patches
Plain Diff
Handle multiples IPs per clients #26
parent
64acce47
Branches
master
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
registry/scripts/upgrade_all.sh
+68
-13
68 additions, 13 deletions
registry/scripts/upgrade_all.sh
with
68 additions
and
13 deletions
registry/scripts/upgrade_all.sh
+
68
−
13
View file @
504883e5
...
...
@@ -16,16 +16,23 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
getip
(){
mainlog
=
"/var/log/
`
basename
$0
`
_
`
date
+%Y%m%d-%H%M
`
"
getips
(){
awk
'/^lease/{IP=$2} /hardware ethernet/{gsub(";","",$3);if($3 == "'
$1
'"){print IP}}'
\
< /var/lib/dhcp/dhcpd.leases |
tail
-n
1
< /var/lib/dhcp/dhcpd.leases |
sort
-u
}
runcmd
(){
host
=
$1
logfile
=
/tmp/
$$
-
$host
.log
shift
echo
"Runnig
$@
on
$host
"
ssh
-o
StrictHostKeychecking
=
no root@
$host
$@
echo
"Runnig
$@
on
$host
"
|
tee
$logfile
ssh
-o
StrictHostKeychecking
=
no root@
$host
$@
|
tee
$logfile
}
log
(){
echo
$@
|
tee
-a
$mainlog
}
# Switch to lametros repository
...
...
@@ -39,29 +46,77 @@ wait_time=120
wait_step
=
5
cmd
=
"cd /opt/primtux-eole/; export HTTPS_PROXY='http://dnsproxy:3128'; git pull; ./upgrade-session.sh
$1
"
declare
-A
HOSTS
declare
-A
IPTOMACS
declare
-A
DOWNS
while
read date
mac name
do
# Boot machine
wakeonlan
-i
$broadcast
"
$mac
"
MACS+
=
"
$mac
"
if
[
!
-z
"
$date
"
]
then
HOSTS[
$mac
]=
$name
log
"Trying to boot
$name
(
$mac
)"
for
i
in
seq
1 3
do
wakeonlan
-i
$broadcast
"
$mac
"
done
sleep
5
MACS+
=
"
$mac
"
fi
done
<
$conf_file
# Wait for boot
echo
"
"
log
"Wakeonlan sent, waiting
"
while
[
$wait_time
-gt
0
]
do
echo
-ne
"Waiting for boot, remaining
$wait_time
seconds
\r
"
log
-ne
"Waiting for boot, remaining
$wait_time
seconds
\r
"
sleep
$wait_step
wait_time
=
$((
$wait_time
-
$wait_step
))
done
echo
-e
"
\n
Waiting finished"
log
-e
"
\n
Waiting finished"
# Running command
for
mac
in
$MACS
do
ip
=
$(
getip
$mac
)
runcmd
$ip
$cmd
&
PIDS
=
"
$PIDS
$!
"
for
ip
in
$(
getips
$mac
)
do
IPTOMACS[
$ip
]=
$mac
runcmd
$ip
$cmd
&
PIDS
=
"
$PIDS
$!
"
done
done
# wait all pids
wait
$PIDS
for
pid
in
$PIDS
do
wait
$pid
done
# Retrieving logs
for
f
in
/tmp/
$$
-
*
do
ip
=
$(
echo
$f
|
cut
-d
'-'
-f
2- |
sed
's/\.log$//'
)
mac
=
${
IPTOMACS
[
$ip
]
}
name
=
${
HOSTS
[
$mac
]
}
log
"===== Begin host
$name
(
$mac
-
$ip
) ===="
cat
$f
>>
$mainlog
log
"===== End host
$name
===="
if
[
$(
wc
-l
$f
|
awk
'{print $1}'
)
-gt
0
]
then
DOWNS[
$mac
]=
$name
fi
rm
$f
done
# Listing down hosts
if
[
${#
DOWNS
[@]
}
-eq
0
]
then
log
"All
${#
HOSTS
[@]
}
hosts answered"
else
log
"On a total of
${#
HOSTS
[@]
}
hosts,
${#
DOWNS
[@]
}
are still down:"
for
mac
in
${
!DOWNS[@]
}
do
log
-e
"
\t
*
${
DOWNS
[
$mac
]
}
(
$mac
)"
done
fi
log
"Output written to
$mainlog
"
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