Просмотр исходного кода

Implement a better upgrade script handling.

Raphael Schneeberger 7 лет назад
Родитель
Сommit
e0184743b1
2 измененных файлов с 25 добавлено и 58 удалено
  1. 8 58
      src/deb/hestia/postinst
  2. 17 0
      src/deb/hestia/preinst

+ 8 - 58
src/deb/hestia/postinst

@@ -5,70 +5,20 @@ if [ ! -e "/usr/local/hestia/data/users/admin" ]; then
     exit
 fi
 
-# Upgrade routines go here
-
 # Load hestia.conf
 source /usr/local/hestia/conf/hestia.conf
 
-# Set version(s)
-pma_v='4.8.5'
-
-# Upgrade phpMyAdmin
-if [ "$DB_SYSTEM" = 'mysql' ]; then
-    # Display upgrade information
-    echo "Upgrade phpMyAdmin to v$pma_v..."
-
-    # Download latest phpMyAdmin release
-    wget --quiet https://files.phpmyadmin.net/phpMyAdmin/$pma_v/phpMyAdmin-$pma_v-all-languages.tar.gz
-
-    # Unpack files
-    tar xzf phpMyAdmin-$pma_v-all-languages.tar.gz
-
-    # Delete file to prevent error
-    rm -fr /usr/share/phpmyadmin/doc/html
-
-    # Overwrite old files
-    cp -rf phpMyAdmin-$pma_v-all-languages/* /usr/share/phpmyadmin
-
-    # Set config and log directory
-    sed -i "s|define('CONFIG_DIR', '');|define('CONFIG_DIR', '/etc/phpmyadmin/');|" /usr/share/phpmyadmin/libraries/vendor_config.php
-    sed -i "s|define('TEMP_DIR', './tmp/');|define('TEMP_DIR', '/var/lib/phpmyadmin/tmp/');|" /usr/share/phpmyadmin/libraries/vendor_config.php
-
-    # Create temporary folder and change permissions
-    if [ ! -d /usr/share/phpmyadmin/tmp ]; then
-        mkdir /usr/share/phpmyadmin/tmp
-        chmod 777 /usr/share/phpmyadmin/tmp
-    fi
+# Get hestia version
+version=$(dpkg -l | awk '$2=="hestia" { print $3 }')
 
-    # Clean up
-    rm -fr phpMyAdmin-$pma_v-all-languages
-    rm -f phpMyAdmin-$pma_v-all-languages.tar.gz
+# Check if upgrade routine exists for target version
+if [ -f "/usr/local/hestia/install/upgrade/$version.sh" ]; then
+    source /usr/local/hestia/install/upgrade/$version.sh
 fi
 
-# Add amd64 to repositories to prevent notifications - https://goo.gl/hmsSV7
-if ! grep -q 'arch=amd64' /etc/apt/sources.list.d/nginx.list; then
-    sed -i s/"deb "/"deb [arch=amd64] "/g /etc/apt/sources.list.d/nginx.list
+# Set new hestia version in conf file
+if [ "$VERSION" != "$version" ]; then
+    sed -I "s/VERSION='$VERSION'/VERSION='$version'/" /usr/local/hestia/conf/hestia.conf
 fi
-if ! grep -q 'arch=amd64' /etc/apt/sources.list.d/mariadb.list; then
-    sed -i s/"deb "/"deb [arch=amd64] "/g /etc/apt/sources.list.d/mariadb.list
-fi
-
-# Fix named rule for AppArmor - https://goo.gl/SPqHdq
-if [ "$DNS_SYSTEM" = 'bind9' ] && [ ! -f /etc/apparmor.d/local/usr.sbin.named ]; then
-        echo "/home/** rwm," >> /etc/apparmor.d/local/usr.sbin.named 2> /dev/null
-fi
-
-# Remove obsolete ports.conf if exists.
-if [ -f /usr/local/hestia/data/firewall/ports.conf ]; then
-    rm -f /usr/local/hestia/data/firewall/ports.conf
-fi
-
-# Reset backend port
-if [ ! -z "$BACKEND_PORT" ]; then
-    /usr/local/hestia/bin/v-change-sys-port $BACKEND_PORT
-fi
-
-# Copy default "Success" page for unassigned hosts
-cp -rf $hestiacp/templates/web/unassigned/* /var/www/
 
 exit 0

+ 17 - 0
src/deb/hestia/preinst

@@ -0,0 +1,17 @@
+#!/bin/bash
+
+# Run triggers only on updates
+if [ ! -e "/usr/local/hestia/data/users/admin" ]; then
+    exit
+fi
+
+# Load hestia.conf
+source /usr/local/hestia/conf/hestia.conf
+
+# Get hestia version
+version=$(dpkg -l | awk '$2=="hestia" { print $3 }')
+
+# Set hestia version if different.
+if [ "$VERSION" != "$version" ]; then
+    sed -I "s/VERSION='$VERSION'/VERSION='$version'/" /usr/local/hestia/conf/hestia.conf
+fi