Add pfsense package with command line



  • Hi to all again

    How i can add a package to my pfsense only with command line in shell?!

    I download a package (.tbz file) and all of prerequirement and put them into '/usr/local/pkg/' directory,
    then first install all prerequirement's package successfully and then install main package successfully  too
    (pkg_add 'PackageName.tbz')
    but in the web of pfsense don't show any one these package and i can not use of these.

    Can any person help me that how add packages to my pfsense with command line?

    Excuse me for bad english!!



  • This code will do it. Save as pkg-install.php and invoke as /usr/local/bin/php ./pkg-install.php "pkg name".

    /* $Id$ */
    /* ========================================================================== */
    /*
        pkg-install.php
    */
    
    require_once("/etc/inc/util.inc");
    require_once("/etc/inc/functions.inc");
    require_once("/etc/inc/pkg-utils.inc");
    require_once("/etc/inc/filter.inc");
    require_once("/etc/inc/shaper.inc");
    require_once("/etc/inc/globals.inc");
    
    function install_pkg($pkgid) {
    global $pkg_interface;
    
            $pkg_interface = "console";
    	print "Installing package " . $pkgid . "\n";
    	$status = install_package($pkgid);
    	if($status == -1) {
    		print "Installation of " . $pkgid . " FAILED!\n";
    	}
    	else {
    		print "Installation of: " . $pkgid . " completed.\n";
    		$status = get_after_install_info($pkgid);
    		if($status)
    			print "Installation completed." . "\n" . $pkgid . " setup instructions" . "\n" . $status . "\n";
    		else
    			print "Installation completed. Please check to make sure that the package is configured from the respective menu then start the package.\n";
    	}
    
    	filter_configure();
    }
    
    if ($argv[1]!="")
            install_pkg($argv[1]);
    
    ?>
    
    


  • Thanks but i did not mean that you say! :-\

    I create this file  pkg-install.php but i don't know that where i put this.

    " and invoke as /usr/local/bin/php" : How i do it?

    Unfortunately i am new in pfsense and don't understand specialized expressions of you.  :'(



  • I'm not sure I understand… you asked how to install a pfSense package from the command line.

    If you save the php code somewhere, you can run it from the command line... just do 'php yourfile.php "package_name"' where package name is the package you want to install.


  • Rebel Alliance Developer Netgate



  • Nice! Thanks! Didn't know that was in 2.1.


  • Rebel Alliance Developer Netgate

    Though reviewing the OP's request he seems to be trying to install the files locally by hand and that isn't possible - the script works like the GUI it requires remote access to the package repository.



  • @jimp:

    Though reviewing the OP's request he seems to be trying to install the files locally by hand and that isn't possible - the script works like the GUI it requires remote access to the package repository.

    Really don't can i install packages locally? Even with "pkg_add" command?

    Actually i install a package and his requirement from my hard and package compeletly installed with command line but problem is that don't show this package on the web interface!!!

    Can you help me about this?


  • Rebel Alliance Developer Netgate

    That is correct, you can get the binary parts installed, but not the GUI parts. There is no current way to do that without manually moving a bunch of files and hand editing several things into the config.xml file.

    It's something we want to accommodate in the future, but it is not currently possible.



  • thanks for your help jimp but i have a problem and that is this:

    Some of files of packages is filter for me and these not in my access
    so i can not install some package on pfsense.
    How i install this packages?

    Can i get packages from installed packages on another pfsense that it access is full?