Explorar el Código

new web template scheme

Serghey Rodin hace 10 años
padre
commit
bcc02c858d
Se han modificado 1 ficheros con 39 adiciones y 36 borrados
  1. 39 36
      bin/v-update-web-templates

+ 39 - 36
bin/v-update-web-templates

@@ -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"
-fi
+# 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
 
-# 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
+# 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
 
-# Update templates
-tar -xzpf templates.tar.gz -C $VESTA/data/ templates/web
+# Defining download url
+vestacp="http://$chost/$version/$release"
 
-# 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
+# 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
 
-# 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