-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
128 lines (110 loc) · 5.01 KB
/
setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/bin/bash
# SETUP
echo "[i] : Setup stared"
# Phase 1 remove ./.git
rm -v ./.git -Rf
echo "[i] : Removed ./.git"
# Phase 2 create Main-Lanucher.sh
echo "[i] : Searching for installation path ... This can take a few moments"
installpath=$(find / -name "*Config-Backupper" 2>/dev/null)
echo "Installation path : $installpath"
echo "[i] : Found installation path"
search=PLACEHOLDERFORINSTALLATIONPATH
replace=$installpath
sed -i "s|${search}|${replace}|g" ./Main-Launcher.sh
echo '[i] : Main-Launcher.sh where configured'
# Phase 3 configure old files commpress&deletion time
echo "--------------------------------------------------------------------------------"
printf "Set days after a config gets commpressed (.gz format) [2,5x-3,5x SMALLER] (Numbers only): "
read archivetimearchivecommpress
search=PLACEHOLDERFORARCHIVETIMEARCHIVECOMMPRESS
replace=$archivetimearchivecommpress
sed -i "s|${search}|${replace}|g" ./Modules/Archive/OldConfigs/Archiver.sh
echo "--------------------------------------------------------------------------------"
printf "Set days after a config gets deleted (Numbers only): "
read archivetimearchivedelete
search=PLACEHOLDERFORARCHIVETIMEARCHIVEDELETE
replace=$archivetimearchivedelete
sed -i "s|${search}|${replace}|g" ./Modules/Archive/OldConfigs/Archiver.sh
echo "--------------------------------------------------------------------------------"
printf "Set days after a logs gets commpressed (.gz format) [2,5x-3,5x SMALLER] (Numbers only): "
read archivetimelogscommpress
search=PLACEHOLDERFORARCHIVETIMELOGSCOMMPRESS
replace=$archivetimelogscommpress
sed -i "s|${search}|${replace}|g" ./Modules/Archive/OldLogs/Archiver.sh
echo "--------------------------------------------------------------------------------"
printf "Set days after a logs gets deleted (.gz format) [2,5x-3,5x SMALLER] (Numbers only): "
read archivetimelogsdelete
search=PLACEHOLDERFORARCHIVETIMELOGSDELETE
replace=$archivetimelogsdelete
sed -i "s|${search}|${replace}|g" ./Modules/Archive/OldLogs/Archiver.sh
echo "--------------------------------------------------------------------------------"
echo "[i] : Main Launcher where created"
# Phase 4 make the files executable
### Launcher ###
chmod --verbose 700 ./Main-Launcher.sh
###./Modules/Backup/ ###
## Main
chmod --verbose 700 ./Modules/Backup/Fortinet/Fortinet.sh
chmod --verbose 700 ./Modules/Backup/DELL/DELL.sh
chmod --verbose 700 ./Modules/Backup/HP/HP.sh
chmod --verbose 700 ./Modules/Backup/Cisco/Cisco.sh
## Sub
# Fortinet
chmod --verbose 700 ./Modules/Backup/Fortinet/fortigateX-special.sh
chmod --verbose 700 ./Modules/Backup/Fortinet/fortigateX.sh
# Cisco
chmod --verbose 700 ./Modules/Backup/Cisco/n3XXX.sh
chmod --verbose 700 ./Modules/Backup/Cisco/sgX00.sh
chmod --verbose 700 ./Modules/Backup/Cisco/wsc3650.sh
# DELL
chmod --verbose 700 ./Modules/Backup/DELL/nXXXX.sh
###./Modules/Archive/ ###
## Archiving
chmod --verbose 700 ./Modules/Archive/OldConfigs/Archiver.sh
chmod --verbose 700 ./Modules/Archive/OldLogs/Archiver.sh
chmod --verbose 700 ./Modules/Archive/ArchiveStats.sh
# Other
chmod --verbose 700 ./Modules/Archive/Fastdebug.sh
##./Modules/Clean/
chmod --verbose 700 ./Modules/Clean/Configs/CleanUp.sh
chmod --verbose 700 ./Modules/Clean/Logs/CleanUp.sh
##./Modules/Setup/
chmod --verbose 700 ./Modules/Setup/WebsiteIndex.sh
chmod --verbose 700 ./Modules/Setup/Fortinet/AutoSetup.sh
chmod --verbose 700 ./Modules/Setup/ModuleChecker.sh
### Other
chmod --verbose 700 ./Modules/FirmwareCheck/Fortinet/FirmwareChecker.sh
echo "[i] : Modules & Lanucher where modified"
# Phase 5 create SSH Key
echo "----------------------------------------"
echo '1024 bit - ONLY FOR TESTING'
echo '2048 bit - It is "secure" until 2030!'
echo "4096 bit - Will be fine"
echo "8192 bit - Are you paranoid ?"
echo "16384 bit - What are you transferring?"
echo "----------------------------------------"
printf "Enter bit lenth (Numbers only): "
read rsakeylenth
ssh-keygen -t rsa -b $rsakeylenth -f ./SSH-Keys/Backup-SSH-Key
# Phase 6 show the new created Public SSH-Key
echo "-----BEGIN PUBLIC KEY-----"
cat ./SSH-Keys/Backup-SSH-Key.pub
echo "-----END PUBLIC KEY-----"
echo " "
# Phase 7 configure Fortinet-AutoSetup.sh
search=PLACEHOLDERFORSSHKEY
replace=$(cat ./SSH-Keys/Backup-SSH-Key.pub)
sed -i "s|${search}|${replace}|g" ./Modules/Setup/Fortinet/AutoSetup.sh
echo '[i] : Fortinet Fortinet-AutoSetup.sh where configured'
# Phase 8 show e.g. for a crontab
echo "--------------------------------------------------------------------------------"
echo "Create a crontab to run the backup every day @ 2:00 enter this line in crontab"
echo "0 2 * * * $installpath/Main-Launcher.sh"
echo "--------------------------------------------------------------------------------"
# Phase 9 remove ./Log/<VENDOR>/DeleteMe files
rm -v ./Log/Cisco/DeleteMe ./Log/Backup/DeleteMe ./Log/DELL/DeleteMe ./Log/Fortinet/DeleteMe ./Log/Failed/DeleteMe ./Log/HP/DeleteMe ./SSH-Keys/DeleteMe ./Devices/Firmware-Versions/DeleteMe
echo "[i] : Removed ./Log/<VENDOR>/DeleteMe & ./SSH-Keys/ files"
rm -v ./setup.sh
echo "[i] : Removed ./setup.sh"
echo "[i] : IT'S DONE !"