-
-
Save BBcan177/b5d9506f9d1ca1ff2457f62bbaaaf878 to your computer and use it in GitHub Desktop.
pfSense python integration start-up code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Mount lib and bin folders | |
$base_unbound = '/var/unbound'; | |
$base_py = '/usr/local'; | |
foreach (array('/bin', '/lib') as $dir) { | |
$validate = exec("/sbin/mount | {$pfb['grep']} '{$base_unbound}{$base_py}{$dir}' 2>&1"); | |
if ($mode == 'enabled' && empty($validate)) { | |
if (!is_dir("{$base_unbound}{$base_py}{$dir}")) { | |
pfb_logger("\n Creating: {$base_unbound}{$base_py}{$dir}", 1); | |
exec("/bin/mkdir -p {$base_unbound}{$base_py}{$dir} 2>&1"); | |
} | |
$pfbpython = TRUE; | |
pfb_logger("\n Mounting: /usr/local{$dir}", 1); | |
exec("/sbin/mount_nullfs -o ro /usr/local{$dir} {$base_unbound}{$base_py}{$dir} 2>&1", $output, $retval); | |
if ($retval != 0) { | |
pfb_logger("\n Failed to mount [ /usr/local{$dir} ] to [ {$base_unbound}{$base_py}{$dir} ]!", 1); | |
} | |
} | |
elseif ($mode == 'disabled' && !empty($validate)) { | |
$pfbpython = TRUE; | |
pfb_logger("\n Unmounting: /usr/local{$dir}", 1); | |
exec("/sbin/umount -t nullfs {$base_unbound}{$base_py}{$dir} 2>&1", $output, $retval;\ | |
if ($retval != 0) { | |
pfb_logger("\n Failed to unmount [ {$base_unbound}{$base_py}{$dir} ]!", 1); | |
} | |
} | |
if ($mode == 'disabled') { | |
foreach (array( "/usr/local{$dir}", '/usr/local', '/usr') as $folder) { | |
if (is_dir("{$base_unbound}{$folder}")) { | |
pfb_logger("\n Removing: {$base_unbound}{$folder}", 1); | |
rmdir("{$base_unbound}{$folder}"); | |
} | |
// Delete remaining subfolders on next loop | |
if ($dir == '/bin') { | |
break; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment