new web template scheme

This commit is contained in:
Serghey Rodin 2015-10-24 18:43:42 +03:00
commit bcc02c858d

View file

@ -1,5 +1,5 @@
#!/bin/bash
# info: updates web templates
# info: update web templates
# options: [RESTART]
#
# The function for obtaining updated pack of web templates.
@ -21,37 +21,40 @@ source $VESTA/conf/vesta.conf
# Action #
#----------------------------------------------------------#
# Find out OS name
if [ -e "/etc/redhat-release" ]; then
os="rhel"
else
os="ubuntu"
# Defining config host
chost='c.vestacp.com'
# Detcing OS
case $(head -n1 /etc/issue |cut -f 1 -d ' ') in
Debian) version="debian" ;;
Ubuntu) version="ubuntu" ;;
*) version="rhel" ;;
esac
# Detecting release
if [ "$version" = 'rhel' ]; then
release=$(grep -o "[0-9]" /etc/redhat-release |head -n1)
fi
if [ "$version" = 'ubuntu' ]; then
release=$(lsb_release -r |awk '{print $2}')
fi
if [ "$version" = 'debian' ]; then
release=$(cat /etc/issue|grep -o [0-9]|head -n1)
fi
# Get new archive
tmpdir=$(mktemp -d --dry-run)
mkdir $tmpdir
cd $tmpdir
wget http://c.vestacp.com/$VERSION/$os/templates.tar.gz -q
if [ "$?" -ne 0 ]; then
echo "Error: can't download template.tar.gz"
log_event "$E_CONNECT" "$EVENT"
rm -rf $tmpdir
exit $E_CONNECT
fi
# Defining download url
vestacp="http://$chost/$version/$release"
# Update templates
# Downloading template archive
cd $(mktemp -d)
wget $vestacp/templates.tar.gz -q
check_result $? "can't download template.tar.gz" $E_CONNECT
# Updating templates
tar -xzpf templates.tar.gz -C $VESTA/data/ templates/web
# Replace includes for apache2.4
if [ "$WEB_SYSTEM" = 'httpd' ] || [ "$WEB_SYSTEM" = 'apache2' ]; then
if [ ! -z "$(/usr/sbin/apachectl -v | grep 'Apache/2.4')" ]; then
sed -i "s/Include /IncludeOptional /g" \
$VESTA/data/templates/web/$WEB_SYSTEM/*tpl
fi
fi
# Rebuild web domains
# Rebuilding web domains
for user in $($BIN/v-list-sys-users plain); do
$BIN/v-rebuild-web-domains $user no
done
@ -61,20 +64,20 @@ done
# Vesta #
#----------------------------------------------------------#
# Restart web server
# Restarting web server
if [ "$restart" != 'no' ]; then
$BIN/v-restart-web
if [ $? -ne 0 ]; then
exit $E_RESTART
check_result $? "restart" >/dev/null 2>&1
if [ ! -z "$PROXY_SYSTTEM" ]; then
$BIN/v-restart-proxy
check_result $? "restart" >/dev/null 2>&1
fi
$BIN/v-restart-proxy
if [ $? -ne 0 ]; then
exit $E_RESTART
if [ ! -z "$WEB_BACKEND" ]; then
$BIN/v-restart-proxy
check_result $? "restart" >/dev/null 2>&1
fi
fi
# Delete tmpdir
rm -rf $tmpdir
exit