forked from hestiacp/hestiacp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpostinst
More file actions
64 lines (46 loc) · 1.91 KB
/
Copy pathpostinst
File metadata and controls
64 lines (46 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
# Configure apt to retry downloading on error
if [ ! -f /etc/apt/apt.conf.d/80-retries ]; then
echo "APT::Acquire::Retries \"3\";" > /etc/apt/apt.conf.d/80-retries
fi
# Define version check function
function version_ge(){ test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1" -o ! -z "$1" -a "$1" = "$2"; }
# Get package version
version=$(dpkg -l | awk '$2=="hestia" { print $3 }')
# Define global variables
source /usr/local/hestia/func/main.sh
# Load message variables
source /usr/local/hestia/install/upgrade/messages.sh
# Set backup folder
HESTIA_BACKUP="/root/hst_upgrade_backups/$(date +%d%m%Y%H%M)"
# Initialize backup folders
mkdir -p $HESTIA_BACKUP/conf/
mkdir -p $HESTIA_BACKUP/packages/
mkdir -p $HESTIA_BACKUP/templates/
# Set installation source folder
hestiacp="$HESTIA/install/deb"
# Run triggers only on updates
if [ ! -e "/usr/local/hestia/data/users/admin" ]; then
exit
fi
# Clear the screen from apt output to prepare for upgrade installer experience
clear
welcome_message
# Load hestia.conf
source /usr/local/hestia/conf/hestia.conf
# Perform necessary upgrade steps
source /usr/local/hestia/install/upgrade/version.sh
# Upgrade phpMyAdmin if applicable
if [ "$DB_SYSTEM" = 'mysql' ]; then
source /usr/local/hestia/install/upgrade/phpmyadmin.sh
fi
# Set new version
sed -i "/VERSION/d" $HESTIA/conf/hestia.conf
echo "VERSION='$version'" >> $HESTIA/conf/hestia.conf
# Add upgrade notification to admin user's panel
$HESTIA/bin/v-add-user-notification admin 'Upgrade complete' 'Your server has been updated to Hestia Control Panel version '$version'.<br>Please report any bugs on GitHub at<br><a href="https://github.com/hestiacp/hestiacp/Issues" target="_new">https://github.com/hestiacp/hestiacp/Issues</a><br><br>Have a great day!'
# Restart services for changes to take full effect
source /usr/local/hestia/install/upgrade/restart.sh
# Display completion message
upgrade_complete
exit 0