mirror of
https://github.com/serghey-rodin/vesta.git
synced 2025-08-14 10:37:39 -07:00
refactoring: log_event(), is_format_valid()
This commit is contained in:
parent
6e0ef668bb
commit
e05dca61a6
211 changed files with 756 additions and 1091 deletions
|
@ -40,9 +40,9 @@ sort_fw_rules() {
|
|||
#----------------------------------------------------------#
|
||||
|
||||
check_args '5' "$#" 'RULE ACTION IP PORT [PROTOCOL] [COMMENT]'
|
||||
validate_format 'rule' 'action' 'protocol' 'port_ext' 'ip'
|
||||
is_format_valid 'rule' 'action' 'protocol' 'port_ext' 'ip'
|
||||
if [ ! -z "$comment" ]; then
|
||||
validate_format 'comment'
|
||||
is_format_valid 'comment'
|
||||
fi
|
||||
is_system_enabled "$FIREWALL_SYSTEM" 'FIREWALL_SYSTEM'
|
||||
is_object_valid '../../data/firewall/rules' 'RULE' "$rule"
|
||||
|
@ -52,10 +52,15 @@ is_object_valid '../../data/firewall/rules' 'RULE' "$rule"
|
|||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Generating timestamp
|
||||
time_n_date=$(date +'%T %F')
|
||||
time=$(echo "$time_n_date" |cut -f 1 -d \ )
|
||||
date=$(echo "$time_n_date" |cut -f 2 -d \ )
|
||||
|
||||
# Concatenating firewall rule
|
||||
str="RULE='$rule' ACTION='$action' PROTOCOL='$protocol' PORT='$port_ext'"
|
||||
str="$str IP='$ip' COMMENT='$comment' SUSPENDED='no'"
|
||||
str="$str TIME='$TIME' DATE='$DATE'"
|
||||
str="$str TIME='$time' DATE='$date'"
|
||||
|
||||
# Deleting old rule
|
||||
sed -i "/RULE='$rule' /d" $VESTA/data/firewall/rules.conf
|
||||
|
@ -75,6 +80,6 @@ $BIN/v-update-firewall
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Logging
|
||||
log_event "$OK" "$EVENT"
|
||||
log_event "$OK" "$ARGUMENTS"
|
||||
|
||||
exit
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue