@@ -65,8 +65,6 @@ _determineOS(){
65
65
OS=$ID
66
66
elif [ -f /etc/redhat-release ]; then
67
67
OS=" redhat"
68
- # elif [ -f /etc/arch-release ]; then
69
- # OS="arch"
70
68
else
71
69
printf " [WGDashboard] %s Sorry, your OS is not supported. Currently the install script only support Debian-based, Red Hat-based OS." " $heavy_crossmark "
72
70
printf " %s\n" " $helpMsg "
@@ -129,18 +127,6 @@ _installPythonVenv(){
129
127
ubuntu|debian)
130
128
{ sudo apt-get update; sudo apt-get install ${pythonExecutable} -venv; } & >> ./log/install.txt
131
129
;;
132
- # centos|fedora|redhat|rhel)
133
- # if command -v dnf &> /dev/null; then
134
- # { sudo dnf install -y ${pythonExecutable}-virtualenv; printf "\n\n"; } >> ./log/install.txt
135
- # else
136
- # { sudo yum install -y ${pythonExecutable}-virtualenv; printf "\n\n"; } >> ./log/install.txt
137
- # fi
138
- # ;;
139
- # *)
140
- # printf "[WGDashboard] %s Sorry, your OS is not supported. Currently the install script only support Debian-based, Red Hat-based OS.\n" "$heavy_crossmark"
141
- # printf "%s\n" "$helpMsg"
142
- # kill $TOP_PID
143
- # ;;
144
130
esac
145
131
fi
146
132
@@ -257,9 +243,9 @@ install_wgd(){
257
243
_installPythonPip
258
244
259
245
if [ ! -d " db" ]
260
- then
261
- printf " [WGDashboard] Creating ./db folder\n"
262
- mkdir " db"
246
+ then
247
+ printf " [WGDashboard] Creating ./db folder\n"
248
+ mkdir " db"
263
249
fi
264
250
_check_and_set_venv
265
251
printf " [WGDashboard] Upgrading Python Package Manage (PIP)\n"
@@ -288,11 +274,11 @@ check_wgd_status(){
288
274
}
289
275
290
276
certbot_create_ssl () {
291
- certbot certonly --config ./certbot.ini --email " $EMAIL " --work-dir $cb_work_dir --config-dir $cb_config_dir --domain " $SERVERURL "
277
+ certbot certonly --config ./certbot.ini --email " $EMAIL " --work-dir $cb_work_dir --config-dir $cb_config_dir --domain " $SERVERURL "
292
278
}
293
279
294
280
certbot_renew_ssl () {
295
- certbot renew --work-dir $cb_work_dir --config-dir $cb_config_dir
281
+ certbot renew --work-dir $cb_work_dir --config-dir $cb_config_dir
296
282
}
297
283
298
284
gunicorn_start () {
@@ -319,7 +305,7 @@ gunicorn_start () {
319
305
}
320
306
321
307
gunicorn_stop () {
322
- sudo kill $( cat ./gunicorn.pid)
308
+ sudo kill $( cat ./gunicorn.pid)
323
309
}
324
310
325
311
start_wgd () {
@@ -328,40 +314,41 @@ start_wgd () {
328
314
}
329
315
330
316
stop_wgd () {
331
- if test -f " $PID_FILE " ; then
332
- gunicorn_stop
333
- else
334
- kill " $( ps aux | grep " [p]ython3 $app_name " | awk ' {print $2}' ) "
335
- fi
317
+ if test -f " $PID_FILE " ; then
318
+ gunicorn_stop
319
+ else
320
+ kill " $( ps aux | grep " [p]ython3 $app_name " | awk ' {print $2}' ) "
321
+ fi
336
322
}
337
323
338
324
startwgd_docker () {
339
325
_checkWireguard
340
- printf " [WGDashboard] WireGuard Config Started \n"
326
+ printf " [WGDashboard][Docker] WireGuard configuration started \n"
341
327
{ date; start_core ; printf " \n\n" ; } >> ./log/install.txt
342
328
gunicorn_start
343
329
}
344
- start_core () {
345
- local iptable_dir=" /opt/wireguarddashboard/src/iptable-rules"
346
- # Check if wg0.conf exists in /etc/wireguard
347
- if [[ ! -f /etc/wireguard/wg0.conf ]]; then
348
- echo " wg0.conf not found. Running Generate Configuration."
349
- newconf_wgd
350
- else
351
- echo " wg0.conf already exists. Skipping WireGuard Config Generation."
352
- fi
353
- # Re-assign config_files to ensure it includes any newly created configurations
354
- local config_files=$( find /etc/wireguard -type f -name " *.conf" )
355
-
356
- # Set file permissions
357
- find /etc/wireguard -type f -name " *.conf" -exec chmod 600 {} \;
358
- find " $iptable_dir " -type f -name " *.sh" -exec chmod +x {} \;
359
330
360
- # Start WireGuard for each config file
361
- for file in $config_files ; do
362
- config_name=$( basename " $file " " .conf" )
363
- wg-quick up " $config_name "
364
- done
331
+ start_core () {
332
+ local iptable_dir=" /opt/wireguarddashboard/src/iptable-rules"
333
+ # Check if wg0.conf exists in /etc/wireguard
334
+ if [[ ! -f /etc/wireguard/wg0.conf ]]; then
335
+ echo " [WGDashboard][Docker] wg0.conf not found. Running generate configuration."
336
+ newconf_wgd
337
+ else
338
+ echo " [WGDashboard][Docker] wg0.conf already exists. Skipping WireGuard configuration generation."
339
+ fi
340
+ # Re-assign config_files to ensure it includes any newly created configurations
341
+ local config_files=$( find /etc/wireguard -type f -name " *.conf" )
342
+
343
+ # Set file permissions
344
+ find /etc/wireguard -type f -name " *.conf" -exec chmod 600 {} \;
345
+ find " $iptable_dir " -type f -name " *.sh" -exec chmod +x {} \;
346
+
347
+ # Start WireGuard for each config file
348
+ for file in $config_files ; do
349
+ config_name=$( basename " $file " " .conf" )
350
+ wg-quick up " $config_name "
351
+ done
365
352
}
366
353
367
354
@@ -383,15 +370,14 @@ EOF
383
370
}
384
371
385
372
start_wgd_debug () {
386
- printf " %s\n" " $dashes "
387
- _checkWireguard
388
- printf " [WGDashboard] Starting WGDashboard in the foreground.\n"
389
- sudo " $venv_python " " $app_name "
390
- printf " %s\n" " $dashes "
373
+ printf " %s\n" " $dashes "
374
+ _checkWireguard
375
+ printf " [WGDashboard] Starting WGDashboard in the foreground.\n"
376
+ sudo " $venv_python " " $app_name "
377
+ printf " %s\n" " $dashes "
391
378
}
392
379
393
380
update_wgd () {
394
-
395
381
_determineOS
396
382
if ! python3 --version > /dev/null 2>&1
397
383
then
@@ -430,55 +416,55 @@ update_wgd() {
430
416
}
431
417
432
418
if [ " $# " != 1 ];
433
- then
434
- help
435
- else
436
- if [ " $1 " = " start" ]; then
437
- if check_wgd_status; then
438
- printf " %s\n" " $dashes "
439
- printf " [WGDashboard] WGDashboard is already running.\n"
440
- printf " %s\n" " $dashes "
441
- else
442
- start_wgd
443
- fi
444
- elif [ " $1 " = " docker_start" ]; then
445
- printf " %s\n" " $dashes "
446
- startwgd_docker
447
- printf " %s\n" " $dashes "
448
- elif [ " $1 " = " stop" ]; then
449
- if check_wgd_status; then
450
- printf " %s\n" " $dashes "
451
- stop_wgd
452
- printf " [WGDashboard] WGDashboard is stopped.\n"
453
- printf " %s\n" " $dashes "
454
- else
455
- printf " %s\n" " $dashes "
456
- printf " [WGDashboard] WGDashboard is not running.\n"
457
- printf " %s\n" " $dashes "
458
- fi
459
- elif [ " $1 " = " update" ]; then
460
- update_wgd
461
- elif [ " $1 " = " install" ]; then
462
- printf " %s\n" " $dashes "
463
- install_wgd
464
- printf " %s\n" " $dashes "
465
- elif [ " $1 " = " restart" ]; then
466
- if check_wgd_status; then
467
- printf " %s\n" " $dashes "
468
- stop_wgd
469
- printf " | WGDashboard is stopped. | \n"
470
- sleep 4
471
- start_wgd
472
- else
473
- start_wgd
474
- fi
475
- elif [ " $1 " = " debug" ]; then
476
- if check_wgd_status; then
477
- printf " | WGDashboard is already running. | \n"
478
- else
479
- start_wgd_debug
480
- fi
481
- else
482
- help
483
- fi
419
+ then
420
+ help
421
+ else
422
+ if [ " $1 " = " start" ]; then
423
+ if check_wgd_status; then
424
+ printf " %s\n" " $dashes "
425
+ printf " [WGDashboard] WGDashboard is already running.\n"
426
+ printf " %s\n" " $dashes "
427
+ else
428
+ start_wgd
429
+ fi
430
+ elif [ " $1 " = " docker_start" ]; then
431
+ printf " %s\n" " $dashes "
432
+ startwgd_docker
433
+ printf " %s\n" " $dashes "
434
+ elif [ " $1 " = " stop" ]; then
435
+ if check_wgd_status; then
436
+ printf " %s\n" " $dashes "
437
+ stop_wgd
438
+ printf " [WGDashboard] WGDashboard is stopped.\n"
439
+ printf " %s\n" " $dashes "
440
+ else
441
+ printf " %s\n" " $dashes "
442
+ printf " [WGDashboard] WGDashboard is not running.\n"
443
+ printf " %s\n" " $dashes "
444
+ fi
445
+ elif [ " $1 " = " update" ]; then
446
+ update_wgd
447
+ elif [ " $1 " = " install" ]; then
448
+ printf " %s\n" " $dashes "
449
+ install_wgd
450
+ printf " %s\n" " $dashes "
451
+ elif [ " $1 " = " restart" ]; then
452
+ if check_wgd_status; then
453
+ printf " %s\n" " $dashes "
454
+ stop_wgd
455
+ printf " [WGDashboard] WGDashboard is stopped.\n"
456
+ sleep 4
457
+ start_wgd
458
+ else
459
+ start_wgd
460
+ fi
461
+ elif [ " $1 " = " debug" ]; then
462
+ if check_wgd_status; then
463
+ printf " [WGDashboard] WGDashboard is already running.\n"
464
+ else
465
+ start_wgd_debug
466
+ fi
467
+ else
468
+ help
469
+ fi
484
470
fi
0 commit comments