diff options
author | jim-p <jimp@pfsense.org> | 2013-02-19 10:36:12 -0500 |
---|---|---|
committer | jim-p <jimp@pfsense.org> | 2013-02-19 10:36:12 -0500 |
commit | 5823264a93654f8f172cdaf80bf1bb35ceb7d801 (patch) | |
tree | 4dc21c421f41eca2054a592f73e8bb966ecd0eb4 /etc/phpshellsessions | |
parent | 28a20fdbf4621c0f5b854615dcc31f5234812f00 (diff) | |
download | pfsense-5823264a93654f8f172cdaf80bf1bb35ceb7d801.zip pfsense-5823264a93654f8f172cdaf80bf1bb35ceb7d801.tar.gz |
Add some PHP shell scripts for managing packages from the CLI.
pfSsh.php playback installpkg git
pfSsh.php playback uninstallpkg git
pfSsh.php playback listpkg
Diffstat (limited to 'etc/phpshellsessions')
-rw-r--r-- | etc/phpshellsessions/installpkg | 39 | ||||
-rw-r--r-- | etc/phpshellsessions/listpkg | 15 | ||||
-rw-r--r-- | etc/phpshellsessions/uninstallpkg | 35 |
3 files changed, 89 insertions, 0 deletions
diff --git a/etc/phpshellsessions/installpkg b/etc/phpshellsessions/installpkg new file mode 100644 index 0000000..15343df --- /dev/null +++ b/etc/phpshellsessions/installpkg @@ -0,0 +1,39 @@ +require_once("config.inc"); +require_once("util.inc"); +require_once("pkg-utils.inc"); + +global $g, $config, $argv, $command_split; + +if(is_array($command_split)) + $args = array_slice($command_split, 2); +else + $args = array_slice($argv, 3); + +$pkg_name = $args[0]; +$install_type = empty($args[1]) ? "normal" : $args[1]; + +echo "Installing package \"{$pkg_name}\"...\n"; + +echo "Trying to fetch package info..."; +$pkg_info = get_pkg_info(); +if ($pkg_info) { + echo " Done.\n"; +} else { + $xmlrpc_base_url = isset($config['system']['altpkgrepo']['enable']) ? $config['system']['altpkgrepo']['xmlrpcbaseurl'] : $g['xmlrpcbaseurl']; + echo "\n" . sprintf(gettext(' >>> Unable to communicate with %1$s. Please verify DNS and interface configuration, and that %2$s has functional Internet connectivity.'), $xmlrpc_base_url, $g['product_name']) . "\n"; + return; +} + +$static_output = ""; +$pkg_interface = "console"; + +if (empty($pkg_info[$pkg_name])) + echo "\nPackage not found.\n"; +elseif ($install_type == "normal") + install_package($pkg_name, $pkg_info[$pkg_name], true); +elseif ($install_type == "xmlonly") + install_package_xml($pkg_name); +else + echo "Invalid install type. Valid values are: normal, xmlonly.\n"; + +echo "\nDone.\n"; diff --git a/etc/phpshellsessions/listpkg b/etc/phpshellsessions/listpkg new file mode 100644 index 0000000..9c13b45 --- /dev/null +++ b/etc/phpshellsessions/listpkg @@ -0,0 +1,15 @@ +require_once("config.inc"); +require_once("util.inc"); + +global $g, $config; + +echo "Installed packages:\n"; + +foreach($config['installedpackages']['package'] as $package) { + $name = str_pad("{$package['name']}-{$package['version']}", 30); + $descr = $package['descr']; + $line = "{$name} {$descr}"; + if (strlen($line) > 80) + $line = substr($line, 0, 77) . "..."; + echo "{$line}\n"; +} diff --git a/etc/phpshellsessions/uninstallpkg b/etc/phpshellsessions/uninstallpkg new file mode 100644 index 0000000..484ccc8 --- /dev/null +++ b/etc/phpshellsessions/uninstallpkg @@ -0,0 +1,35 @@ +require_once("config.inc"); +require_once("util.inc"); +require_once("pkg-utils.inc"); + +global $g, $config, $argv, $command_split; + +if(is_array($command_split)) + $args = array_slice($command_split, 2); +else + $args = array_slice($argv, 3); + +$pkg_name = $args[0]; +$remove_type = empty($args[1]) ? "normal" : $args[1]; +$pkg_info = array(); + +echo "Removing package \"{$pkg_name}\"...\n"; + +foreach($config['installedpackages']['package'] as $package) { + if ($pkg_name == $package['name']) + $pkg_info = $package; +} + +$static_output = ""; +$pkg_interface = "console"; + +if (empty($pkg_info)) + echo "\nPackage not installed.\n"; +elseif ($remove_type == "normal") + uninstall_package($pkg_name); +elseif ($remove_type == "xmlonly") + delete_package_xml($pkg_name); +else + echo "Invalid removal type. Valid values are: normal, xmlonly.\n"; + +echo "\nDone.\n";
\ No newline at end of file |