Skip to content

Commit e018474

Browse files
committed
Implement a better upgrade script handling.
1 parent c6c96c2 commit e018474

File tree

2 files changed

+25
-58
lines changed

2 files changed

+25
-58
lines changed

src/deb/hestia/postinst

Lines changed: 8 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -5,70 +5,20 @@ if [ ! -e "/usr/local/hestia/data/users/admin" ]; then
55
exit
66
fi
77

8-
# Upgrade routines go here
9-
108
# Load hestia.conf
119
source /usr/local/hestia/conf/hestia.conf
1210

13-
# Set version(s)
14-
pma_v='4.8.5'
15-
16-
# Upgrade phpMyAdmin
17-
if [ "$DB_SYSTEM" = 'mysql' ]; then
18-
# Display upgrade information
19-
echo "Upgrade phpMyAdmin to v$pma_v..."
20-
21-
# Download latest phpMyAdmin release
22-
wget --quiet https://files.phpmyadmin.net/phpMyAdmin/$pma_v/phpMyAdmin-$pma_v-all-languages.tar.gz
23-
24-
# Unpack files
25-
tar xzf phpMyAdmin-$pma_v-all-languages.tar.gz
26-
27-
# Delete file to prevent error
28-
rm -fr /usr/share/phpmyadmin/doc/html
29-
30-
# Overwrite old files
31-
cp -rf phpMyAdmin-$pma_v-all-languages/* /usr/share/phpmyadmin
32-
33-
# Set config and log directory
34-
sed -i "s|define('CONFIG_DIR', '');|define('CONFIG_DIR', '/etc/phpmyadmin/');|" /usr/share/phpmyadmin/libraries/vendor_config.php
35-
sed -i "s|define('TEMP_DIR', './tmp/');|define('TEMP_DIR', '/var/lib/phpmyadmin/tmp/');|" /usr/share/phpmyadmin/libraries/vendor_config.php
36-
37-
# Create temporary folder and change permissions
38-
if [ ! -d /usr/share/phpmyadmin/tmp ]; then
39-
mkdir /usr/share/phpmyadmin/tmp
40-
chmod 777 /usr/share/phpmyadmin/tmp
41-
fi
11+
# Get hestia version
12+
version=$(dpkg -l | awk '$2=="hestia" { print $3 }')
4213

43-
# Clean up
44-
rm -fr phpMyAdmin-$pma_v-all-languages
45-
rm -f phpMyAdmin-$pma_v-all-languages.tar.gz
14+
# Check if upgrade routine exists for target version
15+
if [ -f "/usr/local/hestia/install/upgrade/$version.sh" ]; then
16+
source /usr/local/hestia/install/upgrade/$version.sh
4617
fi
4718

48-
# Add amd64 to repositories to prevent notifications - https://goo.gl/hmsSV7
49-
if ! grep -q 'arch=amd64' /etc/apt/sources.list.d/nginx.list; then
50-
sed -i s/"deb "/"deb [arch=amd64] "/g /etc/apt/sources.list.d/nginx.list
19+
# Set new hestia version in conf file
20+
if [ "$VERSION" != "$version" ]; then
21+
sed -I "s/VERSION='$VERSION'/VERSION='$version'/" /usr/local/hestia/conf/hestia.conf
5122
fi
52-
if ! grep -q 'arch=amd64' /etc/apt/sources.list.d/mariadb.list; then
53-
sed -i s/"deb "/"deb [arch=amd64] "/g /etc/apt/sources.list.d/mariadb.list
54-
fi
55-
56-
# Fix named rule for AppArmor - https://goo.gl/SPqHdq
57-
if [ "$DNS_SYSTEM" = 'bind9' ] && [ ! -f /etc/apparmor.d/local/usr.sbin.named ]; then
58-
echo "/home/** rwm," >> /etc/apparmor.d/local/usr.sbin.named 2> /dev/null
59-
fi
60-
61-
# Remove obsolete ports.conf if exists.
62-
if [ -f /usr/local/hestia/data/firewall/ports.conf ]; then
63-
rm -f /usr/local/hestia/data/firewall/ports.conf
64-
fi
65-
66-
# Reset backend port
67-
if [ ! -z "$BACKEND_PORT" ]; then
68-
/usr/local/hestia/bin/v-change-sys-port $BACKEND_PORT
69-
fi
70-
71-
# Copy default "Success" page for unassigned hosts
72-
cp -rf $hestiacp/templates/web/unassigned/* /var/www/
7323

7424
exit 0

src/deb/hestia/preinst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
# Run triggers only on updates
4+
if [ ! -e "/usr/local/hestia/data/users/admin" ]; then
5+
exit
6+
fi
7+
8+
# Load hestia.conf
9+
source /usr/local/hestia/conf/hestia.conf
10+
11+
# Get hestia version
12+
version=$(dpkg -l | awk '$2=="hestia" { print $3 }')
13+
14+
# Set hestia version if different.
15+
if [ "$VERSION" != "$version" ]; then
16+
sed -I "s/VERSION='$VERSION'/VERSION='$version'/" /usr/local/hestia/conf/hestia.conf
17+
fi

0 commit comments

Comments
 (0)