|
11 | 11 |
|
12 | 12 | # Am I root? |
13 | 13 | 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 |
16 | 16 | fi |
17 | 17 |
|
18 | 18 | # Check admin user account |
@@ -42,34 +42,62 @@ case $(head -n1 /etc/issue | cut -f 1 -d ' ') in |
42 | 42 | *) type="NoSupport" ;; |
43 | 43 | esac |
44 | 44 |
|
| 45 | +no_support_message() { |
| 46 | + echo "Your OS is currently not supported." |
| 47 | + exit 1; |
| 48 | +} |
| 49 | + |
45 | 50 | # Check if OS is supported |
46 | 51 | 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' |
49 | 87 | fi |
50 | 88 |
|
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' |
61 | 93 | fi |
62 | 94 |
|
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 |
73 | 100 | fi |
74 | 101 |
|
| 102 | + |
75 | 103 | exit |
0 commit comments