Updating jails

Ivailo Tanusheff i.tanusheff at procreditbank.bg
Wed Oct 4 08:08:53 PDT 2006


I may give you a script how to update ports in the jails. You just need to 
have the same ports installed on your base system and build them with 
making a package ready for instalation. Personally I use: 
PACKAGES=/usr/ports/packages /usr/local/sbin/portupgrade -v -i -a -y -p

Then if you have made jails in /usr/local/jails use the following script:

#!/bin/sh

echo "***********************************"
echo "*                                 *"
echo "*    Preparing mount points       *"
echo "*                                 *"
echo "***********************************"

/sbin/mount_nullfs /usr/ports/ /usr/local/jails/<jail1>/usr/ports
/sbin/mount_nullfs /usr/ports/ /usr/local/jails/<jail2>/usr/ports
...
/sbin/mount_nullfs /usr/ports/ /usr/local/jails/<jailn>/usr/ports

echo ""
echo ""
echo "***********************************"
echo "*                                 *"
echo "*    Executing update script      *"
echo "*                                 *"
echo "***********************************"
echo ""
echo ""

for jid in `/usr/sbin/jls | /usr/bin/cut -c 1-6`; do
  if [ $jid != "JID" ]; then
    echo "Updating:"
    echo `/usr/sbin/jls | /usr/bin/grep JID`
    echo `/usr/sbin/jls | /usr/bin/grep " $jid "`
    echo -n "Continue with upgrade [y/n]: "
    read oks
    if [ "x$oks" = "xn" -o "x$oks" = "xN" ]; then
      echo "Skipping JID=$jid"
      echo ""
      echo ""
    else
      /usr/sbin/jexec $jid /usr/local/bin/updateports.sh
    fi
  fi
done


echo ""
echo ""
echo "***********************************"
echo "*                                 *"
echo "*    Removing mount points        *"
echo "*                                 *"
echo "***********************************"
echo ""
echo ""

/sbin/umount /usr/local/jails/<jail1>/usr/ports
/sbin/umount /usr/local/jails/<jail2>/usr/ports
....
/sbin/umount /usr/local/jails/<jailn>/usr/ports


This asks you for updating particular jail and executes 
/usr/local/bin/updateports.sh in each jail (you should copy it in every 
jail). You can use this:

#!/usr/local/bin/bash


echo "************************************************"
echo "*                                              *"
echo "*         Updating indexes                     *"
echo "*                                              *"
echo "************************************************"


/usr/local/sbin/portsdb -u


echo "************************************************"
echo "*                                              *"
echo "*         Fixing database                      *"
echo "*                                              *"
echo "************************************************"



/usr/local/sbin/pkgdb -Fv



echo "************************************************"
echo "*                                              *"
echo "*         Updating ports                       *"
echo "*                                              *"
echo "************************************************"



/usr/local/sbin/portupgrade -v -i -a -y -f -PP


That is what I use in my jails. Hope this will help you :)
Regards,

Ivailo Tanusheff
Deputy Head of IT Department
ProCredit Bank (Bulgaria) AD





futhwo <futhwo at gmail.com> 
Sent by: owner-freebsd-questions at freebsd.org
04.10.2006 16:24

To
FreeBSD Questions <questions at freebsd.org>
cc

Subject
Updating jails






Hi
We have an infrastructure composed by a few physical servers that 
contains some full jails (up to 10 jails per server). I am wondering 
what's the better and fastest way to bring the jails up-to-date when 
a new patchlevel or minor version is released and installed on the 
host system. This method would better be unattended, but it's not a 
requirement.

Hi
Ivan
_______________________________________________
freebsd-questions at freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to 
"freebsd-questions-unsubscribe at freebsd.org"



More information about the freebsd-questions mailing list