-
Notifications
You must be signed in to change notification settings - Fork 1
/
autoinstaller.sh
108 lines (92 loc) · 3.44 KB
/
autoinstaller.sh
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
#!/usr/bin/env bash
THEME_NAME=directadmin
THEME_URL=https://github.com/RickBakkr/SentoraDirectAdmin/archive/master.zip
SENTORA_VERSION=( "1.0.0", "1.0.1", "1.0.2", "1.0.3" )
echo "$THEME_NAME Theme installer/updater for Sentora."
echo "This autoinstaller is made by Ron-e / Auxio. Thanks!"
echo "###########################################################"
echo "# THE SCRIPT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE #"
echo "# USEFUL, IT IS PROVIDED 'AS IS' AND WITHOUT ANY WARRANTY #"
echo "###########################################################"
echo "Checking if the OS is compatible with this installer/updater..."
if [ -f /etc/centos-release ]; then
OS="CentOs"
VERFULL=$(sed 's/^.*release //;s/ (Fin.*$//' /etc/centos-release)
VER=${VERFULL:0:1} # return 6 or 7
elif [ -f /etc/lsb-release ]; then
OS=$(grep DISTRIB_ID /etc/lsb-release | sed 's/^.*=//')
VER=$(grep DISTRIB_RELEASE /etc/lsb-release | sed 's/^.*=//')
else
OS=$(uname -s)
VER=$(uname -r)
fi
if [[ "$OS" = "CentOs" && ("$VER" = "6" || "$VER" = "7" ) ||
"$OS" = "Ubuntu" && ("$VER" = "12.04" || "$VER" = "14.04" ) ]] ; then
echo "$OS is supported by Sentora and this theme installer/updater."
else
echo "Sorry, $OS $VERFULL is not supported by Sentora and this theme installer/updater."
exit 1
fi
echo "Checking if Sentora is installed and compatible with this installer/updater..."
function contains() {
local n=$#
local value=${!n}
for ((i=1;i < $#;i++)) {
if [ "${!i}" == "${value}" ]; then
echo "y"
return 0
fi
}
echo "n"
return 1
}
if [ -d "/etc/sentora/panel" ]; then
VERSION_SENTORA=$(setso --show dbversion)
if [ $(contains "${SENTORA_VERSION[@]}" "$VERSION_SENTORA") == "y" ]; then
#if [[ "$VERSION_SENTORA" = "1.0.0" ]]; then
echo "Sentora version $VERSION_SENTORA is compatible with this installer/updater."
else
echo "Sorry, Sentora version $VERSION_SENTORA is not compatible with this installer/updater."
exit
fi
else
echo "Sorry, Sentora is not installed on your server."
echo "please install Sentora before using this $THEME_NAME installer/updater. (http://docs.sentora.org/?node=7)"
exit
fi
if [ -d "/etc/sentora/panel/etc/styles/$THEME_NAME" ]; then
THEME_UPDATE=1
echo "You have the $THEME_NAME theme already installed, theme will be updated."
else
THEME_UPDATE=0
echo "You have not jet installed the $THEME_NAME theme, theme will be installed."
fi
cd /etc/sentora/panel/etc/styles/
echo "Downloading the $THEME_NAME theme..."
while true; do
wget -qO $THEME_NAME.zip $THEME_URL
if [[ -f $THEME_NAME.zip ]]; then
break;
else
echo "Failed to download the $THEME_NAME theme from Github."
exit 1
fi
done
if [[ "$THEME_UPDATE" = "1" ]]; then
echo "Updating the $THEME_NAME theme..."
else
echo "Installing the $THEME_NAME theme..."
fi
unzip -q $THEME_NAME.zip
rm -f $THEME_NAME.zip
if [[ "$THEME_UPDATE" = "1" ]]; then
rm -rf /etc/sentora/panel/etc/styles/$THEME_NAME
fi
mv -u -f SentoraDirectAdmin-master $THEME_NAME
echo "##########################################################################################"
if [[ "$THEME_UPDATE" = "1" ]]; then
echo " Congratulations the $THEME_NAME theme for Sentora has now been updated on your server."
else
echo " Congratulations the $THEME_NAME theme for Sentora has now been installed on your server."
fi
echo "##########################################################################################"