Changeset 4905ba9


Ignore:
Timestamp:
Jun 26, 2014 11:45:22 AM (2 weeks ago)
Author:
Kris Moore <kris@…>
Branches:
master
Children:
64c397b
Parents:
75b0622
Message:

Remove much of the legacy UFS cruft which was still present in Warden

It will *require* ZFS going forward, which has been the default on PC-BSD for
a while now

Location:
src-sh/warden
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src-sh/warden/bin/warden

    r9b97c0b r4905ba9  
    577577# Fix old style meta-data, can be removed after 9.1 
    578578fix_old_meta 
     579 
     580# This checks if we have JDIR on a valid ZFS dataset 
     581zfs_prog_check 
    579582 
    580583# Check what the user wants to do 
  • src-sh/warden/scripts/backend/createjail.sh

    raba3187 r4905ba9  
    100100 
    101101  # See if we need to create a new template for this system 
    102   isDirZFS "${JDIR}" 
    103   if [ $? -eq 0 ] ; then 
    104      TDIR="${JDIR}/.warden-template-$DEFTEMPLATE" 
    105   else 
    106      TDIR="${JDIR}/.warden-template-$DEFTEMPLATE.tbz" 
    107   fi 
     102  TDIR="${JDIR}/.warden-template-$DEFTEMPLATE" 
    108103  if [ ! -e "$TDIR" ] ; then 
    109104      FLAGS="-arch $ARCH -nick $DEFTEMPLATE" 
     
    133128  # Set WORLDCHROOT to the dir we will clone / file to extract 
    134129  WORLDCHROOT="${JDIR}/.warden-template-$TEMPLATE" 
    135   isDirZFS "${JDIR}" 
    136   if [ $? -ne 0 ] ; then 
    137     WORLDCHROOT="${WORLDCHROOT}.tbz" 
    138   fi 
    139130else  
    140131   # See if we are overriding the default archive file 
     
    193184# If we are setting up a linux jail, lets do it now 
    194185if [ "$LINUXJAIL" = "YES" ] ; then 
    195    isDirZFS "${JDIR}" 
    196    if [ $? -eq 0 ] ; then 
    197      # Create ZFS mount 
    198      tank=`getZFSTank "$JDIR"` 
    199      if [ -z "$tank" ] ; then 
    200        exit_err "Failed getting ZFS dataset for $JDIR.."; 
    201      fi 
    202      zfs create -o mountpoint=${JAILDIR} -p ${tank}${JAILDIR} 
    203      if [ $? -ne 0 ] ; then exit_err "Failed creating ZFS dataset"; fi 
    204    else 
    205      mkdir -p "${JAILDIR}" 
     186   # Create ZFS mount 
     187   tank=`getZFSTank "$JDIR"` 
     188   if [ -z "$tank" ] ; then 
     189     exit_err "Failed getting ZFS dataset for $JDIR.."; 
    206190   fi 
     191   zfs create -o mountpoint=${JAILDIR} -p ${tank}${JAILDIR} 
     192   if [ $? -ne 0 ] ; then exit_err "Failed creating ZFS dataset"; fi 
    207193   setup_linux_jail 
    208194   exit 0 
     
    211197echo "Building new Jail... Please wait..." 
    212198 
    213 isDirZFS "${JDIR}" 
    214 if [ $? -eq 0 ] ; then 
    215    # Create ZFS CLONE 
    216    tank=`getZFSTank "$JDIR"` 
    217    zfsp=`getZFSRelativePath "${WORLDCHROOT}"` 
    218    jailp=`getZFSRelativePath "${JAILDIR}"` 
    219    zfs clone ${tank}${zfsp}@clean ${tank}${jailp} 
    220    if [ $? -ne 0 ] ; then exit_err "Failed creating clean ZFS base clone"; fi 
    221 else 
    222    # Running on UFS 
    223    mkdir -p "${JAILDIR}" 
    224    echo "Installing world..." 
    225    if [ -d "${WORLDCHROOT}" ] ; then 
    226      tar cvf - -C ${WORLDCHROOT} . 2>/dev/null | tar xpvf - -C "${JAILDIR}" 2>/dev/null 
    227    else 
    228      tar xvf ${WORLDCHROOT} -C "${JAILDIR}" 2>/dev/null 
    229    fi 
    230  
    231    # If this is a pluginjail on UFS :-( Do things the hard way. 
    232    if [ "${PLUGINJAIL}" = "YES" ] ; then 
    233      bootstrap_pkgng "${pjdir}" "pluginjail" 
    234    fi 
    235  
    236    echo "Done" 
    237 fi 
     199# Create ZFS CLONE 
     200tank=`getZFSTank "$JDIR"` 
     201zfsp=`getZFSRelativePath "${WORLDCHROOT}"` 
     202jailp=`getZFSRelativePath "${JAILDIR}"` 
     203zfs clone ${tank}${zfsp}@clean ${tank}${jailp} 
     204if [ $? -ne 0 ] ; then exit_err "Failed creating clean ZFS base clone"; fi 
    238205 
    239206mkdir ${JMETADIR} 
  • src-sh/warden/scripts/backend/createtemplate.sh

    rb5dbe14 r4905ba9  
    7878create_template() 
    7979{ 
    80   # Creating ZFS dataset? 
    81   isDirZFS "${JDIR}" 
    82   if [ $? -eq 0 ] ; then 
    83     local zfsp=`getZFSRelativePath "${TDIR}"` 
     80  local zfsp=`getZFSRelativePath "${TDIR}"` 
    8481 
    85     # Use ZFS base for cloning 
    86     tank=`getZFSTank "${JDIR}"` 
    87     isDirZFS "${TDIR}" "1" 
    88     if [ $? -ne 0 ] ; then 
    89        echo "Creating ZFS ${TDIR} dataset..." 
    90        zfs create -o mountpoint=${TDIR} -p ${tank}${zfsp} 
    91        if [ $? -ne 0 ] ; then exit_err "Failed creating ZFS base dataset"; fi 
    92     fi 
     82  # Use ZFS base for cloning 
     83  tank=`getZFSTank "${JDIR}"` 
     84  isDirZFS "${TDIR}" "1" 
     85  if [ $? -ne 0 ] ; then 
     86     echo "Creating ZFS ${TDIR} dataset..." 
     87     zfs create -o mountpoint=${TDIR} -p ${tank}${zfsp} 
     88     if [ $? -ne 0 ] ; then exit_err "Failed creating ZFS base dataset"; fi 
     89  fi 
    9390 
    94     # Using a supplied tar file? 
    95     if [ -n "$FBSDTAR" ] ; then 
    96       tar xvpf $FBSDTAR -C ${TDIR} 2>/dev/null 
    97       if [ $? -ne 0 ] ; then exit_err "Failed extracting: $FBSDTAR"; fi 
    98     elif [ "$oldFBSD" = "YES" ] ; then 
    99       cd ${JDIR}/.download/ 
    100       cat ${oldStr}.?? | tar --unlink -xpzf - -C ${TDIR} 2>/dev/null 
    101       cd ${JDIR} 
    102     else 
    103       # Extract the dist files 
    104       for f in $DFILES 
    105       do 
    106         tar xvpf ${JDIR}/.download/$f -C ${TDIR} 2>/dev/null 
    107         if [ $? -ne 0 ] ; then exit_err "Failed extracting ZFS template environment"; fi 
    108         rm ${JDIR}/.download/${f} 
    109       done 
    110     fi 
     91  # Using a supplied tar file? 
     92  if [ -n "$FBSDTAR" ] ; then 
     93    tar xvpf $FBSDTAR -C ${TDIR} 2>/dev/null 
     94    if [ $? -ne 0 ] ; then exit_err "Failed extracting: $FBSDTAR"; fi 
     95  elif [ "$oldFBSD" = "YES" ] ; then 
     96    cd ${JDIR}/.download/ 
     97    cat ${oldStr}.?? | tar --unlink -xpzf - -C ${TDIR} 2>/dev/null 
     98    cd ${JDIR} 
     99  else 
     100    # Extract the dist files 
     101    for f in $DFILES 
     102    do 
     103      tar xvpf ${JDIR}/.download/$f -C ${TDIR} 2>/dev/null 
     104      if [ $? -ne 0 ] ; then exit_err "Failed extracting ZFS template environment"; fi 
     105      rm ${JDIR}/.download/${f} 
     106    done 
     107  fi 
    111108 
    112     # Creating a plugin jail? 
    113     if [ "$TPLUGJAIL" = "YES" ] ; then 
    114       cp /etc/resolv.conf ${TDIR}/etc/resolv.conf 
    115       bootstrap_pkgng "${TDIR}" "pluginjail" 
    116     fi 
     109  # Creating a plugin jail? 
     110  if [ "$TPLUGJAIL" = "YES" ] ; then 
     111    cp /etc/resolv.conf ${TDIR}/etc/resolv.conf 
     112    bootstrap_pkgng "${TDIR}" "pluginjail" 
     113  fi 
    117114 
    118     zfs snapshot ${tank}${zfsp}@clean 
    119     if [ $? -ne 0 ] ; then exit_err "Failed creating clean ZFS base snapshot"; fi 
    120   else 
    121     # Sigh, still on UFS?? 
    122     if [ -d "${JDIR}/.templatedir" ]; then 
    123        chflags -R noschg ${JDIR}/.templatedir 
    124        rm -rf ${JDIR}/.templatedir 
    125     fi 
    126  
    127     if [ -n "$FBSDTAR" ] ; then 
    128       # User-supplied tar file  
    129       cp $FBSDTAR ${TDIR} 
    130     elif [ "$oldFBSD" = "YES" ] ; then 
    131       mkdir ${JDIR}/.templatedir 
    132       cd ${JDIR}/.download/ 
    133       echo "Extrating FreeBSD..." 
    134       cat ${oldStr}.?? | tar --unlink -xpzf - -C ${JDIR}/.templatedir 2>/dev/null 
    135       if [ $? -ne 0 ] ; then exit_err "Failed to extract FreeBSD" ; fi 
    136       cd ${JDIR} 
    137  
    138       # Creating a plugin jail? 
    139       if [ "$TPLUGJAIL" = "YES" ] ; then 
    140         cp /etc/resolv.conf ${JDIR}/.templatedir/etc/resolv.conf 
    141         bootstrap_pkgng "${JDIR}/.templatedir/" "pluginjail" 
    142       fi 
    143  
    144       echo "Creating template archive..." 
    145       tar cvjf ${TDIR} -C ${JDIR}/.templatedir 2>/dev/null 
    146       chflags -R noschg ${JDIR}/.templatedir 
    147       rm -rf ${JDIR}/.templatedir 
    148     else 
    149       # Extract the dist files 
    150       mkdir ${JDIR}/.templatedir 
    151       for f in $DFILES 
    152       do 
    153         tar xvpf ${JDIR}/.download/$f -C ${JDIR}/.templatedir 2>/dev/null 
    154         if [ $? -ne 0 ] ; then  
    155            rm -rf ${JDIR}/.templatedir 
    156            exit_err "Failed extracting template environment" 
    157         fi 
    158         rm ${JDIR}/.download/${f} 
    159       done 
    160  
    161       # Creating a plugin jail? 
    162       if [ "$TPLUGJAIL" = "YES" ] ; then 
    163         cp /etc/resolv.conf ${JDIR}/.templatedir/etc/resolv.conf 
    164         bootstrap_pkgng "${JDIR}/.templatedir/" "pluginjail" 
    165       fi 
    166  
    167       echo "Creating template archive..." 
    168       tar cvjf ${TDIR} -C ${JDIR}/.templatedir . 2>/dev/null 
    169       if [ $? -ne 0 ] ; then  
    170          chflags -R noschg ${JDIR}/.templatedir 
    171          rm -rf ${JDIR}/.templatedir 
    172          exit_err "Failed creating template environment" 
    173       fi 
    174       chflags -R noschg ${JDIR}/.templatedir 
    175       rm -rf ${JDIR}/.templatedir 
    176     fi 
    177   fi # End of UFS section 
     115  zfs snapshot ${tank}${zfsp}@clean 
     116  if [ $? -ne 0 ] ; then exit_err "Failed creating clean ZFS base snapshot"; fi 
    178117 
    179118  rm -rf ${JDIR}/.download 
     
    195134# Set the template directory 
    196135TDIR="${JDIR}/.warden-template-$TNICK" 
    197  
    198 # Set the name based upon if using ZFS or UFS 
    199 isDirZFS "${JDIR}" 
    200 if [ $? -eq 0 ] ; then 
    201   TDIR="${TDIR}" 
    202 else 
    203   TDIR="${TDIR}.tbz" 
    204 fi 
    205136 
    206137# Make sure this template is available 
  • src-sh/warden/scripts/backend/functions.sh

    rd2b5358 r4905ba9  
    8888    printerror "Error in download data, checksum mismatch. Please try again later." 
    8989 
    90   # Creating ZFS dataset? 
    91   isDirZFS "${JDIR}" 
    92   if [ $? -eq 0 ] ; then 
    93     local zfsp=`getZFSRelativePath "${WORLDCHROOT}"` 
    94  
    95     # Use ZFS base for cloning 
    96     echo "Creating ZFS ${WORLDCHROOT} dataset..." 
    97     tank=`getZFSTank "${JDIR}"` 
    98     isDirZFS "${WORLDCHROOT}" "1" 
    99     if [ $? -ne 0 ] ; then 
    100        zfs create -o mountpoint=/${tank}${zfsp} -p ${tank}${zfsp} 
    101        if [ $? -ne 0 ] ; then exit_err "Failed creating ZFS base dataset"; fi 
    102        mkdir -p "${WORLDCHROOT}/.plugins" >/dev/null 2>&1 
    103     fi 
    104  
    105     pbi_add -e --no-checksig -p ${WORLDCHROOT} ${PJAIL} 
    106     if [ $? -ne 0 ] ; then exit_err "Failed extracting ZFS chroot environment"; fi 
    107  
    108     zfs snapshot ${tank}${zfsp}@clean 
    109     if [ $? -ne 0 ] ; then exit_err "Failed creating clean ZFS base snapshot"; fi 
    110     rm ${PJAIL} 
    111   else 
    112     # Save the chroot tarball 
    113     mv ${PJAIL} ${WORLDCHROOT} 
    114   fi 
     90  local zfsp=`getZFSRelativePath "${WORLDCHROOT}"` 
     91 
     92  # Use ZFS base for cloning 
     93  echo "Creating ZFS ${WORLDCHROOT} dataset..." 
     94  tank=`getZFSTank "${JDIR}"` 
     95  isDirZFS "${WORLDCHROOT}" "1" 
     96  if [ $? -ne 0 ] ; then 
     97     zfs create -o mountpoint=/${tank}${zfsp} -p ${tank}${zfsp} 
     98     if [ $? -ne 0 ] ; then exit_err "Failed creating ZFS base dataset"; fi 
     99     mkdir -p "${WORLDCHROOT}/.plugins" >/dev/null 2>&1 
     100  fi 
     101 
     102  pbi_add -e --no-checksig -p ${WORLDCHROOT} ${PJAIL} 
     103  if [ $? -ne 0 ] ; then exit_err "Failed extracting ZFS chroot environment"; fi 
     104 
     105  zfs snapshot ${tank}${zfsp}@clean 
     106  if [ $? -ne 0 ] ; then exit_err "Failed creating clean ZFS base snapshot"; fi 
     107  rm ${PJAIL} 
    115108  rm ${PJAILSHA256} 
    116109}; 
     
    150143    printerror "Error in download data, checksum mismatch. Please try again later." 
    151144 
    152   # Creating ZFS dataset? 
    153   isDirZFS "${JDIR}" 
    154   if [ $? -eq 0 ] ; then 
    155     local zfsp=`getZFSRelativePath "${CHROOT}"` 
    156  
    157     # Use ZFS base for cloning 
    158     echo "Creating ZFS ${CHROOT} dataset..." 
    159     tank=`getZFSTank "${JDIR}"` 
    160     isDirZFS "${CHROOT}" "1" 
    161     if [ $? -ne 0 ] ; then 
    162        zfs create -o mountpoint=/${tank}${zfsp} -p ${tank}${zfsp} 
    163        if [ $? -ne 0 ] ; then exit_err "Failed creating ZFS base dataset"; fi 
    164     fi 
    165  
    166     tar xvpf ${FBSD_TARBALL} -C ${CHROOT} 2>/dev/null 
    167     if [ $? -ne 0 ] ; then exit_err "Failed extracting ZFS chroot environment"; fi 
    168  
    169     zfs snapshot ${tank}${zfsp}@clean 
    170     if [ $? -ne 0 ] ; then exit_err "Failed creating clean ZFS base snapshot"; fi 
    171     rm ${FBSD_TARBALL} 
    172   else 
    173     # Save the chroot tarball 
    174     mv ${FBSD_TARBALL} ${CHROOT} 
    175   fi 
     145  local zfsp=`getZFSRelativePath "${CHROOT}"` 
     146 
     147  # Use ZFS base for cloning 
     148  echo "Creating ZFS ${CHROOT} dataset..." 
     149  tank=`getZFSTank "${JDIR}"` 
     150  isDirZFS "${CHROOT}" "1" 
     151  if [ $? -ne 0 ] ; then 
     152     zfs create -o mountpoint=/${tank}${zfsp} -p ${tank}${zfsp} 
     153     if [ $? -ne 0 ] ; then exit_err "Failed creating ZFS base dataset"; fi 
     154  fi 
     155 
     156  tar xvpf ${FBSD_TARBALL} -C ${CHROOT} 2>/dev/null 
     157  if [ $? -ne 0 ] ; then exit_err "Failed extracting ZFS chroot environment"; fi 
     158 
     159  zfs snapshot ${tank}${zfsp}@clean 
     160  if [ $? -ne 0 ] ; then exit_err "Failed creating clean ZFS base snapshot"; fi 
     161  rm ${FBSD_TARBALL} 
    176162  rm ${FBSD_TARBALL_CKSUM} 
    177163}; 
     
    11151101   echo "Jail Templates:" 
    11161102   echo "------------------------------"  
    1117    isDirZFS "${JDIR}" 
    1118    if [ $? -eq 0 ] ; then 
    1119      for i in `ls -d ${JDIR}/.warden-template* 2>/dev/null` 
    1120      do  
    1121         if [ ! -e "$i/bin/sh" ] ; then continue ; fi 
    1122         NICK=`echo "$i" | sed "s|${JDIR}/.warden-template-||g"` 
    1123         file "$i/bin/sh" 2>/dev/null | grep -q "64-bit" 
    1124         if [ $? -eq 0 ] ; then 
    1125            ARCH="amd64" 
    1126         else 
    1127            ARCH="i386" 
    1128         fi 
    1129         VER=`file "$i/bin/sh" | cut -d ',' -f 5 | awk '{print $3}'` 
    1130         if [ -e "$i/etc/rc.conf.pcbsd" ] ; then 
    1131            TYPE="TrueOS" 
    1132         else 
    1133            TYPE="FreeBSD" 
    1134         fi 
    1135         echo -e "${NICK} - $TYPE $VER ($ARCH)" 
    1136      done 
    1137    else 
    1138      # UFS, no details for U! 
    1139      ls ${JDIR}/.warden-template*.tbz | sed "s|${JDIR}/.warden-template-||g" | sed "s|.tbz||g" 
    1140    fi 
    1141    exit 0 
     1103   for i in `ls -d ${JDIR}/.warden-template* 2>/dev/null` 
     1104   do  
     1105     if [ ! -e "$i/bin/sh" ] ; then continue ; fi 
     1106     NICK=`echo "$i" | sed "s|${JDIR}/.warden-template-||g"` 
     1107     file "$i/bin/sh" 2>/dev/null | grep -q "64-bit" 
     1108     if [ $? -eq 0 ] ; then 
     1109        ARCH="amd64" 
     1110     else 
     1111        ARCH="i386" 
     1112     fi 
     1113     VER=`file "$i/bin/sh" | cut -d ',' -f 5 | awk '{print $3}'` 
     1114     if [ -e "$i/etc/rc.conf.pcbsd" ] ; then 
     1115        TYPE="TrueOS" 
     1116     else 
     1117        TYPE="FreeBSD" 
     1118     fi 
     1119     echo -e "${NICK} - $TYPE $VER ($ARCH)" 
     1120  done 
     1121  exit 0 
    11421122} 
    11431123 
     
    11451125{ 
    11461126   tDir="${JDIR}/.warden-template-${1}" 
    1147    isDirZFS "${JDIR}" 
    1148    if [ $? -eq 0 ] ; then 
    1149      isDirZFS "${tDir}" "1" 
    1150      if [ $? -ne 0 ] ; then printerror "Not a ZFS volume: ${tDir}" ; fi 
    1151      tank=`getZFSTank "$tDir"` 
    1152      rp=`getZFSRelativePath "$tDir"` 
    1153      zfs destroy -r $tank${rp}  
    1154      if [ $? -ne 0 ] ; then 
    1155        exit_err "Could not remove template, perhaps you have jails still using it?" 
    1156      fi 
    1157      rmdir ${tDir} 
    1158    else 
    1159      if [ ! -e "${tDir}.tbz" ] ; then 
    1160        exit_err "No such template: ${1}" 
    1161      fi 
    1162      rm ${tDir}.tbz 
    1163    fi 
     1127   isDirZFS "${tDir}" "1" 
     1128   if [ $? -ne 0 ] ; then printerror "Not a ZFS volume: ${tDir}" ; fi 
     1129   tank=`getZFSTank "$tDir"` 
     1130   rp=`getZFSRelativePath "$tDir"` 
     1131   zfs destroy -r $tank${rp}  
     1132   if [ $? -ne 0 ] ; then 
     1133     exit_err "Could not remove template, perhaps you have jails still using it?" 
     1134   fi 
     1135   rmdir ${tDir} 
    11641136   echo "DONE" 
    11651137 
     
    12261198 
    12271199} 
     1200 
     1201zfs_prog_check() { 
     1202 
     1203   isDirZFS "${JDIR}" 
     1204   if [ $? -ne 0 ] ; then 
     1205      echo "WARNING: JDIR is NOT set to a ZFS managed dataset.." 
     1206      echo "Please change JDIR in /usr/local/etc/warden.conf to a ZFS dataset!" 
     1207   fi 
     1208 
     1209} 
Note: See TracChangeset for help on using the changeset viewer.