Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Grenoble
Eole-Wol
Commits
2c773277
Unverified
Commit
2c773277
authored
Jun 05, 2020
by
David Beniamine
Browse files
Fix #22
parent
086d45be
Changes
2
Hide whitespace changes
Inline
Side-by-side
clear_dhcp.sh
0 → 100644
View file @
2c773277
#!/bin/bash
if
[
-z
"
$2
"
]
||
[
"
$1
"
!=
'Name'
]
&&
[
"
$1
"
!=
'MAC'
]
then
echo
"Usage:"
echo
"
\t
$0
MAC aa:bb:cc:dd:ee:ff"
echo
"Or"
echo
"
\t
$0
Name hostname"
exit
1
fi
lease_file
=
"/var/lib/dhcp/dhcpd.leases"
cp
$lease_file
$lease_file
.
$(
date
"+%Y%m%d-%H%M%S"
)
if
[
"
$1
"
==
'MAC'
]
then
MAC
=
$2
awk
-v
MAC
=
"
$MAC
"
'BEGIN{IN=0;ACCU=""} /^lease/{print ACCU;ACCU="";IN=1;do_print=1} /hardware ethernet/{if($3==MAC";"){do_print=0}} {ACCU=ACCU"\n"$0} /^}$/{if(do_print==1){print ACCU};IN=0;do_print=0;ACCU=""}'
$lease_file
>
/tmp/
$$
else
HOST
=
"
\"
$2
\"
"
awk
-v
HOST
=
"
$HOST
"
'BEGIN{IN=0;ACCU=""} /^lease/{print ACCU;ACCU="";IN=1;do_print=1} /client-hostname/{if($2==HOST";"){do_print=0}} {ACCU=ACCU"\n"$0} /^}$/{if(do_print==1){print ACCU};IN=0;do_print=0;ACCU=""}'
$lease_file
>
/tmp/
$$
fi
sed
'/^$/d'
/tmp/
$$
>
$lease_file
systemctl restart isc-dhcp-server
registry/scripts/upgrade_all.sh
View file @
2c773277
...
@@ -150,7 +150,7 @@ do
...
@@ -150,7 +150,7 @@ do
log
"===== Begin host
$name
(
$mac
-
$ip
) ===="
log
"===== Begin host
$name
(
$mac
-
$ip
) ===="
cat
$f
>>
$mainlog
cat
$f
>>
$mainlog
log
"===== End host
$name
===="
log
"===== End host
$name
===="
if
[
$(
wc
-l
$f
|
awk
'{print $1}'
)
-
g
t
0
]
if
[
$(
wc
-l
$f
|
awk
'{print $1}'
)
-
l
t
0
]
then
then
DOWNS[
$mac
]=
$name
DOWNS[
$mac
]=
$name
fi
fi
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment