forked from NOXCIS/Wiregate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·356 lines (280 loc) · 8.52 KB
/
install.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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
#!/bin/bash
set -e
export HISTFILE=/dev/null
export DEBIAN_FRONTEND=noninteractive
export DOCKER_CONTENT_TRUST=1
export TIMER_VALUE=0
export DEPLOY_TYPE="CLOUD DEPLOYMENT MODE"
#CORE_IMPORTS
source ./Core-Installer-Functions/OS-Reqs.sh
source ./Core-Installer-Functions/Menu.sh
source ./Core-Installer-Functions/Title.sh
source ./Core-Installer-Functions/Reset-WormHole.sh
source ./Core-Installer-Functions/Darkwire/Darkwire-ENV-setup.sh
source ./Core-Installer-Functions/Channels/Channels-ENV-setup.sh
source ./Core-Installer-Functions/Pihole/Pihole-ENV-setup.sh
source ./Core-Installer-Functions/WG-Dash/WG-Dash-ENV-setup.sh
source ./Core-Installer-Functions/AdGuard/AdGuard-ENV-setup.sh
source ./Core-Installer-Functions/Anim/frames.sh
Express-AdGuard-Darkwire() {
compose_down
TIMER_VALUE=0
adguard_dwire_cswap
run_adguard_setup
}
Express-AdGuard-Channels() {
compose_down
TIMER_VALUE=0
adguard_channl_cswap
run_adguard_setup
}
Express-Pihole-Darkwire() {
compose_down
TIMER_VALUE=0
pihole_dwire_cswap
run_pihole_setup
}
Express-Pihole-Channels() {
compose_down
TIMER_VALUE=0
pihole_channl_cswap
run_pihole_setup
}
Advanced-AdGuard-Darkwire() {
compose_down
set_timer_value &&
adguard_dwire_cswap
run_adguard_setup
}
Advanced-AdGuard-Channels() {
compose_down
set_timer_value &&
adguard_channl_cswap
run_adguard_setup
}
Advanced-Pihole-Darkwire() {
compose_down
set_timer_value &&
pihole_dwire_cswap
run_pihole_setup
}
Advanced-Pihole-Channels() {
compose_down
set_timer_value &&
pihole_channl_cswap
run_pihole_setup
}
Pre_Configured-AdGuard-Darkwire() {
TIMER_VALUE=5
compose_down
clear &&
adguard_preset_dwire_cswap &&
set_port_range &&
set_adguard_config &&
rm_exst_configs >/dev/null 2>&1 &&
clear &&
compose_up &&
clear &&
generate_wireguard_qr &&
readme_title &&
env_var_adguard_title_short &&
encrypt_file >/dev/null 2>&1 &&
sleep 60 &&
nuke_bash_hist &&
leave_a_star_title &&
return
}
Pre_Configured-AdGuard-Channels() {
TIMER_VALUE=5
compose_down
clear &&
adguard_preset_channl_cswap &&
set_port_range &&
set_adguard_config &&
rm_exst_configs >/dev/null 2>&1 &&
clear &&
compose_up &&
clear &&
generate_wireguard_qr &&
readme_title &&
env_var_adguard_title_short &&
encrypt_file >/dev/null 2>&1 &&
sleep 60 &&
nuke_bash_hist &&
leave_a_star_title &&
return
}
Pre_Configured-Pihole-Darkwire() {
TIMER_VALUE=5
compose_down
clear &&
pihole_preset_dwire_cswap &&
set_port_range &&
rm_exst_configs >/dev/null 2>&1 &&
compose_up &&
clear &&
generate_wireguard_qr &&
readme_title &&
env_var_pihole_title_short &&
encrypt_file >/dev/null 2>&1 &&
sleep 60 &&
nuke_bash_hist &&
leave_a_star_title &&
return
}
Pre_Configured-Pihole-Channels() {
TIMER_VALUE=5
compose_down
clear &&
pihole_preset_channl_cswap &&
set_port_range &&
rm_exst_configs >/dev/null 2>&1 &&
compose_up &&
clear &&
generate_wireguard_qr &&
readme_title &&
env_var_pihole_title_short &&
encrypt_file >/dev/null 2>&1 &&
sleep 60 &&
nuke_bash_hist &&
leave_a_star_title &&
return
}
run_pihole_setup() {
set_pihole_config &&
set_wg-dash_config &&
set_wg-dash_account &&
set_dwire_config &&
set_channels_config &&
rm_exst_configs >/dev/null 2>&1 &&
clear &&
compose_up &&
clear &&
#FINAL_OUTPUT
generate_wireguard_qr &&
readme_title &&
encrypt_file >/dev/null 2>&1 &&
env_var_pihole_title &&
pihole_compose_swap >/dev/null 2>&1
sleep 60 &&
nuke_bash_hist &&
leave_a_star_title &&
return
}
run_adguard_setup() {
set_adguard_config &&
set_wg-dash_config &&
set_wg-dash_account &&
set_dwire_config &&
set_channels_config &&
rm_exst_configs >/dev/null 2>&1 &&
clear &&
compose_up &&
clear &&
#FINAL_OUTPUT
generate_wireguard_qr &&
readme_title &&
encrypt_file >/dev/null 2>&1 &&
env_var_adguard_title &&
adguard_compose_swap >/dev/null 2>&1
sleep 60 &&
nuke_bash_hist &&
leave_a_star_title &&
return
}
#DOCKER FUNCTIONS
compose_up() {
run_docker_title
sudo sysctl -w net.core.rmem_max=2097152 > /dev/null 2>&1
sudo sysctl -w kern.ipc.maxsockbuf=1048576 > /dev/null 2>&1
docker compose pull
docker compose up -d --build
}
compose_down() {
local install_check="preqsinstalled.txt"
local yml_file="docker-compose.yml"
local port_mappings="770-777:770-777/udp"
export WG_DASH_PORT_MAPPINGS="$port_mappings"
if [ ! -f "$install_check" ]; then
# If prerequisites are not installed, install them
install_requirements
docker compose down --remove-orphans &&
docker volume ls -q | grep 'wg_data' | xargs -r docker volume rm
elif [ -f "$install_check" ]; then
# If prerequisites are installed, bring down the Docker-compose setup
docker compose down --remove-orphans #&&
#docker volume ls -q | grep 'wg_data' | xargs -r docker volume rm
fi
}
#MISC
dev_build() {
local adguard_yaml_file="./Global-Configs/AdGuard/Config/AdGuardHome.yaml"
local adguard_password='$2a$12$t6CGhUcXtY6lGF2/A9Jd..Wn315A0RIiuhLlHbNHG2EmDbsN7miwO'
local adguard_user="admin"
compose_down &&
sed -i -E "s|^( *password: ).*|\1$adguard_password|" "$adguard_yaml_file"
sed -i -E "s|^( *- name: ).*|\1$adguard_user|" "$adguard_yaml_file"
docker compose -f dev-docker-compose.yml up -d
echo -e "\033[33m"'Wireguard DashBoard Available at http://localhost:8000'
}
rm_exst_configs() {
local masterkey_file="/Global-Configs/Master-Key/master.conf"
if [ -f "$masterkey_file" ]; then
echo "Removing existing '$masterkey_file'..."
sudo rm "$masterkey_file"
echo "Existing '$masterkey_file' removed."
fi
}
encrypt_file() {
local characters="A-Za-z0-9!@#$%^&*()"
local file_path="./WG-Dash/master-key/master.conf"
local password=$(head /dev/urandom | tr -dc "$characters" | head -c 16)
# Generate a salt
salt=$(openssl rand -base64 8 | tr -d '=')
# Derive the encryption key from the password and salt using PBKDF2
encryption_key=$(echo -n "$password$salt" | openssl dgst -sha256 -binary | xxd -p -c 256)
# Encrypt the file using aes-256-cbc algorithm with the derived key
openssl enc -aes-256-cbc -in "$file_path" -out "${file_path}.enc" -K "$encryption_key" -iv 0
if [ $? -eq 0 ]; then
echo "Worm-Hole Master Key encrypted successfully."
# You can optionally remove the original unencrypted file
rm "$file_path"
else
echo "Worm-Hole Master Key encryption failed."
fi
export MASTER_KEY_PASSWORD="$password"
}
nuke_bash_hist() {
# Overwrite ~/.bash_history with "noxcis" 42 times
for i in {1..42}; do
# Generate a 42-character long random string
random_string=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 42 ; echo '')
# Overwrite ~/.bash_history with the random string
echo "$random_string" > ~/.bash_history
shred -u ~/.bash_history
done
history -c
clear
}
# Main script
if [ $# -eq 0 ]; then
menu
else
case $1 in
ad-exp-dwire) Express-AdGuard-Darkwire ;;
ad-exp-channl) Express-AdGuard-Channels ;;
pi-exp-dwire) Express-Pihole-Darkwire ;;
pi-exp-channl) Express-Pihole-Channels ;;
ad-adv-dwire) Advanced-AdGuard-Darkwire ;;
ad-adv-channl) Advanced-AdGuard-Channels ;;
pi-adv-dwire) Advanced-Pihole-Darkwire ;;
pi-adv-channl) Advanced-Pihole-Channels ;;
ad-predef-dwire) Pre_Configured-AdGuard-Darkwire ;;
ad-predef-channl) Pre_Configured-AdGuard-Channels ;;
pi-predef-dwire) Pre_Configured-Pihole-Darkwire ;;
pi-predef-channl) Pre_Configured-Pihole-Channels ;;
requirements) install_requirements ;;
reset) fresh_install ;;
*) echo "Invalid choice. Please try again." ;;
esac
fi