Skip to content

Commit 6e2ac7a

Browse files
authored
Improve upgrade procedure (hestiacp#2198)
* Improve upgrade procedure 1. Allow setting task on version Use upgrade_config_set_value Setting flag 2. Check version has changed instead of flag on dependencies * Improve config var exsits * Create /var/log/hestia/backup.log + chmod /backup/user.log
1 parent 9e33798 commit 6e2ac7a

File tree

8 files changed

+186
-156
lines changed

8 files changed

+186
-156
lines changed

bin/v-add-sys-filemanager

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ fi
105105
# Add configuration file
106106
cp -f $HESTIA_INSTALL_DIR/filemanager/filegator/configuration.php $HESTIA/web/fm/configuration.php
107107

108-
108+
echo "$fm_v" > "${FM_INSTALL_DIR}/version"
109109
# Set permissions
110110
chown root: -R "${FM_INSTALL_DIR}"
111111
chown $user: "${FM_INSTALL_DIR}/private"

bin/v-backup-user

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,7 @@ echo "$backup_str" >> $USER_DATA/backup.conf
770770
tail -n $BACKUPS $USER_DATA/backup.conf > $USER_DATA/backup.conf_
771771
mv -f $USER_DATA/backup.conf_ $USER_DATA/backup.conf
772772
chmod 660 $USER_DATA/backup.conf
773+
chmod 660 $BACKUP/$user.log
773774

774775
# Deleting task from queue
775776
sed -i "/v-backup-user $user /d" $HESTIA/data/queue/backup.pipe
@@ -783,10 +784,11 @@ if [ -e "$BACKUP/$user.log" ] && [ "$notify" = "yes" ]; then
783784
subj="$user → backup has been completed"
784785
email=$(get_user_value '$CONTACT')
785786
cat $BACKUP/$user.log |$SENDMAIL -s "$subj" "$email" "$notify"
786-
rm $BACKUP/$user.log
787787
$BIN/v-add-user-notification "$user" "Backup created successfully" "<b>Archive:</b> $user.$backup_new_date.tar"
788788
fi
789789

790+
791+
790792
# Logging
791793
$BIN/v-log-action "$user" "Info" "Backup" "Backup created (Archive: $backup_new_date.tar)."
792794
$BIN/v-log-action "system" "Info" "Backup" "Backup created (User: $user, Archive: $backup_new_date.tar)."

func/syshealth.sh

Lines changed: 59 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -171,18 +171,21 @@ function syshealth_restore_system_config() {
171171
fi
172172
}
173173

174+
function check_key_exsits() {
175+
grep -e "^$1=" $HESTIA/conf/hestia.conf
176+
}
177+
174178
# Repair System Configuration
175179
# Adds missing variables to $HESTIA/conf/hestia.conf with safe default values
176180
function syshealth_repair_system_config() {
177181
# Release branch
178-
if [ -z "$RELEASE_BRANCH" ]; then
182+
if [[ -z $(check_key_exsits 'RELEASE_BRANCH') ]]; then
179183
echo "[ ! ] Adding missing variable to hestia.conf: RELEASE_BRANCH ('release')"
180184
$BIN/v-change-sys-config-value 'RELEASE_BRANCH' 'release'
181185
fi
182-
183186
# Webmail alias
184187
if [ -n "$IMAP_SYSTEM" ]; then
185-
if [ -z "$WEBMAIL_ALIAS" ]; then
188+
if [[ -z $(check_key_exsits 'WEBMAIL_ALIAS') ]]; then
186189
echo "[ ! ] Adding missing variable to hestia.conf: WEBMAIL_ALIAS ('webmail')"
187190
$BIN/v-change-sys-config-value 'WEBMAIL_ALIAS' 'webmail'
188191
fi
@@ -191,88 +194,88 @@ function syshealth_repair_system_config() {
191194
# phpMyAdmin/phpPgAdmin alias
192195
if [ -n "$DB_SYSTEM" ]; then
193196
if [ "$DB_SYSTEM" = "mysql" ]; then
194-
if [ -z "$DB_PMA_ALIAS" ]; then
197+
if [[ -z $(check_key_exsits 'DB_PMA_ALIAS') ]]; then
195198
echo "[ ! ] Adding missing variable to hestia.conf: DB_PMA_ALIAS ('phpmyadmin)"
196199
$BIN/v-change-sys-config-value 'DB_PMA_ALIAS' 'phpmyadmin'
197200
fi
198201
fi
199202
if [ "$DB_SYSTEM" = "pgsql" ]; then
200-
if [ -z "$DB_PGA_ALIAS" ]; then
203+
if [[ -z $(check_key_exsits 'DB_PGA_ALIAS') ]]; then
201204
echo "[ ! ] Adding missing variable to hestia.conf: DB_PGA_ALIAS ('phppgadmin')"
202205
$BIN/v-change-sys-config-value 'DB_PGA_ALIAS' 'phppgadmin'
203206
fi
204207
fi
205208
fi
206209

207210
# Backup compression level
208-
if [ -z "$BACKUP_GZIP" ]; then
211+
if [[ -z $(check_key_exsits 'BACKUP_GZIP') ]]; then
209212
echo "[ ! ] Adding missing variable to hestia.conf: BACKUP_GZIP ('4')"
210213
$BIN/v-change-sys-config-value 'BACKUP_GZIP' '4'
211214
fi
212215

213216
# Theme
214-
if [ -z "$THEME" ]; then
217+
if [[ -z $(check_key_exsits 'THEME') ]]; then
215218
echo "[ ! ] Adding missing variable to hestia.conf: THEME ('dark')"
216219
$BIN/v-change-sys-config-value 'THEME' 'dark'
217220
fi
218221

219222
# Default language
220-
if [ -z "$LANGUAGE" ]; then
223+
if [[ -z $(check_key_exsits 'LANGUAGE') ]]; then
221224
echo "[ ! ] Adding missing variable to hestia.conf: LANGUAGE ('en')"
222-
$BIN/v-change-sys-language 'en'
225+
$BIN/v-change-sys-language 'LANGUAGE' 'en'
223226
fi
224227

225228
# Disk Quota
226-
if [ -z "$DISK_QUOTA" ]; then
229+
if [[ -z $(check_key_exsits 'DISK_QUOTA') ]]; then
227230
echo "[ ! ] Adding missing variable to hestia.conf: DISK_QUOTA ('no')"
228231
$BIN/v-change-sys-config-value 'DISK_QUOTA' 'no'
229232
fi
230233

231234
# CRON daemon
232-
if [ -z "$CRON_SYSTEM" ]; then
235+
if [[ -z $(check_key_exsits 'CRON_SYSTEM') ]]; then
233236
echo "[ ! ] Adding missing variable to hestia.conf: CRON_SYSTEM ('cron')"
234237
$BIN/v-change-sys-config-value 'CRON_SYSTEM' 'cron'
235238
fi
236239

237240
# Backend port
238-
if [ -z "$BACKEND_PORT" ]; then
241+
if [[ -z $(check_key_exsits 'BACKEND_PORT') ]]; then
239242
ORIGINAL_PORT=$(cat $HESTIA/nginx/conf/nginx.conf | grep "listen" | sed 's/[^0-9]*//g')
240243
echo "[ ! ] Adding missing variable to hestia.conf: BACKEND_PORT ('$ORIGINAL_PORT')"
241244
$HESTIA/bin/v-change-sys-config-value 'BACKEND_PORT' $PORT
242245
fi
243246

244247
# Upgrade: Send email notification
245-
if [ -z "$UPGRADE_SEND_EMAIL" ]; then
248+
if [[ -z $(check_key_exsits 'UPGRADE_SEND_EMAIL') ]]; then
246249
echo "[ ! ] Adding missing variable to hestia.conf: UPGRADE_SEND_EMAIL ('true')"
247250
$BIN/v-change-sys-config-value 'UPGRADE_SEND_EMAIL' 'true'
248251
fi
249252

250253
# Upgrade: Send email notification
251-
if [ -z "$UPGRADE_SEND_EMAIL_LOG" ]; then
254+
if [[ -z $(check_key_exsits 'UPGRADE_SEND_EMAIL_LOG') ]]; then
252255
echo "[ ! ] Adding missing variable to hestia.conf: UPGRADE_SEND_EMAIL_LOG ('false')"
253256
$BIN/v-change-sys-config-value 'UPGRADE_SEND_EMAIL_LOG' 'false'
254257
fi
255258

256259
# File Manager
257-
if [ -z "$FILE_MANAGER" ]; then
260+
if [[ -z $(check_key_exsits 'FILE_MANAGER') ]]; then
258261
echo "[ ! ] Adding missing variable to hestia.conf: FILE_MANAGER ('true')"
259262
$BIN/v-add-sys-filemanager quiet
260263
fi
261264

262265
# Support for ZSTD / GZIP Change
263-
if [ -z "$BACKUP_MODE" ]; then
266+
if [[ -z $(check_key_exsits 'BACKUP_MODE') ]]; then
264267
echo "[ ! ] Setting zstd backup compression type as default..."
265268
$BIN/v-change-sys-config-value "BACKUP_MODE" "zstd"
266269
fi
267270

268271
# Login style switcher
269-
if [ -z "$LOGIN_STYLE" ]; then
272+
if [[ -z $(check_key_exsits 'LOGIN_STYLE') ]]; then
270273
echo "[ ! ] Adding missing variable to hestia.conf: LOGIN_STYLE ('default')"
271274
$BIN/v-change-sys-config-value "LOGIN_STYLE" "default"
272275
fi
273276

274277
# Webmail clients
275-
if [ -z "$WEBMAIL_SYSTEM" ]; then
278+
if [[ -z $(check_key_exsits 'WEBMAIL_SYSTEM') ]]; then
276279
if [ -d "/var/lib/roundcube" ]; then
277280
echo "[ ! ] Adding missing variable to hestia.conf: WEBMAIL_SYSTEM ('roundcube')"
278281
$BIN/v-change-sys-config-value "WEBMAIL_SYSTEM" "roundcube"
@@ -283,139 +286,145 @@ function syshealth_repair_system_config() {
283286
fi
284287

285288
# Inactive session timeout
286-
if [ -z "$INACTIVE_SESSION_TIMEOUT" ]; then
289+
if [[ -z $(check_key_exsits 'INACTIVE_SESSION_TIMEOUT') ]]; then
287290
echo "[ ! ] Adding missing variable to hestia.conf: INACTIVE_SESSION_TIMEOUT ('60')"
288291
$BIN/v-change-sys-config-value "INACTIVE_SESSION_TIMEOUT" "60"
289292
fi
290293

291294
# Enforce subdomain ownership
292-
if [ -z "$ENFORCE_SUBDOMAIN_OWNERSHIP" ]; then
295+
if [[ -z $(check_key_exsits 'ENFORCE_SUBDOMAIN_OWNERSHIP') ]]; then
293296
echo "[ ! ] Adding missing variable to hestia.conf: ENFORCE_SUBDOMAIN_OWNERSHIP ('no')"
294297
$BIN/v-change-sys-config-value "ENFORCE_SUBDOMAIN_OWNERSHIP" "no"
295298
fi
296-
299+
300+
if [[ -z $(check_key_exsits 'API') ]]; then
301+
echo "[ ! ] Adding missing variable to hestia.conf: API ('no')"
302+
$BIN/v-change-sys-config-value "API" "no"
303+
fi
304+
297305
# API access allowed IP's
298306
if [ "$API" = "yes" ]; then
299307
check_api_key=$(grep "API_ALLOWED_IP" $HESTIA/conf/hestia.conf)
300308
if [ -z "$check_api_key" ]; then
301-
if [ -z "$API_ALLOWED_IP" ]; then
309+
if [[ -z $(check_key_exsits 'API_ALLOWED_IP') ]]; then
302310
echo "[ ! ] Adding missing variable to hestia.conf: API_ALLOWED_IP ('allow-all')"
303311
$BIN/v-change-sys-config-value "API_ALLOWED_IP" "allow-all"
304312
fi
305313
fi
306314
fi
307315

308316
# Enforce subdomain ownership
309-
if [ -z "$ENFORCE_SUBDOMAIN_OWNERSHIP" ]; then
317+
if [[ -z $(check_key_exsits 'ENFORCE_SUBDOMAIN_OWNERSHIP') ]]; then
310318
echo "[ ! ] Adding missing variable to hestia.conf: ENFORCE_SUBDOMAIN_OWNERSHIP ('yes')"
311319
$BIN/v-change-sys-config-value "ENFORCE_SUBDOMAIN_OWNERSHIP" "yes"
312320
fi
313321
# Debug mode
314-
if [ -z "$DEBUG_MODE" ]; then
322+
if [[ -z $(check_key_exsits 'DEBUG_MODE') ]]; then
315323
echo "[ ! ] Adding missing variable to hestia.conf: DEBUG_MODE ('false')"
316324
$BIN/v-change-sys-config-value "DEBUG_MODE" "false"
317325
fi
318326
# Quick install plugin
319-
if [ -z "$PLUGIN_APP_INSTALLER" ]; then
327+
if [[ -z $(check_key_exsits 'PLUGIN_APP_INSTALLER') ]]; then
320328
echo "[ ! ] Adding missing variable to hestia.conf: PLUGIN_APP_INSTALLER ('true')"
321329
$BIN/v-change-sys-config-value "PLUGIN_APP_INSTALLER" "true"
322330
fi
323331
# Enable preview mode
324-
if [ -z "$POLICY_SYSTEM_ENABLE_BACON" ]; then
332+
if [[ -z $(check_key_exsits 'POLICY_SYSTEM_ENABLE_BACON') ]]; then
325333
echo "[ ! ] Adding missing variable to hestia.conf: POLICY_SYSTEM_ENABLE_BACON ('false')"
326334
$BIN/v-change-sys-config-value "POLICY_SYSTEM_ENABLE_BACON" "false"
327335
fi
328336
# Hide system services
329-
if [ -z "$POLICY_SYSTEM_HIDE_SERVICES" ]; then
337+
if [[ -z $(check_key_exsits 'POLICY_SYSTEM_HIDE_SERVICES') ]]; then
330338
echo "[ ! ] Adding missing variable to hestia.conf: POLICY_SYSTEM_HIDE_SERVICES ('no')"
331339
$BIN/v-change-sys-config-value "POLICY_SYSTEM_HIDE_SERVICES" "no"
332340
fi
333341
# Password reset
334-
if [ -z "$POLICY_SYSTEM_PASSWORD_RESET" ]; then
342+
if [[ -z $(check_key_exsits 'POLICY_SYSTEM_PASSWORD_RESET') ]]; then
335343
echo "[ ! ] Adding missing variable to hestia.conf: POLICY_SYSTEM_PASSWORD_RESET ('no')"
336344
$BIN/v-change-sys-config-value "POLICY_SYSTEM_PASSWORD_RESET" "no"
337345
fi
338-
# Protect admin user
339-
if [ -z "$POLICY_SYSTEM_PROTECTED_ADMIN" ]; then
340-
echo "[ ! ] Adding missing variable to hestia.conf: POLICY_SYSTEM_PROTECTED_ADMIN ('no')"
341-
$BIN/v-change-sys-config-value "POLICY_SYSTEM_PROTECTED_ADMIN" "no"
342-
fi
346+
343347
# Theme editor
344-
if [ -z "$POLICY_USER_CHANGE_THEME" ]; then
348+
if [[ -z $(check_key_exsits 'POLICY_USER_CHANGE_THEME') ]]; then
345349
echo "[ ! ] Adding missing variable to hestia.conf: POLICY_USER_CHANGE_THEME ('yes')"
346350
$BIN/v-change-sys-config-value "POLICY_USER_CHANGE_THEME" "true"
347351
fi
352+
# Protect admin user
353+
if [[ -z $(check_key_exsits 'POLICY_SYSTEM_PROTECTED_ADMIN') ]]; then
354+
echo "[ ! ] Adding missing variable to hestia.conf: POLICY_SYSTEM_PROTECTED_ADMIN ('no')"
355+
$BIN/v-change-sys-config-value "POLICY_SYSTEM_PROTECTED_ADMIN" "no"
356+
fi
348357
# Allow user delete logs
349-
if [ -z "$POLICY_USER_DELETE_LOGS" ]; then
358+
if [[ -z $(check_key_exsits 'POLICY_USER_DELETE_LOGS') ]]; then
350359
echo "[ ! ] Adding missing variable to hestia.conf: POLICY_USER_DELETE_LOGS ('yes')"
351360
$BIN/v-change-sys-config-value "POLICY_USER_DELETE_LOGS" "yes"
352361
fi
353362
# Allow users to delete details
354-
if [ -z "$POLICY_USER_EDIT_DETAILS" ]; then
363+
if [[ -z $(check_key_exsits 'POLICY_USER_EDIT_DETAILS') ]]; then
355364
echo "[ ! ] Adding missing variable to hestia.conf: POLICY_USER_EDIT_DETAILS ('yes')"
356365
$BIN/v-change-sys-config-value "POLICY_USER_EDIT_DETAILS" "yes"
357366
fi
358367
# Allow users to edit DNS templates
359-
if [ -z "$POLICY_USER_EDIT_DNS_TEMPLATES" ]; then
368+
if [[ -z $(check_key_exsits 'POLICY_USER_EDIT_DNS_TEMPLATES') ]]; then
360369
echo "[ ! ] Adding missing variable to hestia.conf: POLICY_USER_EDIT_DNS_TEMPLATES ('yes')"
361370
$BIN/v-change-sys-config-value "POLICY_USER_EDIT_DNS_TEMPLATES" "yes"
362371
fi
363372
# Allow users to edit web templates
364-
if [ -z "$POLICY_USER_EDIT_WEB_TEMPLATES" ]; then
373+
if [[ -z $(check_key_exsits 'POLICY_USER_EDIT_WEB_TEMPLATES') ]]; then
365374
echo "[ ! ] Adding missing variable to hestia.conf: POLICY_USER_EDIT_WEB_TEMPLATES ('yes')"
366375
$BIN/v-change-sys-config-value "POLICY_USER_EDIT_WEB_TEMPLATES" "true"
367376
fi
368377
# View user logs
369-
if [ -z "$POLICY_USER_VIEW_LOGS" ]; then
378+
if [[ -z $(check_key_exsits 'POLICY_USER_VIEW_LOGS') ]]; then
370379
echo "[ ! ] Adding missing variable to hestia.conf: POLICY_USER_VIEW_LOGS ('yes')"
371380
$BIN/v-change-sys-config-value "POLICY_USER_VIEW_LOGS" "true"
372381
fi
373382
# Allow users to login (read only) when suspended
374-
if [ -z "$POLICY_USER_VIEW_SUSPENDED" ]; then
383+
if [[ -z $(check_key_exsits 'POLICY_USER_VIEW_SUSPENDED') ]]; then
375384
echo "[ ! ] Adding missing variable to hestia.conf: POLICY_USER_VIEW_SUSPENDED ('no')"
376385
$BIN/v-change-sys-config-value "POLICY_USER_VIEW_SUSPENDED" "no"
377386
fi
378387
# PHPMyadmin SSO key
379-
if [ -z "$PHPMYADMIN_KEY" ]; then
388+
if [[ -z $(check_key_exsits 'PHPMYADMIN_KEY') ]]; then
380389
echo "[ ! ] Adding missing variable to hestia.conf: PHPMYADMIN_KEY ('')"
381390
$BIN/v-change-sys-config-value "PHPMYADMIN_KEY" ""
382391
fi
383392
# Use SMTP server for hestia internal mail
384-
if [ -z "$USE_SERVER_SMTP" ]; then
393+
if [[ -z $(check_key_exsits 'USE_SERVER_SMTP') ]]; then
385394
echo "[ ! ] Adding missing variable to hestia.conf: USE_SERVER_SMTP ('')"
386395
$BIN/v-change-sys-config-value "USE_SERVER_SMTP" "false"
387396
fi
388397

389-
if [ -z "$SERVER_SMTP_PORT" ]; then
398+
if [[ -z $(check_key_exsits 'SERVER_SMTP_HOST') ]]; then
390399
echo "[ ! ] Adding missing variable to hestia.conf: SERVER_SMTP_PORT ('')"
391-
$BIN/v-change-sys-config-value "SERVER_SMTP_PORT" ""
400+
$BIN/v-change-sys-config-value "SERVER_SMTP_HOST" ""
392401
fi
393402

394-
if [ -z "$SERVER_SMTP_HOST" ]; then
403+
if [[ -z $(check_key_exsits 'SERVER_SMTP_HOST') ]]; then
395404
echo "[ ! ] Adding missing variable to hestia.conf: SERVER_SMTP_HOST ('')"
396405
$BIN/v-change-sys-config-value "SERVER_SMTP_HOST" ""
397406
fi
398407

399-
if [ -z "$SERVER_SMTP_SECURITY" ]; then
408+
if [[ -z $(check_key_exsits 'SERVER_SMTP_SECURITY') ]]; then
400409
echo "[ ! ] Adding missing variable to hestia.conf: SERVER_SMTP_SECURITY ('')"
401410
$BIN/v-change-sys-config-value "SERVER_SMTP_SECURITY" ""
402411
fi
403412

404-
if [ -z "$SERVER_SMTP_USER" ]; then
413+
if [[ -z $(check_key_exsits 'SERVER_SMTP_USER') ]]; then
405414
echo "[ ! ] Adding missing variable to hestia.conf: SERVER_SMTP_USER ('')"
406415
$BIN/v-change-sys-config-value "SERVER_SMTP_USER" ""
407416
fi
408417

409-
if [ -z "$SERVER_SMTP_PASSWD" ]; then
418+
if [[ -z $(check_key_exsits 'SERVER_SMTP_PASSWD') ]]; then
410419
echo "[ ! ] Adding missing variable to hestia.conf: SERVER_SMTP_PASSWD ('')"
411420
$BIN/v-change-sys-config-value "SERVER_SMTP_PASSWD" ""
412421
fi
413422

414-
if [ -z "$SERVER_SMTP_ADDR" ]; then
423+
if [[ -z $(check_key_exsits 'SERVER_SMTP_ADDR') ]]; then
415424
echo "[ ! ] Adding missing variable to hestia.conf: SERVER_SMTP_ADDR ('')"
416425
$BIN/v-change-sys-config-value "SERVER_SMTP_ADDR" ""
417426
fi
418-
if [ -z "$POLICY_CSRF_STRICTNESS" ]; then
427+
if [[ -z $(check_key_exsits 'POLICY_CSRF_STRICTNESS') ]]; then
419428
echo "[ ! ] Adding missing variable to hestia.conf: POLICY_CSRF_STRICTNESS ('')"
420429
$BIN/v-change-sys-config-value "POLICY_CSRF_STRICTNESS" "1"
421430
fi

0 commit comments

Comments
 (0)