Skip to content

Commit 6509d7b

Browse files
luizjrKristan Kenney
authored andcommitted
Check for Ubuntu LTS releases before installing
If the system is running on a non-LTS release, abort the installation process as it is an unsupported configuration.
1 parent 8b34f42 commit 6509d7b

File tree

1 file changed

+52
-24
lines changed

1 file changed

+52
-24
lines changed

install/hst-install.sh

Lines changed: 52 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
# Am I root?
1313
if [ "x$(id -u)" != 'x0' ]; then
14-
echo 'Error: this script can only be executed by root'
15-
exit 1
14+
echo 'Error: this script can only be executed by root'
15+
exit 1
1616
fi
1717

1818
# Check admin user account
@@ -42,34 +42,62 @@ case $(head -n1 /etc/issue | cut -f 1 -d ' ') in
4242
*) type="NoSupport" ;;
4343
esac
4444

45+
no_support_message() {
46+
echo "Your OS is currently not supported."
47+
exit 1;
48+
}
49+
4550
# Check if OS is supported
4651
if [ "$type" = "NoSupport" ]; then
47-
echo "Your OS is currently not supported."
48-
exit 1;
52+
no_support_message
53+
fi
54+
55+
check_wget_curl(){
56+
# Check wget
57+
if [ -e '/usr/bin/wget' ]; then
58+
wget -q https://raw.githubusercontent.com/hestiacp/hestiacp/master/install/hst-install-$type.sh -O hst-install-$type.sh
59+
if [ "$?" -eq '0' ]; then
60+
bash hst-install-$type.sh $*
61+
exit
62+
else
63+
echo "Error: hst-install-$type.sh download failed."
64+
exit 1
65+
fi
66+
fi
67+
68+
# Check curl
69+
if [ -e '/usr/bin/curl' ]; then
70+
curl -s -O https://raw.githubusercontent.com/hestiacp/hestiacp/master/install/hst-install-$type.sh
71+
if [ "$?" -eq '0' ]; then
72+
bash hst-install-$type.sh $*
73+
exit
74+
else
75+
echo "Error: hst-install-$type.sh download failed."
76+
exit 1
77+
fi
78+
fi
79+
}
80+
81+
82+
# Detect codename
83+
if [ "$type" = "debian" ]; then
84+
codename="$(cat /etc/os-release |grep VERSION= |cut -f 2 -d \(|cut -f 1 -d \))"
85+
release=$(cat /etc/debian_version|grep -o [0-9]|head -n1)
86+
VERSION='debian'
4987
fi
5088

51-
# Check wget
52-
if [ -e '/usr/bin/wget' ]; then
53-
wget -q https://raw.githubusercontent.com/hestiacp/hestiacp/master/install/hst-install-$type.sh -O hst-install-$type.sh
54-
if [ "$?" -eq '0' ]; then
55-
bash hst-install-$type.sh $*
56-
exit
57-
else
58-
echo "Error: hst-install-$type.sh download failed."
59-
exit 1
60-
fi
89+
if [ "$type" = "ubuntu" ]; then
90+
codename="$(lsb_release -s -c)"
91+
release="$(lsb_release -s -r)"
92+
VERSION='ubuntu'
6193
fi
6294

63-
# Check curl
64-
if [ -e '/usr/bin/curl' ]; then
65-
curl -s -O https://raw.githubusercontent.com/hestiacp/hestiacp/master/install/hst-install-$type.sh
66-
if [ "$?" -eq '0' ]; then
67-
bash hst-install-$type.sh $*
68-
exit
69-
else
70-
echo "Error: hst-install-$type.sh download failed."
71-
exit 1
72-
fi
95+
# Check Ubuntu Version Are Acceptable to install
96+
if [ "$codename" = "14.04" ] || [ "$codename" = "16.04" ] || [ "$codename" = "18.04" ]; then
97+
check_wget_curl
98+
else
99+
no_support_message
73100
fi
74101

102+
75103
exit

0 commit comments

Comments
 (0)