-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
lamp-add
executable file
·97 lines (89 loc) · 3.8 KB
/
lamp-add
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
#!/bin/bash
#
# Add new domains to your setup. This creates the website folder, link to the
# /etc/hosts file, creates a SSL certificate and sets up a git project for you
# to begin using.
#
# Copyright: Copyright 2018-2020 Justin Hartman (https://justinhartman.co)
# Author : Justin Hartman <[email protected]> (https://justinhartman.co)
# License : https://opensource.org/licenses/AGPL-3.0 AGPL-3.0
# Version : 1.2.2
# Link : https://github.com/justinhartman/lamp-ssl
# Since : 0.1.0
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
#######################################
# Includes the colour palette and
# other global variables
# Globals:
# None
# Arguments:
# None
# Returns:
# Variables
#######################################
global_includes() {
source ./scripts/globals.sh
source ./scripts/colour_palette.sh
}
#######################################
# This is the main application thread.
# Globals:
# None
# Arguments:
# None
# Returns:
# String Multi-interactive messages.
#######################################
main_application() {
# shellcheck source=scripts/enter_domain.sh
source "${scripts}"/enter_domain.sh # Get domain name to be added
# shellcheck source=scripts/openssl_config.sh
source "${scripts}"/openssl_config.sh # Add domain to 'openssl.conf' configuration file
# shellcheck source=scripts/openssl_command.sh
source "${scripts}"/openssl_command.sh # Create SSL Certificates for the new domain
# shellcheck source=scripts/keychain_certificate.sh
source "${scripts}"/keychain_certificate.sh # Adding new SSL cert to macOS' Keychain
# shellcheck source=scripts/hosts_domain.sh
source "${scripts}"/hosts_domain.sh # Add new domain to hosts file
# shellcheck source=scripts/folder_and_git.sh
source "${scripts}"/folder_and_git.sh # Add website folder and initialise git repo
# shellcheck source=scripts/git_setup.sh
source "${scripts}"/git_setup.sh # git initial structure, files and check-in
# shellcheck source=scripts/website_folder_ownership.sh
source "${scripts}"/website_folder_ownership.sh # Set correct folder ownership
# shellcheck source=scripts/restart_apache.sh
source "${scripts}"/restart_apache.sh # Restart Apache 2
printf "${GRN}%s\\n" "${TOP}"
printf '* %-76s %s\n' "Congratulations! Your domain has been added and you can begin using it" "*"
printf '* %-76s %s\n' "immediately. You will find your website in the following folder:" "*"
printf '* %-76s %s\n' "'${dist}/websites/${domain}'" "*"
printf '* %-76s %s\n' "You can edit all your files in this location. You can access your website" "*"
printf '* %-76s %s\n' " by going to https://${domain} in your web browser." "*"
printf "%s${NOC}\\n\\n" "${BOTTOM}"
}
global_includes # Includes global variables and file paths.
if ! [ "$(id -u)" = 0 ]; then
printf "${RED}%s\\n" "${TOP}"
printf '* %-76s %s\n' "This needs to be run as root. Please run it again using 'sudo' by executing" "*"
printf '* %-76s %s\n' "the following command: $ sudo ./lamp-add" "*"
printf "%s${NOC}\\n\\n" "${BOTTOM}"
exit 1
fi
#######################################
# Run the main install.
#######################################
main_application
exit 0