-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
install.sh
executable file
·95 lines (74 loc) · 3.12 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
#!/usr/bin/env bash
###############################################################################
# DIG Node Setup Script with SSL and Let's Encrypt
# This script installs and configures a DIG Node with Nginx reverse proxy,
# using HTTPS to communicate with the content server, and attaching client
# certificates. It also sets up Let's Encrypt SSL certificates if a hostname
# is provided and the user opts in. Please run this script as root.
###############################################################################
# Load reusable functions
source ./lib/colors.sh
source ./lib/check_root.sh
source ./lib/detect_distro.sh
source ./lib/detect_cloud_vm.sh
source ./lib/check_software.sh
source ./lib/docker_group.sh
source ./lib/stop_existing_service.sh
source ./lib/generate_credentials.sh
source ./lib/collect_user_inputs.sh
source ./lib/ask_include_nginx.sh
source ./lib/open_ports.sh
source ./lib/open_ports_upnp.sh
source ./lib/docker_compose_setup.sh
source ./lib/nginx_setup.sh
source ./lib/pull_docker_images.sh
source ./lib/create_systemd_service.sh
###############################################################################
# Script Execution Begins
###############################################################################
# Ensure the script is run as root
check_root
# Display script header
echo -e "${GREEN}
###############################################################################
# DIG Node Setup Script with SSL and Let's Encrypt #
###############################################################################
${NC}"
# Detect the distribution and set package manager and service commands
detect_distro
# Detect if running on an Cloud virtual machine
detect_cloud_vm # Ensure this is called before check_software
# Check for required software at the beginning
check_software
# Stop the existing DIG Node service if running
stop_existing_service
# Check if the current user is in the Docker group
docker_group_check
# Generate high-entropy DIG_USERNAME and DIG_PASSWORD
generate_credentials
# Collect additional user inputs (trusted full node, public IP, Mercenary Mode)
collect_user_inputs
# Ask if the user wants to include the Nginx reverse-proxy container
ask_include_nginx
# Open ports using the appropriate firewall
ask_open_ports
# Attempt to open ports using UPnP (skip if on EC2)
if [[ $IS_CLOUD_VM == "yes" ]]; then
echo -e "${YELLOW}Running on Cloud VM instance. Skipping UPnP port forwarding.${NC}"
echo -e "${YELLOW}Please ensure your Security Groups are configured to allow inbound traffic on the required ports.${NC}"
else
ask_upnp_ports
fi
# Create docker-compose.yml file
create_docker_compose
# Setup Nginx reverse proxy if chosen
nginx_setup
# Pull latest Docker images
pull_docker_images
# Create systemd service file
create_systemd_service
# Completion message
echo -e "${GREEN}Your DIG Node setup is complete!${NC}"
###############################################################################
# End of Script
###############################################################################