forked from hestiacp/hestiacp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhst-install.sh
More file actions
executable file
·154 lines (143 loc) · 4.4 KB
/
hst-install.sh
File metadata and controls
executable file
·154 lines (143 loc) · 4.4 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
145
146
147
148
149
150
151
152
153
154
#!/bin/bash
# ======================================================== #
#
# Hestia Control Panel Installation Routine
# Automatic OS detection wrapper
# https://www.hestiacp.com/
#
# Currently Supported Operating Systems:
#
# Debian 10, 11, 12
# Ubuntu 20.04, 22.04
# AlmaLinux, EuroLinux, Red Hat EnterPrise Linux, Rocky Linux 8, 9
#
# ======================================================== #
# Am I root?
if [ "x$(id -u)" != 'x0' ]; then
echo 'Error: this script can only be executed by root'
exit 1
fi
# Check admin user account
if [ ! -z "$(grep ^admin: /etc/passwd)" ] && [ -z "$1" ]; then
echo "Error: user admin exists"
echo
echo 'Please remove admin user before proceeding.'
echo 'If you want to do it automatically run installer with -f option:'
echo "Example: bash $0 --force"
exit 1
fi
# Check admin group
if [ ! -z "$(grep ^admin: /etc/group)" ] && [ -z "$1" ]; then
echo "Error: group admin exists"
echo
echo 'Please remove admin group before proceeding.'
echo 'If you want to do it automatically run installer with -f option:'
echo "Example: bash $0 --force"
exit 1
fi
# Detect OS
if [ -e "/etc/os-release" ] && [ ! -e "/etc/redhat-release" ]; then
type=$(grep "^ID=" /etc/os-release | cut -f 2 -d '=')
if [ "$type" = "ubuntu" ]; then
# Check if lsb_release is installed
if [ -e '/usr/bin/lsb_release' ]; then
release="$(lsb_release -s -r)"
VERSION='ubuntu'
else
echo "lsb_release is currently not installed, please install it:"
echo "apt-get update && apt-get install lsb-release"
exit 1
fi
elif [ "$type" = "debian" ]; then
release=$(cat /etc/debian_version | grep -o "[0-9]\{1,2\}" | head -n1)
VERSION='debian'
fi
elif [ -e "/etc/os-release" ] && [ -e "/etc/redhat-release" ]; then
type=$(grep "^ID=" /etc/os-release | cut -f 2 -d '"')
if [ "$type" = "rhel" ]; then
release=$(cat /etc/redhat-release | cut -f 1 -d '.' | awk '{print $3}')
VERSION='rhel'
elif [ "$type" = "almalinux" ]; then
release=$(cat /etc/redhat-release | cut -f 1 -d '.' | awk '{print $3}')
VERSION='almalinux'
elif [ "$type" = "eurolinux" ]; then
release=$(cat /etc/redhat-release | cut -f 1 -d '.' | awk '{print $3}')
VERSION='eurolinux'
elif [ "$type" = "rocky" ]; then
release=$(cat /etc/redhat-release | cut -f 1 -d '.' | awk '{print $3}')
VERSION='rockylinux'
fi
else
type="NoSupport"
fi
no_support_message() {
echo "****************************************************"
echo "Your operating system (OS) is not supported by"
echo "Hestia Control Panel. Officially supported releases:"
echo "****************************************************"
echo " Debian 10, 11, 12"
echo " Ubuntu 20.04, 22.04 LTS"
# Commenting this out for now
# echo " AlmaLinux, EuroLinux, Red Hat EnterPrise Linux, Rocky Linux 8,9"
echo ""
exit 1
}
if [ "$type" = "NoSupport" ]; then
no_support_message
fi
check_wget_curl() {
# Check wget
if [ -e '/usr/bin/wget' ]; then
if [ -e '/etc/redhat-release' ]; then
wget -q https://raw.githubusercontent.com/hestiacp/hestiacp/release/install/hst-install-rhel.sh -O hst-install-rhel.sh
if [ "$?" -eq '0' ]; then
bash hst-install-rhel.sh $*
exit
else
echo "Error: hst-install-rhel.sh download failed."
exit 1
fi
else
wget -q https://raw.githubusercontent.com/hestiacp/hestiacp/release/install/hst-install-$type.sh -O hst-install-$type.sh
if [ "$?" -eq '0' ]; then
bash hst-install-$type.sh $*
exit
else
echo "Error: hst-install-$type.sh download failed."
exit 1
fi
fi
fi
# Check curl
if [ -e '/usr/bin/curl' ]; then
if [ -e '/etc/redhat-release' ]; then
curl -s -O https://raw.githubusercontent.com/hestiacp/hestiacp/release/install/hst-install-rhel.sh
if [ "$?" -eq '0' ]; then
bash hst-install-rhel.sh $*
exit
else
echo "Error: hst-install-rhel.sh download failed."
exit 1
fi
else
curl -s -O https://raw.githubusercontent.com/hestiacp/hestiacp/release/install/hst-install-$type.sh
if [ "$?" -eq '0' ]; then
bash hst-install-$type.sh $*
exit
else
echo "Error: hst-install-$type.sh download failed."
exit 1
fi
fi
fi
}
# Check for supported operating system before proceeding with download
# of OS-specific installer, and throw error message if unsupported OS detected.
if [[ "$release" =~ ^(10|11|12|20.04|22.04)$ ]]; then
check_wget_curl $*
elif [[ -e "/etc/redhat-release" ]] && [[ "$release" =~ ^(8|9)$ ]]; then
check_wget_curl $*
else
no_support_message
fi
exit