Skip to content

Commit

Permalink
Fix nom de domaine en dur
Browse files Browse the repository at this point in the history
Plus nettoyage du code.
  • Loading branch information
PhilippeLeroux committed Mar 21, 2018
1 parent 36fa9ec commit b6d1fe8
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions dns/clean_up_ssh_authorized_keys.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
. ~/plescripts/global.cfg
EXEC_CMD_ACTION=EXEC

typeset -r ME=$0
typeset -r PARAMS="$*"
typeset -r str_usage=\
"Usage : $ME ...."
typeset -r ME=$0
typeset -r PARAMS="$*"

typeset -r str_usage=\
"Usage : $ME"

while [ $# -ne 0 ]
do
case $1 in
-emul)
EXEC_CMD_ACTION=NOP
first_args=-emul
shift
;;

Expand All @@ -34,24 +34,27 @@ do
esac
done

typeset -r aut_file=/root/.ssh/authorized_keys
must_be_executed_on_server $infra_hostname

typeset -r aut_file=/root/.ssh/authorized_keys

typeset -r domain=$(hostname -d)

typeset -i count_hosts_removed=0
typeset -i nr_hosts_removed=0

while read -r f1 f2 from
do
host=${from##*@}
info -n "$(printf "%-18s" $host)"
grep "$host" /var/named/reverse.orcl 1>/dev/null
if [ $? -eq 0 ]
if grep -q "$host" /var/named/reverse.$domain
then
info -f " [$OK]"
else
info -f "[${RED}removed${NORM}]"
exec_cmd -c "sed -i "/$host/d" $aut_file"
count_hosts_removed=count_hosts_removed+1
((++nr_hosts_removed))
fi
LN
done<$aut_file

info "$count_hosts_removed hosts removed."
info "$nr_hosts_removed hosts removed."

0 comments on commit b6d1fe8

Please sign in to comment.