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

Fix/change default value true to yes for three POLICY_USER directives (#3998)

* Modify three POLICY_USER values to use yes instead of true

Modified directives are:

POLICY_USER_CHANGE_THEME
POLICY_USER_EDIT_WEB_TEMPLATES
POLICY_USER_VIEW_LOGS

* Fix default values for three POLICY_USER directives

In hestia.conf and defaults/hestia.conf, modify existing POLICY_USER directives (POLICY_USER_CHANGE_THEME, POLICY_USER_EDIT_WEB_TEMPLATES and POLICY_USER_VIEW_LOGS) that are using value 'true' instead of the correct value 'yes'
sahsanu 2 лет назад
Родитель
Сommit
bec1b59151
2 измененных файлов с 54 добавлено и 3 удалено
  1. 3 3
      func/syshealth.sh
  2. 51 0
      install/upgrade/versions/1.8.8.sh

+ 3 - 3
func/syshealth.sh

@@ -394,7 +394,7 @@ function syshealth_repair_system_config() {
 	# Theme editor
 	if [[ -z $(check_key_exists 'POLICY_USER_CHANGE_THEME') ]]; then
 		echo "[ ! ] Adding missing variable to hestia.conf: POLICY_USER_CHANGE_THEME ('yes')"
-		$BIN/v-change-sys-config-value "POLICY_USER_CHANGE_THEME" "true"
+		$BIN/v-change-sys-config-value "POLICY_USER_CHANGE_THEME" "yes"
 	fi
 	# Protect admin user
 	if [[ -z $(check_key_exists 'POLICY_SYSTEM_PROTECTED_ADMIN') ]]; then
@@ -419,12 +419,12 @@ function syshealth_repair_system_config() {
 	# Allow users to edit web templates
 	if [[ -z $(check_key_exists 'POLICY_USER_EDIT_WEB_TEMPLATES') ]]; then
 		echo "[ ! ] Adding missing variable to hestia.conf: POLICY_USER_EDIT_WEB_TEMPLATES ('yes')"
-		$BIN/v-change-sys-config-value "POLICY_USER_EDIT_WEB_TEMPLATES" "true"
+		$BIN/v-change-sys-config-value "POLICY_USER_EDIT_WEB_TEMPLATES" "yes"
 	fi
 	# View user logs
 	if [[ -z $(check_key_exists 'POLICY_USER_VIEW_LOGS') ]]; then
 		echo "[ ! ] Adding missing variable to hestia.conf: POLICY_USER_VIEW_LOGS ('yes')"
-		$BIN/v-change-sys-config-value "POLICY_USER_VIEW_LOGS" "true"
+		$BIN/v-change-sys-config-value "POLICY_USER_VIEW_LOGS" "yes"
 	fi
 	# Allow users to login (read only) when suspended
 	if [[ -z $(check_key_exists 'POLICY_USER_VIEW_SUSPENDED') ]]; then

+ 51 - 0
install/upgrade/versions/1.8.8.sh

@@ -0,0 +1,51 @@
+#!/bin/bash
+
+# Hestia Control Panel upgrade script for target version 1.8.8
+
+#######################################################################################
+#######                      Place additional commands below.                   #######
+#######################################################################################
+####### upgrade_config_set_value only accepts true or false.                    #######
+#######                                                                         #######
+####### Pass through information to the end user in case of a issue or problem  #######
+#######                                                                         #######
+####### Use add_upgrade_message "My message here" to include a message          #######
+####### in the upgrade notification email. Example:                             #######
+#######                                                                         #######
+####### add_upgrade_message "My message here"                                   #######
+#######                                                                         #######
+####### You can use \n within the string to create new lines.                   #######
+#######################################################################################
+
+upgrade_config_set_value 'UPGRADE_UPDATE_WEB_TEMPLATES' 'false'
+upgrade_config_set_value 'UPGRADE_UPDATE_DNS_TEMPLATES' 'false'
+upgrade_config_set_value 'UPGRADE_UPDATE_MAIL_TEMPLATES' 'false'
+upgrade_config_set_value 'UPGRADE_REBUILD_USERS' 'false'
+upgrade_config_set_value 'UPGRADE_UPDATE_FILEMANAGER_CONFIG' 'false'
+
+# Modify existing POLICY_USER directives (POLICY_USER_CHANGE_THEME, POLICY_USER_EDIT_WEB_TEMPLATES
+# and POLICY_USER_VIEW_LOGS) that are using value 'true' instead of the correct value 'yes'
+
+hestia_conf="$HESTIA/conf/hestia.conf"
+hestia_defaults_conf="$HESTIA/conf/defaults/hestia.conf"
+
+for i in POLICY_USER_CHANGE_THEME POLICY_USER_EDIT_WEB_TEMPLATES POLICY_USER_VIEW_LOGS; do
+        if [[ -f "$hestia_conf" ]]; then
+                if grep "$i" "$hestia_conf" | grep -q 'true'; then
+                        if "$BIN/v-change-sys-config-value" "$i" 'yes'; then
+                                echo "[ * ] Success: ${i} value changed from true to yes in hestia.conf"
+                        else
+                                echo "[ ! ] Error: Couldn't change ${i} value from true to yes in hestia.conf"
+                        fi
+                fi
+        fi
+        if [[ -f "$hestia_defaults_conf" ]]; then
+                if grep "$i" "$hestia_defaults_conf" | grep -q 'true'; then
+                        if sed -i "s/${i}='true'/${i}='yes'/" "$hestia_defaults_conf"; then
+                                echo "[ * ] Success: ${i} value changed from true to yes in defaults/hestia.conf"
+                        else
+                                echo "[ ! ] Error: Couldn't change ${i} value from true to yes in defaults/hestia.conf"
+                        fi
+                fi
+        fi
+done