forked from hestiacp/hestiacp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path0.9.8-29.sh
More file actions
192 lines (163 loc) · 6.91 KB
/
Copy path0.9.8-29.sh
File metadata and controls
192 lines (163 loc) · 6.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
#!/bin/bash
# define vars
HESTIA="/usr/local/hestia"
HESTIA_BACKUP="/root/hst_upgrade/$(date +%d%m%Y%H%M)"
hestiacp="$HESTIA/install/deb"
# load hestia.conf
source $HESTIA/conf/hestia.conf
# load hestia main functions
source /usr/local/hestia/func/main.sh
# Initialize backup directory
mkdir -p $HESTIA_BACKUP/templates/
mkdir -p $HESTIA_BACKUP/packages/
echo "(*) Upgrading to Hestia Control Panel v$VERSION..."
# Generating dhparam.
if [ ! -e /etc/ssl/dhparam.pem ]; then
echo "(*) Enabling HTTPS Strict Transport Security (HSTS) support"
# Backup existing conf
mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak
# Copy new nginx config
cp -f $hestiacp/nginx/nginx.conf /etc/nginx/
# Copy dhparam
cp -f $hestiacp/ssl/dhparam.pem /etc/ssl/
# Update dns servers in nginx.conf
dns_resolver=$(cat /etc/resolv.conf | grep -i '^nameserver' | cut -d ' ' -f2 | tr '\r\n' ' ' | xargs)
sed -i "s/1.0.0.1 1.1.1.1/$dns_resolver/g" /etc/nginx/nginx.conf
# Restart nginx service
service nginx restart >/dev/null 2>&1
fi
# Update default page templates
echo "(*) Replacing default templates and packages..."
echo " Existing templates have been backed up to the following location:"
echo " $HESTIA_BACKUP/templates/"
# Back up default package and install latest version
if [ -d $HESTIA/data/packages/ ]; then
cp -f $HESTIA/data/packages/default.pkg $HESTIA_BACKUP/packages/
fi
# Back up old template files and install the latest versions
if [ -d $HESTIA/data/templates/ ]; then
cp -rf $HESTIA/data/templates $HESTIA_BACKUP/
$HESTIA/bin/v-update-web-templates
$HESTIA/bin/v-update-dns-templates
fi
# Remove old Office 365 template as there is a newer version with an updated name
if [ -f $HESTIA/data/templates/dns/o365.tpl ]; then
rm -f $HESTIA/data/templates/dns/o365.tpl
fi
# Back up and remove default index.html if it exists
if [ -f /var/www/html/index.html ]; then
cp -rf /var/www/html/index.html $HESTIA_BACKUP/templates/
rm -rf /var/www/html/index.html
fi
# Configure default success page and set permissions on CSS, JavaScript, and Font dependencies for unassigned hosts
if [ ! -d /var/www/html ]; then
mkdir -p /var/www/html/
fi
if [ ! -d /var/www/document_errors/ ]; then
mkdir -p /var/www/document_errors/
fi
cp -rf $HESTIA/install/deb/templates/web/unassigned/* /var/www/html/
cp -rf $HESTIA/install/deb/templates/web/skel/document_errors/* /var/www/document_errors/
chmod 644 /var/www/html/*
chmod 751 /var/www/html/css
chmod 751 /var/www/html/js
chmod 751 /var/www/html/webfonts
chmod 644 /var/www/document_errors/*
chmod 751 /var/www/document_errors/css
chmod 751 /var/www/document_errors/js
chmod 751 /var/www/document_errors/webfonts
# Correct permissions on CSS, JavaScript, and Font dependencies for default templates
chmod 751 $HESTIA/data/templates/web/skel/document_errors/css
chmod 751 $HESTIA/data/templates/web/skel/document_errors/js
chmod 751 $HESTIA/data/templates/web/skel/document_errors/webfonts
chmod 751 $HESTIA/data/templates/web/skel/public_*html/css
chmod 751 $HESTIA/data/templates/web/skel/public_*html/js
chmod 751 $HESTIA/data/templates/web/skel/public_*html/webfonts
chmod 751 $HESTIA/data/templates/web/suspend/css
chmod 751 $HESTIA/data/templates/web/suspend/js
chmod 751 $HESTIA/data/templates/web/suspend/webfonts
chmod 751 $HESTIA/data/templates/web/unassigned/css
chmod 751 $HESTIA/data/templates/web/unassigned/js
chmod 751 $HESTIA/data/templates/web/unassigned/webfonts
# Add unassigned hosts configuration to nginx and apache2
if [ "$WEB_SYSTEM" = "apache2" ]; then
echo "(*) Adding unassigned hosts configuration to apache2..."
if [ -f /usr/local/hestia/data/ips/* ]; then
for ip in /usr/local/hestia/data/ips/*; do
ipaddr=${ip##*/}
rm -f /etc/apache2/conf.d/$ip.conf
cp -f $HESTIA/install/deb/apache2/unassigned.conf /etc/apache2/conf.d/$ipaddr.conf
sed -i 's/directIP/'$ipaddr'/g' /etc/apache2/conf.d/$ipaddr.conf
done
fi
fi
if [ "$PROXY_SYSTEM" = "nginx" ]; then
echo "(*) Adding unassigned hosts configuration to nginx..."
if [ -f /usr/local/hestia/data/ips/* ]; then
for ip in /usr/local/hestia/data/ips/*; do
ipaddr=${ip##*/}
rm -f /etc/nginx/conf.d/$ip.conf
cp -f $HESTIA/install/deb/nginx/unassigned.inc /etc/nginx/conf.d/$ipaddr.conf
sed -i 's/directIP/'$ipaddr'/g' /etc/nginx/conf.d/$ipaddr.conf
done
fi
fi
# Fix empty pool error message for multiphp
php_versions=$( ls -l /etc/php/ | grep ^d | wc -l )
if [ "$php_versions" -gt 1 ]; then
for v in $(ls /etc/php/); do
cp -f $hestiacp/php-fpm/dummy.conf /etc/php/$d/fpm/pool.d/
v=$(echo "$v" | sed -e 's/[.]//')
sed -i "/s/9999/9999$v/g" /etc/php/$v/fpm/pool.d/dummy.conf
done
fi
# Set Purge to false in roundcube config - https://goo.gl/3Nja3u
echo "(*) Updating Roundcube configuration..."
if [ -f /etc/roundcube/config.inc.php ]; then
sed -i "s/\['flag_for_deletion'] = 'Purge';/\['flag_for_deletion'] = false;/gI" /etc/roundcube/config.inc.php
fi
if [ -f /etc/roundcube/defaults.inc.php ]; then
sed -i "s/\['flag_for_deletion'] = 'Purge';/\['flag_for_deletion'] = false;/gI" /etc/roundcube/defaults.inc.php
fi
if [ -f /etc/roundcube/main.inc.php ]; then
sed -i "s/\['flag_for_deletion'] = 'Purge';/\['flag_for_deletion'] = false;/gI" /etc/roundcube/main.inc.php
fi
# Remove old OS-specific installation files if they exist to free up space
if [ -d $HESTIA/install/ubuntu ]; then
echo "(*) Removing old installation data files for Ubuntu..."
rm -rf $HESTIA/install/ubuntu
fi
if [ -d $HESTIA/install/debian ]; then
echo "(*) Removing old installation data files for Debian..."
rm -rf $HESTIA/install/debian
fi
# Fix dovecot configuration
echo "(*) Updating dovecot IMAP/POP server configuration..."
if [ -f /etc/dovecot/conf.d/15-mailboxes.conf ]; then
# Remove mailboxes configuration if it exists
rm -f /etc/dovecot/conf.d/15-mailboxes.conf
fi
if [ -f /etc/dovecot/dovecot.conf ]; then
# Update dovecot configuration and restart dovecot service
cp -f $HESTIA/install/deb/dovecot/dovecot.conf /etc/dovecot/dovecot.conf
systemctl restart dovecot
sleep 0.5
fi
# Add IMAP system variable to configuration if dovecot is installed
if [ -z "$IMAP_SYSTEM" ]; then
if [ -f /usr/bin/dovecot ]; then
echo "(*) Adding missing IMAP_SYSTEM variable to hestia.conf..."
echo "IMAP_SYSTEM = 'dovecot'" >> $HESTIA/conf/hestia.conf
fi
fi
# Rebuild mailboxes
for user in `ls /usr/local/hestia/data/users/`; do
echo "(*) Rebuilding mail domains for user: $user..."
v-rebuild-mail-domains $user
done
# Remove Webalizer and replace it with awstats as default
echo "(*) Setting awstats as default web statistics backend..."
apt purge webalizer -y > /dev/null 2>&1
sed -i "s/STATS_SYSTEM='webalizer,awstats'/STATS_SYSTEM='awstats'/g" $HESTIA/conf/hestia.conf
# Run sftp jail once
$HESTIA/bin/v-add-sys-sftp-jail