diff options
author | Jim P <jim@pingle.org> | 2012-08-22 05:10:12 -0700 |
---|---|---|
committer | Jim P <jim@pingle.org> | 2012-08-22 05:10:12 -0700 |
commit | 5413255f09b75859c3fcab39bbaef65a9ac6dfe7 (patch) | |
tree | a1f0c98115b3a069e97d2688b1c9cca2f08a2a31 /config/ipguard/ipguard.inc | |
parent | ba47052140bc2e2430ffb2731f70f008baece090 (diff) | |
parent | 9c886d11858e0e82e65f4de02662b6e4c076ca51 (diff) | |
download | pfsense-packages-5413255f09b75859c3fcab39bbaef65a9ac6dfe7.tar.gz pfsense-packages-5413255f09b75859c3fcab39bbaef65a9ac6dfe7.tar.bz2 pfsense-packages-5413255f09b75859c3fcab39bbaef65a9ac6dfe7.zip |
Merge pull request #312 from phil-davis/master
Ipguard minor cleanup
Diffstat (limited to 'config/ipguard/ipguard.inc')
-rw-r--r-- | config/ipguard/ipguard.inc | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/config/ipguard/ipguard.inc b/config/ipguard/ipguard.inc index 052f6f31..1891b24b 100644 --- a/config/ipguard/ipguard.inc +++ b/config/ipguard/ipguard.inc @@ -44,7 +44,9 @@ function ipguard_custom_php_deinstall_command(){ conf_mount_rw(); stop_service('ipguard'); - chmod("/usr/local/etc/rc.d/ipguard.sh",0444); + $ipguard_sh_file = "/usr/local/etc/rc.d/ipguard.sh"; + if (is_file($ipguard_sh_file)) + chmod($ipguard_sh_file,0444); conf_mount_ro(); } @@ -60,9 +62,6 @@ function ipguard_custom_php_write_config(){ if (is_array($config['installedpackages']['ipguard']['config'])){ - // Mount Read-write - conf_mount_rw(); - // Read config $new_config=array(); foreach ($config['installedpackages']['ipguard']['config'] as $ipguard){ @@ -96,7 +95,9 @@ function ipguard_custom_php_write_config(){ else{ #remove config files stop_service('ipguard'); - chmod("/usr/local/etc/rc.d/ipguard.sh",0444); + $ipguard_sh_file = "/usr/local/etc/rc.d/ipguard.sh"; + if (is_file($ipguard_sh_file)) + chmod($ipguard_sh_file,0444); } // Mount Read-only conf_mount_ro(); @@ -109,20 +110,20 @@ function ipguard_custom_php_write_config(){ function ipguard_sync_on_changes() { global $config, $g; - if (is_array($config['installedpackages']['ipguardsync'])) - if (!$config['installedpackages']['ipguardsync']['config'][0]['synconchanges']) - return; - - log_error("[ipguard] xmlrpc sync is starting."); - foreach ($config['installedpackages']['ipguardsync']['config'] as $rs ){ - foreach($rs['row'] as $sh){ - $sync_to_ip = $sh['ipaddress']; - $password = $sh['password']; - if($password && $sync_to_ip) - ipguard_do_xmlrpc_sync($sync_to_ip, $password); + if (is_array($config['installedpackages']['ipguardsync'])) { + if ($config['installedpackages']['ipguardsync']['config'][0]['synconchanges']) { + log_error("[ipguard] xmlrpc sync is starting."); + foreach ($config['installedpackages']['ipguardsync']['config'] as $rs ){ + foreach($rs['row'] as $sh){ + $sync_to_ip = $sh['ipaddress']; + $password = $sh['password']; + if($password && $sync_to_ip) + ipguard_do_xmlrpc_sync($sync_to_ip, $password); + } } + log_error("[ipguard] xmlrpc sync is ending."); + } } - log_error("[ipguard] xmlrpc sync is ending."); } /* Do the actual XMLRPC sync */ @@ -185,7 +186,7 @@ function ipguard_do_xmlrpc_sync($sync_to_ip, $password) { log_error("ipguard XMLRPC sync successfully completed with {$url}:{$port}."); } - /* tell ipguard to reload our settings on the destionation sync host. */ + /* tell ipguard to reload our settings on the destination sync host. */ $method = 'pfsense.exec_php'; $execcmd = "require_once('/usr/local/pkg/ipguard.inc');\n"; $execcmd .= "ipguard_custom_php_write_config();"; |