|
FreeBSD Installation and Upgrading Installing and upgrading FreeBSD. |
|
Thread Tools | Display Modes |
|
|||
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: Code:
/usr/sbin/pkg_version -v -L '=' 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 ). Code:
#!/bin/sh # 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 fi # 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}'` do 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 "" done # Now, unmount all ports echo -n "Unmounting ports tree from all jails: " ./umports all > /dev/null echo "Done." 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! |
|
|||
Hmm... now that I've had a chance to play around with it more, there's a few things that can be changed.
For example, the line above that reads Code:
for i in `jls | grep -v "JID" | awk '{print $3}'` Code:
for i in `jls | awk '$1 !~ /JID/ {print $3}'` Code:
jexec -U root `jls | grep $i | awk '{print $1}'` /usr/sbin/pkg_version -v -L '=' Code:
jexec -U root `jls | awk '$3 ~ /'$i'/ {print $1}'` /usr/sbin/pkg_version -v -L '='
__________________
I just saved a bunch of money on my car insurance by fleeing the scene of the accident! Last edited by cajunman4life; 9th May 2008 at 11:52 PM. Reason: Typo |
Thread Tools | |
Display Modes | |
|
|
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 |