source: src-sh/warden/scripts/backend/checkupdates.sh @ 3c28602

9.1-release9.2-releasereleng/10.0releng/10.0.1releng/10.0.2
Last change on this file since 3c28602 was 3c28602, checked in by Kris Moore <kris@…>, 16 months ago
  • Improve PKGNG usage when checking for updates to jails
  • Property mode set to 100755
File size: 2.0 KB
Line 
1#!/bin/sh
2# Script to check for jail updates
3# Args $1 = JAILNAME
4######################################################################
5
6# Source our functions
7PROGDIR="/usr/local/share/warden"
8
9# Source our variables
10. ${PROGDIR}/scripts/backend/functions.sh
11
12JAILNAME="$1"
13
14if [ -z "${JAILNAME}" ]
15then
16  echo "ERROR: You must specify a jail to check"
17  exit 5
18fi
19
20if [ -z "${JDIR}" ]
21then
22  echo "ERROR: JDIR is unset!!!!"
23  exit 5
24fi
25
26JAILDIR="${JDIR}/${JAILNAME}"
27
28if [ ! -d "${JAILDIR}" -a "${JAILNAME}" != "all" ]
29then
30  echo "ERROR: No jail located at ${JAILDIR}"
31  exit 5
32fi
33
34
35# End of error checking, now start update checking
36#####################################################################
37
38# Check for updates
39if [ "${JAILNAME}" = "all" ] ; then
40  cd ${JDIR}
41  for i in `ls -d .*.meta`
42  do
43    JAILNAME=`echo ${i}|sed 's|.meta$||'|sed 's|^.||'`
44    HOST="`cat ${i}/host`"
45    set_warden_metadir
46    if [ -e "${JMETADIR}/jail-linux" ] ; then continue; fi
47
48    echo "Checking for jail updates to ${HOST}"
49    echo "################################################"
50 
51    # Check for pkgng updates
52    if [ -e "${JDIR}/${JAILNAME}/usr/local/sbin/pkg-static" ] ; then
53       chroot "${JDIR}/${JAILNAME}" pkg upgrade -n
54    fi
55
56    # Check for system-updates
57    chroot ${JDIR}/${JAILNAME} cat /usr/sbin/freebsd-update | sed 's|! -t 0|-z '1'|g' | /bin/sh -s 'fetch'
58  done
59else
60  set_warden_metadir
61 
62  if [ -e "${JMETADIR}/jail-linux" ] ; then
63    echo "ERROR: Cannot check for updates to Linux Jails.. Please use any included Linux utilities for your disto."
64    exit 5
65  fi
66
67   echo "Checking for jail updates to ${JAILNAME}..."
68   echo "################################################"
69
70   # Check for pkgng updates
71   if [ -e "${JDIR}/${JAILNAME}/usr/local/sbin/pkg-static" ] ; then
72      chroot "${JDIR}/${JAILNAME}" pkg upgrade -n
73   fi
74
75   # Check for system-updates
76   chroot ${JDIR}/${JAILNAME} cat /usr/sbin/freebsd-update | sed 's|! -t 0|-z '1'|g' | /bin/sh -s 'fetch'
77fi
Note: See TracBrowser for help on using the repository browser.