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.
		
		
		
		
		
			
		
			
				
					
					
						
							57 lines
						
					
					
						
							1.5 KiB
						
					
					
				
			
		
		
	
	
							57 lines
						
					
					
						
							1.5 KiB
						
					
					
				#!/bin/bash
 | 
						|
# info: revokes api key
 | 
						|
# options: [HASH]
 | 
						|
#
 | 
						|
# example: v-revoke-api-key mykey
 | 
						|
#
 | 
						|
# This function removes a key from in $HESTIA/data/keys/
 | 
						|
 | 
						|
#----------------------------------------------------------#
 | 
						|
#                Variables & Functions                     #
 | 
						|
#----------------------------------------------------------#
 | 
						|
 | 
						|
# 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"
 | 
						|
 | 
						|
#----------------------------------------------------------#
 | 
						|
#                Variables & Functions                     #
 | 
						|
#----------------------------------------------------------#
 | 
						|
 | 
						|
hash=$1
 | 
						|
 | 
						|
args_usage='HASH'
 | 
						|
check_args '1' "$#" "$args_usage"
 | 
						|
is_format_valid 'hash'
 | 
						|
 | 
						|
# Perform verification if read-only mode is enabled
 | 
						|
check_hestia_demo_mode
 | 
						|
 | 
						|
#----------------------------------------------------------#
 | 
						|
#                       Action                             #
 | 
						|
#----------------------------------------------------------#
 | 
						|
 | 
						|
if [ ! -d "$HESTIA/data/keys/" ]; then
 | 
						|
	exit "$E_NOTEXIST"
 | 
						|
fi
 | 
						|
 | 
						|
if [[ -e "$HESTIA/data/keys/$hash" ]]; then
 | 
						|
	rm $HESTIA/data/keys/$hash
 | 
						|
else
 | 
						|
	exit "$E_NOTEXIST"
 | 
						|
fi
 | 
						|
 | 
						|
#----------------------------------------------------------#
 | 
						|
#                       Hestia                             #
 | 
						|
#----------------------------------------------------------#
 | 
						|
 | 
						|
# Logging
 | 
						|
$BIN/v-log-action "system" "Info" "System" "System API key revoked (Key: $hash)."
 | 
						|
log_event "$OK" "$ARGUMENTS"
 | 
						|
 | 
						|
exit
 |