You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					55 lines
				
				1.6 KiB
			
		
		
			
		
	
	
					55 lines
				
				1.6 KiB
			| 
								 
											2 years ago
										 
									 | 
							
								#!/bin/bash
							 | 
						||
| 
								 | 
							
								# info: changes user configuration value
							 | 
						||
| 
								 | 
							
								# options: USER KEY VALUE
							 | 
						||
| 
								 | 
							
								#
							 | 
						||
| 
								 | 
							
								# example: v-change-user-config-value admin ROLE admin
							 | 
						||
| 
								 | 
							
								#
							 | 
						||
| 
								 | 
							
								# Changes key/value for specified user.
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#----------------------------------------------------------#
							 | 
						||
| 
								 | 
							
								#                Variables & Functions                     #
							 | 
						||
| 
								 | 
							
								#----------------------------------------------------------#
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								# Argument definition
							 | 
						||
| 
								 | 
							
								user=$1
							 | 
						||
| 
								 | 
							
								key="$2"
							 | 
						||
| 
								 | 
							
								value="$3"
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								# Includes
							 | 
						||
| 
								 | 
							
								# shellcheck source=/etc/hestiacp/hestia.conf
							 | 
						||
| 
								 | 
							
								source /etc/hestiacp/hestia.conf
							 | 
						||
| 
								 | 
							
								# shellcheck source=/usr/local/hestia/func/main.sh
							 | 
						||
| 
								 | 
							
								source $HESTIA/func/main.sh
							 | 
						||
| 
								 | 
							
								# load config file
							 | 
						||
| 
								 | 
							
								source_conf "$HESTIA/conf/hestia.conf"
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#----------------------------------------------------------#
							 | 
						||
| 
								 | 
							
								#                    Verifications                         #
							 | 
						||
| 
								 | 
							
								#----------------------------------------------------------#
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								is_format_valid 'user' 'key'
							 | 
						||
| 
								 | 
							
								is_common_format_valid "$value" "$key"
							 | 
						||
| 
								 | 
							
								is_object_valid 'user' 'USER' "$user"
							 | 
						||
| 
								 | 
							
								is_object_unsuspended 'user' 'USER' "$user"
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								# Perform verification if read-only mode is enabled
							 | 
						||
| 
								 | 
							
								check_hestia_demo_mode
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#----------------------------------------------------------#
							 | 
						||
| 
								 | 
							
								#                       Action                             #
							 | 
						||
| 
								 | 
							
								#----------------------------------------------------------#
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								# Set theme value
							 | 
						||
| 
								 | 
							
								check_ckey=$(grep "^${key^^}" $USER_DATA/user.conf)
							 | 
						||
| 
								 | 
							
								if [ -z "$check_ckey" ]; then
							 | 
						||
| 
								 | 
							
									# Rebuild user configuration to repair missing value
							 | 
						||
| 
								 | 
							
									$BIN/v-rebuild-user "$user"
							 | 
						||
| 
								 | 
							
								fi
							 | 
						||
| 
								 | 
							
								update_user_value "$user" "${key^^}" "$value"
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#----------------------------------------------------------#
							 | 
						||
| 
								 | 
							
								#                       Hestia                             #
							 | 
						||
| 
								 | 
							
								#----------------------------------------------------------#
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								exit
							 |