Changeset 0e61329


Ignore:
Timestamp:
11/07/13 08:42:13 (9 months ago)
Author:
Kris Moore <kris@…>
Branches:
9.2-release
Children:
02d7a86
Parents:
6abb585
Message:

Backport fix for warden jail exporting

File:
1 edited

Legend:

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

    r1620346 r0e61329  
    99. ${PROGDIR}/scripts/backend/functions.sh 
    1010 
     11EXPORTNAME="$1" 
    1112JAILNAME="$1" 
    1213OUTDIR="$2" 
    1314 
    14 if [ -z "${JAILNAME}" ] 
     15if [ -z "${EXPORTNAME}" ] 
    1516then 
    16   echo "ERROR: No jail specified to chroot into!" 
     17  echo "ERROR: No jail specified to export!" 
    1718  exit 5 
    1819fi 
     
    2425fi 
    2526 
    26 JAILDIR="${JDIR}/${JAILNAME}" 
     27JAILDIR="${JDIR}/${EXPORTNAME}" 
    2728 
    2829if [ ! -d "${JAILDIR}" ] 
     
    3536 
    3637# First check if this jail is running, and stop it 
    37 ${PROGDIR}/scripts/backend/checkstatus.sh "${JAILNAME}" 
     38${PROGDIR}/scripts/backend/checkstatus.sh "${EXPORTNAME}" 
    3839if [ "$?" = "0" ] 
    3940then 
    40   ${PROGDIR}/scripts/backend/stopjail.sh "${JAILNAME}" 
     41  ${PROGDIR}/scripts/backend/stopjail.sh "${EXPORTNAME}" 
    4142fi 
     43 
     44# Reset JAILDIR 
     45JAILNAME="$1" 
     46JAILDIR="${JDIR}/${EXPORTNAME}" 
     47set_warden_metadir 
    4248 
    4349# Now that the jail is stopped, lets make a large tbz file of it 
     
    5864MASK6="${JMASK}" 
    5965 
    60 echo "Creating compressed archive of ${JAILNAME}... Please Wait..." >&1 
    61 tar cvJf "${WTMP}/${JAILNAME}.tlz" -C "${JAILDIR}" . 2>${WTMP}/${JAILNAME}.files 
     66echo "Creating compressed archive of ${EXPORTNAME}... Please Wait..." >&1 
     67tar cvJf "${WTMP}/${EXPORTNAME}.txz" -C "${JAILDIR}" . 2>${WTMP}/${EXPORTNAME}.files 
    6268 
    6369cd ${WTMP} 
    6470 
    65 LINES="`wc -l ${JAILNAME}.files | sed -e 's, ,,g' | cut -d '.' -f 1`" 
     71LINES="`wc -l ${EXPORTNAME}.files | sed -e 's, ,,g' | cut -d '.' -f 1`" 
    6672 
    6773# Finished, now make the header info 
     
    7480IP6: ${IP6}/${MASK6} 
    7581HOST: ${HOST} 
    76 " >${WTMP}/${JAILNAME}.header 
     82" >${WTMP}/${EXPORTNAME}.header 
    7783 
    7884# Copy over jail extra meta-data 
     
    8086 
    8187# Compress the header file 
    82 tar cvzf ${JAILNAME}.header.tgz ${JAILNAME}.header jail-* 2>/dev/null 
     88tar cvzf ${EXPORTNAME}.header.tgz ${EXPORTNAME}.header jail-* 2>/dev/null 
    8389 
    8490# Create our spacer 
     
    8793 
    8894# Make the .wdn file now 
    89 cat ${JAILNAME}.header.tgz .spacer ${JAILNAME}.tlz > ${JAILNAME}.wdn 
     95cat ${EXPORTNAME}.header.tgz .spacer ${EXPORTNAME}.txz > ${EXPORTNAME}.wdn 
    9096 
    9197# Remove the old files 
    92 rm ${JAILNAME}.header 
    93 rm ${JAILNAME}.files 
    94 rm ${JAILNAME}.tlz 
     98rm ${EXPORTNAME}.header 
     99rm ${EXPORTNAME}.files 
     100rm ${EXPORTNAME}.txz 
    95101rm .spacer 
    96 rm ${JAILNAME}.header.tgz 
     102rm ${EXPORTNAME}.header.tgz 
    97103 
    98104# Remove any extra jail meta-files from WTMP 
     
    106112then 
    107113  mkdir -p ${OUTDIR} 2>/dev/null 
    108   mv ${JAILNAME}.wdn ${OUTDIR}/ 
    109   echo "Created ${JAILNAME}.wdn in ${OUTDIR}" >&1 
     114  mv ${EXPORTNAME}.wdn ${OUTDIR}/ 
     115  echo "Created ${EXPORTNAME}.wdn in ${OUTDIR}" >&1 
    110116else  
    111   echo "Created ${JAILNAME}.wdn in ${WTMP}" >&1 
     117  echo "Created ${EXPORTNAME}.wdn in ${WTMP}" >&1 
    112118fi 
    113119 
Note: See TracChangeset for help on using the changeset viewer.