Update multiple jails together

Hi,

I have a bunch of jails running. Each time they need an update, I have to login in them individually and run pkg update; pkg upgrade

Is there a way to run the pkg update; pkg upgrade in one go on all the jails from the host?

Thanks
 
If you follow the ondra_knezour advice, it should give you something like the following :
Code:
#! /bin/sh
jail_ids=$(jls -h jid | grep -v jid)
echo "Starting upgrading jails..."
for x in $jail_ids ; do
  echo "jail id : $x"
  pkg -j $x upgrade
done
 
This code works fine. The only issue I have is that some of my jails use different gateways so I need to specify the fib number like this:
setfib 1 pkg -j $x upgrade

Is there anyway to find out what fib is a particular jail is using except extracting it from the config file in /usr/local/etc/ezjail/ ?
 
Ultima on irc came up with the following script. The fib numbers should match the jails.

Code:
#!/bin/sh
jails="jail1 jail2 jail3"
fib="0 1 2"
dollarsign="$"
pos="1"
for j in ${jails}; do
   f=`echo $fib | awk "{ print $dollarsign$pos }"`
   setfib $f jexec $j pkg upgrade -y
   setfib $f jexec $j pkg autoremove -y
   setfib $f jexec $j pkg clean -y
   pos=$(( $pos + 1 ))
done
 
Back
Top