3 # Update freebsd base of all running jails
5 # one has first to create the suitable configuration file
6 # by default /usr/local/etc/jail-update.conf
7 # or pass it as the first argument
13 echo -e '-c\tconfiguration file'
14 echo -e '\t\tdefault to /usr/local/etc/jail-update.conf'
15 echo -e '-j\tjail list'
16 echo -e '\t\tdefault to all running jails'
17 echo -e '-u\tthis message'
18 echo '-------------------------------------------------'
23 NC='\033[0m' # No Color
24 while getopts "cuj:" option
42 CONF=/usr/local/etc/jail-update.conf
43 # get currently running names (or jids) list
44 JLIST=`jls name 2>/dev/null`
48 [ -z "${JLIST}" ] && echo 'no jail to check.exiting.' && exit 0
49 [ ! -r "${CONF}" ] && echo 'no configuration file for updating.exiting.' && exit 1
52 echo 'Ready to update jail(s) <'${JLIST}'>, according to the <'${CONF}'> configuration.'
58 JPATH=`jls -j ${J} path 2>/dev/null`
59 if [ -n "${JPATH}" ]; then
60 echo '[ :: ' $J ' ::]'
61 # freebsd version this jail is running
62 JVERSION=`jexec ${J} freebsd-version -u`
63 if [ -n "${JVERSION}" ]; then
64 echo 'Updating <'${J}'> from version <'${JVERSION}'>, path <'${JPATH}'>.'
65 freebsd-update -f ${CONF} --currently-running ${JVERSION} -b ${JPATH} fetch install
68 echo 'Unable to get jail <'${J}'> path.Skipping'
73 echo 'Jail <'${J}'> unavailable.Skipping.'