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.
		
		
		
		
		
			
		
			
				
					56 lines
				
				1.7 KiB
			
		
		
			
		
	
	
					56 lines
				
				1.7 KiB
			| 
								 
											2 years ago
										 
									 | 
							
								#!/bin/bash
							 | 
						||
| 
								 | 
							
								# info: suspend firewall rule
							 | 
						||
| 
								 | 
							
								# options: RULE
							 | 
						||
| 
								 | 
							
								#
							 | 
						||
| 
								 | 
							
								# example: v-suspend-firewall-rule 7
							 | 
						||
| 
								 | 
							
								#
							 | 
						||
| 
								 | 
							
								# This function suspends a certain 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"
							 | 
						||
| 
								 | 
							
								is_object_unsuspended '../../data/firewall/rules' 'RULE' "$rule"
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								# Perform verification if read-only mode is enabled
							 | 
						||
| 
								 | 
							
								check_hestia_demo_mode
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#----------------------------------------------------------#
							 | 
						||
| 
								 | 
							
								#                       Action                             #
							 | 
						||
| 
								 | 
							
								#----------------------------------------------------------#
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								# Suspending rule
							 | 
						||
| 
								 | 
							
								update_object_value ../../data/firewall/rules RULE "$rule" '$SUSPENDED' yes
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								# Updating system firewall
							 | 
						||
| 
								 | 
							
								$BIN/v-update-firewall
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#----------------------------------------------------------#
							 | 
						||
| 
								 | 
							
								#                       Hestia                             #
							 | 
						||
| 
								 | 
							
								#----------------------------------------------------------#
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								# Logging
							 | 
						||
| 
								 | 
							
								$BIN/v-log-action "system" "Info" "Firewall" "Suspended firewall rule (Rule: $rule)."
							 | 
						||
| 
								 | 
							
								log_event "$OK" "$ARGUMENTS"
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								exit
							 |