Browse Source

Rewrite template update scripts to copy from dep package as source.

Raphael Schneeberger 7 years ago
parent
commit
2dd18db7b5
2 changed files with 38 additions and 37 deletions
  1. 19 13
      bin/v-update-dns-templates
  2. 19 24
      bin/v-update-web-templates

+ 19 - 13
bin/v-update-dns-templates

@@ -16,25 +16,31 @@ restart=$1
 source $HESTIA/func/main.sh
 source $HESTIA/conf/hestia.conf
 
+# Detect OS
+case $(head -n1 /etc/issue | cut -f 1 -d ' ') in
+    Debian)     type="debian" ;;
+    Ubuntu)     type="ubuntu" ;;
+    *)          type="NoSupport" ;;
+esac
+
+# Detect version
+if [ "$type" = "ubuntu" ]; then
+    release="$(lsb_release -s -r)"
+elif [ "$type" = "ubuntu" ]; then
+    release=$(cat /etc/debian_version|grep -o [0-9]|head -n1)
+else
+    echo "Error: can't detect supported os"
+    log_event "$E_NOTEXIST"
+    exit $E_NOTEXIST
+fi
+
 
 #----------------------------------------------------------#
 #                       Action                             #
 #----------------------------------------------------------#
 
-# Get new archive
-tmpdir=$(mktemp -d --dry-run)
-mkdir $tmpdir
-cd $tmpdir
-wget http://c.hestiacp.com/rhel/7/templates.tar.gz -q
-if [ "$?" -ne 0 ]; then
-    echo "Error: can't download template.tar.gz"
-    log_event "$E_CONNECT" "$ARGUMENTS"
-    rm -rf $tmpdir
-    exit $E_CONNECT
-fi
-
 # Update templates
-tar -xzpf templates.tar.gz -C $HESTIA/data/ templates/dns
+cp -rf $HESTIA/install/$type/$release/templates/dns $HESTIA/data/templates/
 
 
 #----------------------------------------------------------#

+ 19 - 24
bin/v-update-web-templates

@@ -16,36 +16,31 @@ restart=$1
 source $HESTIA/func/main.sh
 source $HESTIA/conf/hestia.conf
 
-
-#----------------------------------------------------------#
-#                       Action                             #
-#----------------------------------------------------------#
-
-# Detcing OS
-case $(head -n1 /etc/issue |cut -f 1 -d ' ') in
-    Debian)     version="debian" ;;
-    Ubuntu)     version="ubuntu" ;;
-    *)          version="NotSupported" ;;
+# Detect OS
+case $(head -n1 /etc/issue | cut -f 1 -d ' ') in
+    Debian)     type="debian" ;;
+    Ubuntu)     type="ubuntu" ;;
+    *)          type="NoSupport" ;;
 esac
 
-# Detecting release
-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
-if [ "$version" = 'NotSupported' ]; then
-    echo "No Supported OS Version found, abort."
-    exit 1
+# Detect version
+if [ "$type" = "ubuntu" ]; then
+    release="$(lsb_release -s -r)"
+elif [ "$type" = "ubuntu" ]; then
+    release=$(cat /etc/debian_version|grep -o [0-9]|head -n1)
+else
+    echo "Error: can't detect supported os"
+    log_event "$E_NOTEXIST"
+    exit $E_NOTEXIST
 fi
 
-# Defining template path
-hestiacp="$HESTIA/install/$version/$release"
 
-# Updating templates
-cp -rf $hestiacp/templates/web $HESTIA/data/templates/
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
 
+# Update templates
+cp -rf $HESTIA/install/$type/$release/templates/web $HESTIA/data/templates/
 
 # Rebuilding web domains
 for user in $($BIN/v-list-sys-users plain); do