Ignore:
Timestamp:
Apr 15, 2013 1:06:48 PM (12 months ago)
Author:
Kris Moore <kris@…>
Branches:
master, 9.1-release, 9.2-release, releng/10.0, releng/10.0.1
Children:
8901c47
Parents:
4d2a365
Message:

Merge changes from John Hixson and FreeNAS work

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src-sh/warden/scripts/backend/createjail.sh

    r90a056e r17235d6  
    2323  fi 
    2424 
    25   if [ "$STARTUP" = "YES" ] ; then 
     25  if [ "$AUTOSTART" = "YES" ] ; then 
    2626    touch "${JMETADIR}/autostart" 
    2727  fi 
     
    6969 
    7070  # If we are auto-starting the jail, do it now 
    71   if [ "$STARTUP" = "YES" ] ; then warden start ${JAILNAME} ; fi 
     71  if [ "$AUTOSTART" = "YES" ] ; then warden start ${JAILNAME} ; fi 
    7272 
    7373  echo "Success! Linux jail created at ${JAILDIR}" 
     
    8787esac 
    8888 
    89 if [ -z "${VERSION}" -a -e "/etc/version" ] ; then VERSION=`cat /etc/version`; fi 
    90  
    9189# Location of the chroot environment 
    9290isDirZFS "${JDIR}" 
    9391if [ $? -eq 0 ] ; then 
    94   if [ "${PLUGINJAIL}" = "YES" ] ; then 
    95     WORLDCHROOT="${JDIR}/.warden-pj-chroot-${ARCH}" 
    96   else 
    97     WORLDCHROOT="${JDIR}/.warden-chroot-${ARCH}" 
    98   fi 
    99   export WORLDCHROOT 
     92  WORLDCHROOT_PLUGINJAIL="${JDIR}/.warden-pj-chroot-${ARCH}" 
     93  WORLDCHROOT_STANDARD="${JDIR}/.warden-chroot-${ARCH}" 
    10094else 
    101   if [ "${PLUGINJAIL}" = "YES" ] ; then 
    102     WORLDCHROOT="${JDIR}/.warden-pj-chroot-${ARCH}.tbz" 
    103   else 
    104     WORLDCHROOT="${JDIR}/.warden-chroot-${ARCH}.tbz" 
    105   fi 
    106   export WORLDCHROOT 
    107 fi 
     95  WORLDCHROOT_PLUGINJAIL="${JDIR}/.warden-pj-chroot-${ARCH}.tbz" 
     96  WORLDCHROOT_STANDARD="${JDIR}/.warden-chroot-${ARCH}.tbz" 
     97fi 
     98if [ "${PLUGINJAIL}" = "YES" ] ; then 
     99  WORLDCHROOT="${WORLDCHROOT_PLUGINJAIL}" 
     100else 
     101  WORLDCHROOT="${WORLDCHROOT_STANDARD}" 
     102fi 
     103export WORLDCHROOT WORLDCHROOT_PLUGINJAIL WORLDCHROOT_STANDARD 
    108104 
    109105if [ "${IP4}" != "OFF" ] ; then 
     
    118114  IP6="${JIP}" 
    119115  MASK6="${JMASK}" 
    120   if [ -z "$MASK4" ] ; then MASK6="64"; fi 
     116  if [ -z "$MASK6" ] ; then MASK6="64"; fi 
    121117fi 
    122118 
     
    126122fi 
    127123 
    128 if [ -z "${HOST}" -o -z "$SOURCE" -o -z "${PORTS}" -o -z "${STARTUP}" ]  
    129 then 
    130   if [ -z "$HOST" ] ; then 
    131      echo "ERROR: Missing hostname!" 
    132   else 
    133      echo "ERROR: Missing required data!" 
    134   fi 
    135  
    136   exit 6 
     124if [ -z "$HOST" ] ; then 
     125   echo "ERROR: Missing hostname!" 
     126   exit 6 
    137127fi 
    138128 
     
    168158 
    169159# Check if we need to download the chroot file 
     160 
     161# 
     162# If this is a pluginjail, we clone a regular freebsd chroot, then we 
     163# bootstrap packageng, install the required packages that a pluginjail 
     164# needs, then snapshot it. Once this is done, creating a pluginjail is 
     165# as easy as doing a zfs clone. 
     166# 
    170167if [ "${PLUGINJAIL}" = "YES" -a ! -e "${WORLDCHROOT}" ] ; then 
    171   downloadpluginjail "${VERSION}" 
     168  if [ ! -e "${WORLDCHROOT_STANDARD}" ] ; then 
     169    downloadchroot "${WORLDCHROOT_STANDARD}" 
     170  fi 
     171 
     172  isDirZFS "${JDIR}" 
     173  if [ $? -eq 0 ] ; then 
     174    tank=`getZFSTank "$JDIR"` 
     175    zfsp=`getZFSRelativePath "${WORLDCHROOT_STANDARD}"` 
     176    clonep="/$(basename ${WORLDCHROOT_PLUGINJAIL})" 
     177 
     178    mnt=`getZFSMountpoint ${tank}` 
     179    pjdir="${mnt}${clonep}" 
     180 
     181    zfs clone ${tank}${zfsp}@clean ${tank}${clonep} 
     182    if [ $? -ne 0 ] ; then exit_err "Failed creating clean ZFS pluginjail clone"; fi 
     183 
     184    cp /etc/resolv.conf ${pjdir}/etc/resolv.conf 
     185 
     186    bootstrap_pkgng "${pjdir}" "pluginjail" 
     187 
     188    zfs snapshot ${tank}${clonep}@clean 
     189    if [ $? -ne 0 ] ; then exit_err "Failed creating clean ZFS pluginjail snapshot"; fi 
     190 
     191  # We're on UFS :-( 
     192  else 
     193    downloadchroot "${WORLDCHROOT_STANDARD}" 
     194 
     195  fi 
    172196 
    173197elif [ ! -e "${WORLDCHROOT}" -a "${LINUXJAIL}" != "YES" ] ; then 
    174   downloadchroot 
     198  downloadchroot "${WORLDCHROOT}" 
    175199fi 
    176200 
     
    212236     tar xvf ${WORLDCHROOT} -C "${JAILDIR}" 2>/dev/null 
    213237   fi 
     238 
     239   # If this is a pluginjail on UFS :-( Do things the hard way. 
     240   if [ "${PLUGINJAIL}" = "YES" ] ; then 
     241     bootstrap_pkgng "${pjdir}" "pluginjail" 
     242   fi 
     243 
    214244   echo "Done" 
    215245fi 
     
    286316 
    287317  if [ "${IP4}" != "OFF" ] ; then 
    288     echo "${IP4}                        ${HOST}" > "${JAILDIR}/etc/hosts" 
     318    echo "${IP4}                        ${HOST}" >> "${JAILDIR}/etc/hosts" 
    289319  fi 
    290320  if [ "${IP6}" != "OFF" ] ; then 
    291     echo "${IP6}                        ${HOST}" > "${JAILDIR}/etc/hosts" 
     321    echo "${IP6}                        ${HOST}" >> "${JAILDIR}/etc/hosts" 
    292322    sed -i '' "s|#ListenAddress ::|ListenAddress ${IP6}|g" ${JAILDIR}/etc/ssh/sshd_config 
    293323  fi 
     
    298328fi # End of ARCHIVEFILE check 
    299329 
    300 if [ "$STARTUP" = "YES" ] ; then 
     330if [ "$AUTOSTART" = "YES" ] ; then 
    301331  touch "${JMETADIR}/autostart" 
    302332fi 
     
    314344  bootstrap_pkgng "${JAILDIR}" 
    315345  if [ $? -ne 0 ] ; then 
    316      echo "You can manually re-try by running # warden bspkgng ${IP}" 
     346     echo "You can manually re-try by running # warden bspkgng ${JAILNAME}" 
    317347  fi 
    318348fi 
     
    332362 
    333363# If we are auto-starting the jail, do it now 
    334 if [ "$STARTUP" = "YES" ] ; then warden start ${JAILNAME} ; fi 
     364if [ "$AUTOSTART" = "YES" ] ; then warden start ${JAILNAME} ; fi 
    335365 
    336366echo "Success!" 
Note: See TracChangeset for help on using the changeset viewer.