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
						
					
					
				#!/bin/bash
 | 
						|
# info: delete firewall rule
 | 
						|
# options: RULE
 | 
						|
#
 | 
						|
# example: v-delete-firewall-rule SSH_BLOCK
 | 
						|
#
 | 
						|
# This function deletes firewall rule.
 | 
						|
 | 
						|
#----------------------------------------------------------#
 | 
						|
#                Variables & Functions                     #
 | 
						|
#----------------------------------------------------------#
 | 
						|
 | 
						|
# Argument definition
 | 
						|
rule=$1
 | 
						|
 | 
						|
# 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                         #
 | 
						|
#----------------------------------------------------------#
 | 
						|
 | 
						|
check_args '1' "$#" 'RULE'
 | 
						|
is_format_valid 'rule'
 | 
						|
is_system_enabled "$FIREWALL_SYSTEM" 'FIREWALL_SYSTEM'
 | 
						|
is_object_valid '../../data/firewall/rules' 'RULE' "$rule"
 | 
						|
 | 
						|
# Perform verification if read-only mode is enabled
 | 
						|
check_hestia_demo_mode
 | 
						|
 | 
						|
#----------------------------------------------------------#
 | 
						|
#                       Action                             #
 | 
						|
#----------------------------------------------------------#
 | 
						|
 | 
						|
# Deleting rule
 | 
						|
sed -i "/RULE='$rule' /d" $HESTIA/data/firewall/rules.conf
 | 
						|
 | 
						|
# Updating system firewall
 | 
						|
$BIN/v-update-firewall
 | 
						|
 | 
						|
#----------------------------------------------------------#
 | 
						|
#                       Hestia                             #
 | 
						|
#----------------------------------------------------------#
 | 
						|
 | 
						|
# Logging
 | 
						|
$BIN/v-log-action "system" "Info" "Firewall" "Removed firewall rule (ID: $rule)."
 | 
						|
log_event "$OK" "$ARGUMENTS"
 | 
						|
 | 
						|
exit
 |