Date: Sat, 1 Dec 2001 16:43:32 -0600 From: Noah Dunker <ndunker@jccc.net> To: "'freebsd-questions@freebsd.org'" <freebsd-questions@freebsd.org> Subject: A little Script I put together Message-ID: <C18E28011272D41180AD00B0D0496C0801C022CA@ns-exch05>
next in thread | raw e-mail | index | archive | help
A coworker and I put this together some time ago. We use it mostly on our FreeBSD Laptops. There are a few minor security issues in that this script just blindly accepts packages off the FreeBSD FTP Server (or whatever server/path you choose for $pkg_source. I Figured I'd share. You type a package name, say, xmame, you type: ./pkg_inst.sh xmame And it will download a new package list from freebsd.org, search through it for the full filename of xmame, and feed the whole ftp path to pkg_add, which will download it, and if it has dependencies, pkg_add will download them, too. Kind of like using the ports system, but you don't have to wait. :) /var/pkgindex gets checked every time you run, but it will download a fresh copy if the current /var/pkgindex is more than 24 Hours old. Basically, this just searches the ftp site for the whole version number, so that you don't have to manually trudge out there with ncfpt2 or some such. We decided to use normal shell tools instead of perl. I can't remember why now. :) Enjoy! Props go out to w0lfman68 for not only his incessant prodding of me to make a tool like this, but sitting down and helping me add features and cleaning it up. :) Noah Dunker Systems Analyst/Technician Johnson County Community College #!/bin/sh # # pkg_inst.sh # evil package installer hack # for freebsd # # Usage: pkg_inst.sh <package name> # requires lynx # # source of packages pkg_source="ftp.freebsd.org/pub/FreeBSD/ports/packages/All/" # name of pkgindex pkg_index="/var/pkgindex" if [ $1 ] # check for package name arg then # did we get the name of a package.tgz if [ `echo $1 | grep -e "-[0-9]" | wc -c` -gt 3 ] then # set pkgname to 1st arg pkgname=$1 # find a match in the pkg_index else # do we have a current copy of pkg_index if [ `find $pkg_index -mtime 1| wc -c` -gt 3 ] then echo "Found current pkgindex" # set pkgname to name of newest package version in pkgindex pkgname=`cat $pkg_index |cut -b32- |grep "^$1-[0-9]" |cut -f1 -d " " | tail -1` else # go get a new list of packages echo "Getting fresh pkgindex from freebsd.org" lynx -dump -nolist ftp://$pkg_source >/var/pkgindex # set pkgname to name of newest package version in pkgindex pkgname=`cat $pkg_index |cut -b32- |grep "^$1-[0-9]" |cut -f1 -d " " | tail -1` fi fi # if we have the package name install it if [ `echo $pkgname |wc -c` -gt 3 ] then echo "installing package $pkgname" pkg_add ftp://ftp.freebsd.org/pub/FreeBSD/ports/packages/All/$pkgname else # no match found echo "Sorry no match for $1" fi else # you did not supply the argument echo "Usage: install.sh <package name>" fi # end of script To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?C18E28011272D41180AD00B0D0496C0801C022CA>