Go Back   DaemonForums > FreeBSD > FreeBSD Installation and Upgrading

FreeBSD Installation and Upgrading Installing and upgrading FreeBSD.

Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1   (View Single Post)  
Old 9th May 2008
cajunman4life cajunman4life is offline
Real Name: Aaron Graves
Package Pilot
Join Date: May 2008
Location: Coolidge, Arizona
Posts: 203
Default Keeping ports in multiple jails up to date

This might possibly belong in the guides section. If that's the case, then feel free to move mods

At any rate, I'm sitting here bored at work again. So I set out to solve one of the problems I've been thinking (admittedly not to heavily) about the last few days. I've recently begun using jails (specifically ezjail) more and more lately, and with all the different ports that I install in each one, it's becoming increasingly difficult to make sure each one is up-to-date.

On the host system I have a simple script that checks for updates:
/usr/sbin/pkg_version -v -L '='
This will output a nice list of the ports installed that are out of date. Using this list I can determine which, if any of these, actually needs to be updated (was it a security/bugfix, or did someone just bump something to the latest version and by upgrading I could potentially break other things?).

So, how can I also check my jails without having to manually log in to each jail and run the above command? Well, the "usual" way that is. By writing a shell script.

Background information: I don't have a ports tree installed in any of my jails. /usr/ports/ is an empty directory, and I use mount_nullfs to mount the ports tree on the host system to each jail.

Without further ado, here is my shell script. Feel free to use it yourself if you'd like (note however that it is "beerware", so if you're ever in the Phoenix metro area you'll be required to buy me a beer... or not ).

# CVAll - checkver all - Checks for available updates on all jails.
# Written by Aaron Graves - 05/09/2008
#  Let's just call this a release under the beerware license.
#  No need to be all formal and such.

# First step, see if we're running as root. If not, then complain and exit.
if [ `whoami` != "root" ]; then
        echo 1>&2 ERROR: This command must be run by root...
        exit 1

# Now that we've got that nasty business out of the way, let's mount the ports
#  tree to all jails.
echo -n "Mounting ports tree to all jails: "
./mports all > /dev/null
echo "Done."
echo ""

# Now we'll go step by step through each jail to check for updates...
for i in `jls | grep -v "JID" | awk '{print $3}'`
        echo "Checking for available updates on $i, please wait..."
        jexec -U root `jls | grep $i | awk '{print $1}'` /usr/sbin/pkg_version -v -L '='
        echo "Done."
        echo ""

# Now, unmount all ports
echo -n "Unmounting ports tree from all jails: "
./umports all > /dev/null
echo "Done."
An additional note: The "mports" and "umports" above references a few other scripts I've written which goes through and does mount_nullfs for each of the jails I have installed to mount the ports tree. If anyone's interested I can post the code for those scripts (or you can replace those sections with whatever code you want to use to mount the ports tree).

Any questions/comments can be directed back towards me. Enjoy!
I just saved a bunch of money on my car insurance by fleeing the scene of the accident!
Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[fman] tags out of date for ports BSDKaffee Feedback and Suggestions 1 12th June 2009 07:36 AM
jails, aliasing, router, and dmz? neurosis FreeBSD Security 17 7th November 2008 03:47 AM
Using Date variable? cwhitmore FreeBSD General 9 13th August 2008 07:16 AM
Upgrading firefox to firefox 3 -keeping plugins+bookmarks kasse FreeBSD Ports and Packages 11 5th July 2008 01:34 PM
HOWTO: Always install an up-to-date port chris Guides 8 28th May 2008 11:53 AM

All times are GMT. The time now is 02:13 AM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2022, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick