#!/bin/bash # info: delete firewall rule # options: RULE # # The function deletes firewall rule. #----------------------------------------------------------# # Variable&Function # #----------------------------------------------------------# # Importing system variables source /etc/profile # Argument definition rule=$1 # Includes source $VESTA/func/main.sh source $VESTA/conf/vesta.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" #----------------------------------------------------------# # Action # #----------------------------------------------------------# oldvalues=$(grep "RULE='$rule'" $VESTA/data/firewall/rules.conf) # Deleting rule sed -i "/RULE='$rule' /d" $VESTA/data/firewall/rules.conf # Updating system firewall $BIN/v-update-firewall if [ "$WEB_SYSTEM" == 'nginx' ] || [ "$PROXY_SYSTEM" == 'nginx' ]; then parse_object_kv_list_non_eval "$oldvalues" if [ "$PORT" == "80,443" ] && [ "$ACTION" == "DROP" ]; then sed -i "/$IP/d" /etc/nginx/conf.d/block-firewall.conf systemctl restart nginx fi fi #----------------------------------------------------------# # Vesta # #----------------------------------------------------------# # Logging log_event "$OK" "$ARGUMENTS" exit