Skip to content

Commit

Permalink
Merge pull request #14 from MrMarioMichel/development
Browse files Browse the repository at this point in the history
New Files Names
  • Loading branch information
DRIgnazGortngschirl authored Oct 15, 2019
2 parents e4cc3eb + b776136 commit 69e7f72
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 23 deletions.
4 changes: 2 additions & 2 deletions Modules/Archive/ArchiveStats.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ minus1=1 # Caused by also counting the./Archive/resources/config.php as a .conf

# Do some Quick Math 2 + 2 = 4 - 1 = 3
avglinesinconfig=$((expr $totallines / $configsinarchive))
fortinethostfilecounttotal$((expr $fortinethostfilecount + fortinetspecialhostfilecount))
total=$((expr $fortinethostfilecounttotal + $ + $hphostfilecount + $ciscohostfilecount + $dellhostfilecount))
fortinethostfilecounttotal=$((expr $fortinethostfilecount + $fortinetspecialhostfilecount))
total=$((expr $fortinethostfilecounttotal + $hphostfilecount + $ciscohostfilecount + $dellhostfilecount))
dirsinarchive=$((expr $dirsinarchive - $minus2))
totalconfigsarchive=$((expr $totalconfigsarchive - $minus1))

Expand Down
9 changes: 5 additions & 4 deletions Modules/Backup/Cisco/n3XXX.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@ for device in $(egrep -v "^\s*(#|$)" ./Devices/Cisco/n3xxx-txt | grep -oE "\b([0
if ping -c 3 $device &> /dev/null
then
echo "[i]: $device reachable"
sshpass -p "$passwd" ssh -tt $user@$device <<EOF > BackupConfigCiscoTEMP1
sshpass -p "$passwd" ssh -tt $user@$device <<EOF > BackupConfigCiscoTEMPn3XXX
terminal length 0
show startup-config
exit
EOF
name=$(grep hostname ./BackupConfigCiscoTEMP1 | sed 's|["?]||g' | sed 's/hostname //' | tr -dc '[:print:]')
grep -v "$name#" BackupConfigCiscoTEMP1 | sed 's/terminal length 0//g' | sed 's/show startup-config//g' | sed 's/exit//g' > BackupConfigCisco
name=$(grep hostname ./BackupConfigCiscoTEMPn3XXX | sed 's|["?]||g' | sed 's/hostname //' | tr -dc '[:print:]')
grep -v "$name#" BackupConfigCiscoTEMPn3XXX | sed 's/terminal length 0//g' | sed 's/show startup-config//g' | sed 's/exit//g' > BackupConfigCiscon3XXX
if [ -z "$name" ]
then
echo "[i]: $device Name not found"
else
echo "[i]: $device Name found $name"
mkdir -v ./Archive/$name
date=$(date +"%H-%M_%d-%m-%Y")
mv -v ./BackupConfigCisco ./Archive/$name/$name-$date.conf
mv -v ./BackupConfigCiscon3XXX ./Archive/$name/$name-$date.conf
if [ -f ./Archive/$name/$name-$date.conf ]
then
echo "[i]: File $name-$date.conf found"
Expand All @@ -35,6 +35,7 @@ EOF
echo "[i]: $device backup failed"
fi
fi
rm -v BackupConfigCiscoTEMPn3XXX
else
echo "[i]: $device not reachable"
fi
Expand Down
9 changes: 5 additions & 4 deletions Modules/Backup/Cisco/wsc3650.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ for device in $(egrep -v "^\s*(#|$)" ./Devices/Cisco/wsc3650.txt | grep -oE "\b(
if ping -c 3 $device &> /dev/null
then
echo "[i]: $device reachable"
sshpass -p "$passwd" ssh -tt $user@$device <<EOF > BackupConfigCiscoTEMP1
sshpass -p "$passwd" ssh -tt $user@$device <<EOF > BackupConfigCiscoTEMPwsc3650
terminal length 0
show startup-config
exit
EOF
name=$(grep hostname ./BackupConfigCiscoTEMP1 | sed 's|["?]||g' | sed 's/hostname //' | tr -dc '[:print:]')
grep -v "$name#" BackupConfigCiscoTEMP1 | sed 's/terminal length 0//g' | sed 's/show startup-config//g' | sed 's/exit//g' > BackupConfigCisco
name=$(grep hostname ./BackupConfigCiscoTEMPwsc3650 | sed 's|["?]||g' | sed 's/hostname //' | tr -dc '[:print:]')
grep -v "$name#" BackupConfigCiscoTEMPwsc3650 | sed 's/terminal length 0//g' | sed 's/show startup-config//g' | sed 's/exit//g' > BackupConfigCiscowsc3650
if [ -z "$name" ]
then
echo "[i]: $device Name not found"
else
echo "[i]: $device Name found $name"
mkdir -v ./Archive/$name
date=$(date +"%H-%M_%d-%m-%Y")
mv -v ./BackupConfigCisco ./Archive/$name/$name-$date.conf
mv -v ./BackupConfigCiscowsc3650 ./Archive/$name/$name-$date.conf
if [ -f ./Archive/$name/$name-$date.conf ]
then
echo "[i]: File $name-$date.conf found"
Expand All @@ -34,6 +34,7 @@ EOF
echo "[i]: $device backup failed"
fi
fi
rm -v BackupConfigCiscoTEMPwsc3650
else
echo "[i]: $device not reachable"
fi
Expand Down
28 changes: 17 additions & 11 deletions Modules/Backup/DELL/nXXXX.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,24 @@ user="dell"
passwd="XXXXXXPASSWORDXXXXXX"

echo "[i]: Started Backup of Configs : DELL (nXXXX.sh)"
for device in $(egrep -v "^\s*(#|$)" ./Devices/DELL/NXXXX.txt | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b")
for device in $(egrep -v "^\s*(#|$)" ./Devices/DELL/nXXXX.txt | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b")
do
echo -e "[i]: Host --> $device"
sshpass -p "$passwd" \ssh -v $user@$device <<EOF > BackupConfigDELLTEMP1
enable
show running-config
exit
exit
exit
if ping -c 3 $device &> /dev/null
then
echo "[i]: $device reachable"
sshpass -p "$passwd" \ssh -v $user@$device <<EOF > BackupConfigDELLTEMPnXXXX
enable
show running-config
exit
exit
exit
EOF
name=$(grep "hostname" BackupConfigDELLTEMP1 | sed 's|["?]||g' | sed 's/hostname //' | tr -dc '[:print:]')
grep -v "$name>" BackupConfigDELLTEMP1 | grep -v "$name#"> BackupConfigDELL
name=$(grep "hostname" BackupConfigDELLTEMPnXXXX | sed 's|["?]||g' | sed 's/hostname //' | tr -dc '[:print:]')
grep -v "$name>" BackupConfigDELLTEMPnXXXX | grep -v "$name#"> BackupConfigDELLnXXXX
mkdir -v Archive/$name
date=$(date +"%H-%M_%d-%m-%Y")
mv -v BackupConfigDELL ./Archive/$name/$name-$date.conf
rm BackupConfigDELLTEMP1
mv -v BackupConfigDELLnXXXX ./Archive/$name/$name-$date.conf
if [ -f ./Archive/$name/$name-$date.conf ]
then
echo "[i]: File $name-$date.conf found!"
Expand All @@ -28,4 +30,8 @@ EOF
echo "[i]: File $name-$date.conf not found!"
echo "[i]: $device backup failed"
fi
fi
rm -v BackupConfigDELLTEMPnXXXX
else
echo "[i]: $device not reachable"
done
4 changes: 2 additions & 2 deletions Modules/FirmwareCheck/Fortinet/FirmwareChecker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ awk '{ print $2}' ./Devices/Firmware-Versions/Fortinet-Firmware-Versions.txt | c
### Display on a website ###

# Can be used to create a "okay" looking list of ./Devices/Firmware-Versions/Fortinet-Firmware-Versions.txt to display it e.g. on a website. Will be placed in ./Devices/Firmware-Versions/
# sed -i ./Devices/Firmware-Versions/Fortinet-Firmware-Versions.txt 's/ /\&nbsp;\&nbsp;\&nbsp;\&nbsp;\&nbsp;\&nbsp;\&nbsp;\&nbsp;\&nbsp;\&nbsp;/g' | > ./Devices/Firmware-Versions/Fortinet-Firmware-Versions.html
# sed 's/ /\&nbsp;\&nbsp;\&nbsp;\&nbsp;\&nbsp;\&nbsp;\&nbsp;\&nbsp;\&nbsp;\&nbsp;/g' ./Devices/Firmware-Versions/Fortinet-Firmware-Versions.txt > ./Devices/Firmware-Versions/Fortinet-Firmware-Versions.html

# Can be used to create a list of ./Devices/Firmware-Versions/Fortinet-Firmware-Count.txt to display it e.g. on a website. Will be placed in ./Devices/Firmware-Versions/
# awk '{ print $2}' ./Devices/Firmware-Versions/Firmware-Versions.txt | cut -d "-" -f2 | sort | uniq -c | sed 's/^ *//' | sed 's/ / x FortiOS /g' | sed ':a;N;$!ba;s/\n/<br>/g' ./Devices/Firmware-Versions/Fortinet-Firmware-Count.html
# awk '{ print $2}' ./Devices/Firmware-Versions/Fortinet-Firmware-Versions.txt | cut -d "-" -f2 | sort | uniq -c | sed 's/^ *//' | sed 's/ / x FortiOS /g' | sed ':a;N;$!ba;s/\n/<br>/g' > ./Devices/Firmware-Versions/Fortinet-Firmware-Count.html

0 comments on commit 69e7f72

Please sign in to comment.