summaryrefslogtreecommitdiff
path: root/8-nginx.sh
blob: efcaa6e5af6247a7988892490444eb08e1be03e6 (plain)
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
#!/usr/bin/env bash

source ./auto/helper-logic

# Clear the screen and print the header
PrintHeader

# Ensure we are running as root
EnsureRoot

# Ensure stage 7 is complete
EnsureStageIsComplete 7

# Add NGINX configuration
echo "Configuring NGINX..."

#region NGINX default configuration
if [ -f /etc/nginx/sites-enabled/default ]; then
  function RemoveDefaultNginxConfiguration() {
    rm /etc/nginx/sites-enabled/default
  }

  Run "RemoveDefaultNginxConfiguration" \
    "Removing default NGINX configuration..." \
    "Failed to remove default NGINX configuration." \
    "Default NGINX configuration has been removed."
fi
#endregion

#region NGINX apt-mirror configuration
if [ -f /etc/nginx/sites-available/apt-mirror ]; then
  function RemoveAptMirrorNginxConfiguration() {
    rm /etc/nginx/sites-available/apt-mirror
  }

  Run "RemoveAptMirrorNginxConfiguration" \
    "Removing apt-mirror NGINX configuration..." \
    "Failed to remove apt-mirror NGINX configuration." \
    "Apt-mirror NGINX configuration has been removed."
fi

function CopyAvailableSiteFile {
  cp ./auto/nginx-site /etc/nginx/sites-available/apt-mirror
}

Run "CopyAvailableSiteFile" \
  "Copying apt-mirror NGINX configuration file..." \
  "Failed to copy apt-mirror NGINX configuration." \
  "Apt-mirror NGINX configuration has been copied."
#endregion

#region Enable NGINX apt-mirror configuration
if [ ! -f /etc/nginx/sites-enabled/apt-mirror ]; then
  function LinkAptMirrorNginxConfiguration() {
    ln -s /etc/nginx/sites-available/apt-mirror /etc/nginx/sites-enabled/apt-mirror
  }

  Run "LinkAptMirrorNginxConfiguration" \
    "Linking apt-mirror NGINX configuration file..." \
    "Failed to link apt-mirror NGINX configuration." \
    "Apt-mirror NGINX configuration has been linked."
fi
#endregion

#region Restart NGINX
function RestartNginx() {
  systemctl restart nginx
}

Run "RestartNginx" \
  "Restarting NGINX..." \
  "Failed to restart NGINX." \
  "NGINX has been restarted."
#endregion

echo
echo "Part 8 of the installer is now done."
echo "The installation is now done - you can build the ISO by running the build-iso.sh bash script."

# Create marker file
CreateMarkerFile 8