-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall
More file actions
executable file
·144 lines (119 loc) · 3.48 KB
/
Copy pathinstall
File metadata and controls
executable file
·144 lines (119 loc) · 3.48 KB
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
#!/usr/bin/env bash
#
# Lamp Installer
#
LAMP_SOURCE="${BASH_SOURCE[0]:-$0}"
if [[ "$(id -u)" -ne "0" ]]; then
if command -v sudo >/dev/null 2>&1; then
echo "Not running as root, auto-executing with sudo"
exec sudo "$LAMP_SOURCE"
fi
echo "The sudo command not found. Please run this script as root."
exit 1
fi
LAMP_PATH="$(cd -P -- "$(dirname -- "$LAMP_SOURCE")" && pwd -P)"
if [[ -f "$LAMP_PATH/config/lamp.bash" ]]; then
source "$LAMP_PATH/config/lamp.bash"
if [[ -n "$LAMP_CONFIG_GITHUB_TOKEN" && "$LAMP_CONFIG_GITHUB_TOKEN" =~ ^gh ]]; then
# shellcheck disable=SC2034
LAMP_GITHUB_TOKEN="$LAMP_CONFIG_GITHUB_TOKEN"
fi
fi
source "$LAMP_PATH/lib/functions.bash"
LAMP_DISTRO="$(get_distro)"
if [[ -z "$LAMP_DISTRO" || ! -d "$LAMP_PATH/distros/$LAMP_DISTRO" ]]; then
echo "Unsupported distro"
exit 1
fi
LAMP_DISTRO_CODENAME="$(get_distro_codename)"
if [[ -z "$LAMP_DISTRO_CODENAME" ]]; then
echo "Missing distro codename"
exit 1
fi
LAMP_DISTRO_ID="$(get_distro_id)"
if [[ -z "$LAMP_DISTRO_ID" ]]; then
echo "Missing distro ID"
exit 1
fi
LAMP_OS_ARCH=
case "$(uname -m)" in
x86_64 | amd64)
LAMP_OS_ARCH="amd64"
;;
aarch64 | arm64)
LAMP_OS_ARCH="arm64"
;;
esac
if [[ -z "$LAMP_OS_ARCH" ]]; then
echo "Unsupported OS architecture"
exit 1
fi
LAMP_DISTRO_PATH="$LAMP_PATH/distros/$LAMP_DISTRO"
if [[ -n "$LAMP_CONFIG_FQDN" ]]; then
LAMP_FQDN="$LAMP_CONFIG_FQDN"
else
LAMP_FQDN="$(hostname -f)"
fi
make_array LAMP_FQDN_EXPANDED "${LAMP_FQDN//./ }"
if [[ ${#LAMP_FQDN_EXPANDED[@]} -lt 2 ]]; then
console_log "Invalid FQDN format. Expected 'hostname.tld'."
console_log "Set LAMP_CONFIG_FQDN or configure a valid system FQDN."
exit 1
fi
if [[ ${#LAMP_FQDN_EXPANDED[@]} -gt 2 ]]; then
console_log "The FQDN '$LAMP_FQDN' is a subdomain."
console_log "Only 'hostname.tld' format is supported, truncating."
LAMP_FQDN="$(echo "${LAMP_FQDN_EXPANDED[@]}" | awk '{print $(NF-1)"."$NF}')"
fi
LAMP_TLD="$(echo "$LAMP_FQDN" | awk -F'.' '{print $NF}')"
if [[ -n "$LAMP_CONFIG_TLD" && "$LAMP_TLD" != "$LAMP_CONFIG_TLD" ]]; then
console_log "Applying configured TLD '$LAMP_CONFIG_TLD' instead of '$LAMP_TLD'."
LAMP_TLD="$LAMP_CONFIG_TLD"
LAMP_FQDN="${LAMP_FQDN%.*}.$LAMP_TLD"
fi
console_log "The FQDN for lamp is: $LAMP_FQDN"
if [[ "$LAMP_TLD" == "localhost" ]]; then
console_log "The IP for lamp is: 127.0.0.1"
else
if [[ -n "$LAMP_CONFIG_IP_ADDRESS" ]]; then
LAMP_IP_ADDRESSES=("$LAMP_CONFIG_IP_ADDRESS")
else
make_array LAMP_IP_ADDRESSES "$(hostname -I)"
fi
if [[ ${#LAMP_IP_ADDRESSES[@]} -gt 1 ]]; then
console_log "Multiples IP's detected, validating the IPv4"
for i in "${!LAMP_IP_ADDRESSES[@]}"; do
if ! [[ "${LAMP_IP_ADDRESSES[i]}" =~ ^([0-9]{1,3}\.){3}([0-9]{1,3})$ ]]; then
unset 'LAMP_IP_ADDRESSES[i]'
fi
done
unset i
fi
if [[ ${#LAMP_IP_ADDRESSES[@]} -ne 1 ]]; then
console_log "Declare the LAMP_CONFIG_IP_ADDRESS option to select the correct IP"
for x in "${LAMP_IP_ADDRESSES[@]}"; do
console_log "Possible IP: $x"
done
exit 1
fi
LAMP_IP_ADDRESS="${LAMP_IP_ADDRESSES[0]}"
console_log "The IP for lamp is: $LAMP_IP_ADDRESS"
fi
console_log "The Public IP for lamp is: $(get_public_ip)"
LAMP_INCLUDE_NAMES=(
system
mkcert
memcached
php
apache
mariadb
phpmyadmin
mailhog # Deprecated, only exits to remove it.
mailpit
bind # Deprecated, only exits to remove it.
coredns
bin
)
for LAMP_INCLUDE_NAME in "${LAMP_INCLUDE_NAMES[@]}"; do
include "$LAMP_INCLUDE_NAME"
done