Skip to content

Commit bcc02c8

Browse files
committed
new web template scheme
1 parent 0c25d7f commit bcc02c8

File tree

1 file changed

+39
-36
lines changed

1 file changed

+39
-36
lines changed

bin/v-update-web-templates

Lines changed: 39 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
# info: updates web templates
2+
# info: update web templates
33
# options: [RESTART]
44
#
55
# The function for obtaining updated pack of web templates.
@@ -21,37 +21,40 @@ source $VESTA/conf/vesta.conf
2121
# Action #
2222
#----------------------------------------------------------#
2323

24-
# Find out OS name
25-
if [ -e "/etc/redhat-release" ]; then
26-
os="rhel"
27-
else
28-
os="ubuntu"
29-
fi
24+
# Defining config host
25+
chost='c.vestacp.com'
26+
27+
# Detcing OS
28+
case $(head -n1 /etc/issue |cut -f 1 -d ' ') in
29+
Debian) version="debian" ;;
30+
Ubuntu) version="ubuntu" ;;
31+
*) version="rhel" ;;
32+
esac
3033

31-
# Get new archive
32-
tmpdir=$(mktemp -d --dry-run)
33-
mkdir $tmpdir
34-
cd $tmpdir
35-
wget http://c.vestacp.com/$VERSION/$os/templates.tar.gz -q
36-
if [ "$?" -ne 0 ]; then
37-
echo "Error: can't download template.tar.gz"
38-
log_event "$E_CONNECT" "$EVENT"
39-
rm -rf $tmpdir
40-
exit $E_CONNECT
34+
# Detecting release
35+
if [ "$version" = 'rhel' ]; then
36+
release=$(grep -o "[0-9]" /etc/redhat-release |head -n1)
37+
fi
38+
if [ "$version" = 'ubuntu' ]; then
39+
release=$(lsb_release -r |awk '{print $2}')
40+
fi
41+
if [ "$version" = 'debian' ]; then
42+
release=$(cat /etc/issue|grep -o [0-9]|head -n1)
4143
fi
4244

43-
# Update templates
44-
tar -xzpf templates.tar.gz -C $VESTA/data/ templates/web
45+
# Defining download url
46+
vestacp="http://$chost/$version/$release"
4547

46-
# Replace includes for apache2.4
47-
if [ "$WEB_SYSTEM" = 'httpd' ] || [ "$WEB_SYSTEM" = 'apache2' ]; then
48-
if [ ! -z "$(/usr/sbin/apachectl -v | grep 'Apache/2.4')" ]; then
49-
sed -i "s/Include /IncludeOptional /g" \
50-
$VESTA/data/templates/web/$WEB_SYSTEM/*tpl
51-
fi
52-
fi
48+
# Downloading template archive
49+
cd $(mktemp -d)
50+
wget $vestacp/templates.tar.gz -q
51+
52+
check_result $? "can't download template.tar.gz" $E_CONNECT
53+
54+
# Updating templates
55+
tar -xzpf templates.tar.gz -C $VESTA/data/ templates/web
5356

54-
# Rebuild web domains
57+
# Rebuilding web domains
5558
for user in $($BIN/v-list-sys-users plain); do
5659
$BIN/v-rebuild-web-domains $user no
5760
done
@@ -61,20 +64,20 @@ done
6164
# Vesta #
6265
#----------------------------------------------------------#
6366

64-
# Restart web server
67+
# Restarting web server
6568
if [ "$restart" != 'no' ]; then
6669
$BIN/v-restart-web
67-
if [ $? -ne 0 ]; then
68-
exit $E_RESTART
70+
check_result $? "restart" >/dev/null 2>&1
71+
72+
if [ ! -z "$PROXY_SYSTTEM" ]; then
73+
$BIN/v-restart-proxy
74+
check_result $? "restart" >/dev/null 2>&1
6975
fi
7076

71-
$BIN/v-restart-proxy
72-
if [ $? -ne 0 ]; then
73-
exit $E_RESTART
77+
if [ ! -z "$WEB_BACKEND" ]; then
78+
$BIN/v-restart-proxy
79+
check_result $? "restart" >/dev/null 2>&1
7480
fi
7581
fi
7682

77-
# Delete tmpdir
78-
rm -rf $tmpdir
79-
8083
exit

0 commit comments

Comments
 (0)