Add separate command before/after blacklist refresh http://virtualmin.com/node/36643

This commit is contained in:
Jamie Cameron
2015-03-25 23:10:09 -07:00
parent 882dcb7384
commit 04ed6406e7
3 changed files with 25 additions and 2 deletions

View File

@@ -4,4 +4,6 @@ actions=Standard actions files,9,40,5,\t
macros=Macro files directory,0
before_apply_cmd=Command to run before applying configuration,3,None
after_apply_cmd=Command to run after applying configuration,3,None
before_refresh_cmd=Command to run before refreshing blacklist,3,None
after_refresh_cmd=Command to run after refreshing blacklist,3,None
display_zone_descriptions=Display zone descriptions in rules file?,1,0-No,1-Yes

View File

@@ -9,13 +9,13 @@ if ($access{'nochange'}) {
}
&error_setup($text{'refresh_err'});
$err = &run_before_apply_command();
$err = &run_before_refresh_command();
&error($err) if ($err);
$out = &backquote_logged("$config{'shorewall'} refresh 2>&1");
if ($?) {
&error("<pre>$out</pre>");
}
$err = &run_after_apply_command();
$err = &run_after_refresh_command();
&webmin_log("refresh");
&redirect("");

View File

@@ -1845,6 +1845,27 @@ if ($config{'after_apply_cmd'}) {
}
}
# run_before_refresh_command()
# Runs the before-refresh command, if any. If it fails, returns the error
# message output
sub run_before_refresh_command
{
if ($config{'before_refresh_cmd'}) {
local $out = &backquote_logged("($config{'before_refresh_cmd'}) </dev/null 2>&1");
return $out if ($?);
}
return undef;
}
# run_after_refresh_command()
# Runs the after-refresh command, if any
sub run_after_refresh_command
{
if ($config{'after_refresh_cmd'}) {
&system_logged("($config{'after_refresh_cmd'}) </dev/null >/dev/null 2>&1");
}
}
# list_standard_actions()
# Returns a list of standard Shorewall actions
sub list_standard_actions