Changeset 8a1ef9e


Ignore:
Timestamp:
09/15/13 19:24:50 (11 months ago)
Author:
Kris Moore <kris@…>
Branches:
master, 9.2-release, releng/10.0, releng/10.0.1, releng/10.0.2
Children:
6144235
Parents:
e5240d6
Message:

Fix a bug importing warden jails, make sure to use the embedded
hostname when the user doesn't supply one via the CLI

File:
1 edited

Legend:

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

    r1620346 r8a1ef9e  
    2424  IP6="${JIP}" 
    2525  MASK6="${JMASK}" 
     26fi 
     27 
     28# Lets start importing the jail now 
     29###################################################################### 
     30 
     31 
     32chk=`echo "${IFILE}" | cut -c 1-1` 
     33if [ "$chk" != "/" ] 
     34then 
     35  IFILE="`pwd`/${IFILE}" 
     36fi 
     37 
     38 
     39# Extract the header info of the file 
     40cd ${WTMP} 
     41rm -rf tmp.$$ >/dev/null 
     42mkdir tmp.$$ 
     43cd tmp.$$ 
     44 
     45tar xvzf ${IFILE} >/dev/null 2>/dev/null 
     46if [ "${?}" != "0" ] 
     47then 
     48    echo "ERROR: Extracting header info failed! " 
     49    cd .. 
     50    rm -rf tmp.$$ 
     51    exit 5 
     52fi 
     53 
     54# Blank our variables and read in the header information 
     55VER="" 
     56OS="" 
     57FILES="" 
     58FIP4="" 
     59FIP6="" 
     60FHOST="" 
     61 
     62HEADER=`ls *.header` 
     63 
     64while read line 
     65do 
     66  #Check for the file version 
     67  echo "$line" | grep -q "Ver:" 
     68  if [ $? -eq 0 ]; then 
     69    VER="`echo $line | cut -d ' ' -f 2-10`" 
     70  fi 
     71 
     72  # Check for the OS Platform 
     73  echo "$line" | grep -q "OS:" 
     74  if [ $? -eq 0 ]; then 
     75    OS="`echo $line | cut -d ' ' -f 2-10`" 
     76  fi 
     77 
     78  # Check for the File Number  
     79  echo "$line" | grep -q "Files:" 
     80  if [ $? -eq 0 ]; then 
     81    FILES="`echo $line | cut -d ' ' -f 2-10`" 
     82  fi 
     83   
     84  # Check for the built in IP4 
     85  echo "$line" | grep -q "IP4:" 
     86  if [ $? -eq 0 ]; then 
     87    FIP4="`echo $line | cut -d ' ' -f 2-10`" 
     88  fi 
     89 
     90  # Check for the built in IP6 
     91  echo "$line" | grep -q "IP6:" 
     92  if [ $? -eq 0 ]; then 
     93    FIP6="`echo $line | cut -d ' ' -f 2-10`" 
     94  fi 
     95   
     96  # Check for the built in HOST 
     97  echo "$line" | grep -q "HOST:" 
     98  if [ $? -eq 0 ]; then 
     99    FHOST="`echo $line | cut -d ' ' -f 2-10`" 
     100  fi 
     101 
     102done < $HEADER  
     103 
     104 
     105if [ "$HOST" = "OFF" ] ; then 
     106   HOST="${FHOST}" 
    26107fi 
    27108 
     
    65146set_warden_metadir 
    66147 
    67 # Lets start importing the jail now 
    68 ###################################################################### 
    69  
    70  
    71 chk=`echo "${IFILE}" | cut -c 1-1` 
    72 if [ "$chk" != "/" ] 
    73 then 
    74   IFILE="`pwd`/${IFILE}" 
    75 fi 
    76  
    77  
    78 # Extract the header info of the file 
    79 cd ${WTMP} 
    80 rm -rf tmp.$$ >/dev/null 
    81 mkdir tmp.$$ 
    82 cd tmp.$$ 
    83  
    84 tar xvzf ${IFILE} >/dev/null 2>/dev/null 
    85 if [ "${?}" != "0" ] 
    86 then 
    87     echo "ERROR: Extracting header info failed! " 
    88     cd .. 
    89     rm -rf tmp.$$ 
    90     exit 5 
    91 fi 
    92  
    93 # Blank our variables and read in the header information 
    94 VER="" 
    95 OS="" 
    96 FILES="" 
    97 FIP4="" 
    98 FIP6="" 
    99 FHOST="" 
    100  
    101 HEADER=`ls *.header` 
    102  
    103 while read line 
    104 do 
    105   #Check for the file version 
    106   echo "$line" | grep -q "Ver:" 
    107   if [ $? -eq 0 ]; then 
    108     VER="`echo $line | cut -d ' ' -f 2-10`" 
    109   fi 
    110  
    111   # Check for the OS Platform 
    112   echo "$line" | grep -q "OS:" 
    113   if [ $? -eq 0 ]; then 
    114     OS="`echo $line | cut -d ' ' -f 2-10`" 
    115   fi 
    116  
    117   # Check for the File Number  
    118   echo "$line" | grep -q "Files:" 
    119   if [ $? -eq 0 ]; then 
    120     FILES="`echo $line | cut -d ' ' -f 2-10`" 
    121   fi 
    122    
    123   # Check for the built in IP4 
    124   echo "$line" | grep -q "IP4:" 
    125   if [ $? -eq 0 ]; then 
    126     FIP4="`echo $line | cut -d ' ' -f 2-10`" 
    127   fi 
    128  
    129   # Check for the built in IP6 
    130   echo "$line" | grep -q "IP6:" 
    131   if [ $? -eq 0 ]; then 
    132     FIP6="`echo $line | cut -d ' ' -f 2-10`" 
    133   fi 
    134    
    135   # Check for the built in HOST 
    136   echo "$line" | grep -q "HOST:" 
    137   if [ $? -eq 0 ]; then 
    138     FHOST="`echo $line | cut -d ' ' -f 2-10`" 
    139   fi 
    140  
    141 done < $HEADER  
    142148 
    143149cd .. 
     
    154160then 
    155161    echo "WARNING: This .wdn file was created on $OS, while this host is `uname -r | cut -d '-' -f 1`" 
    156     echo "This jail may not work...Importing anyway..." 
    157162fi 
    158163 
Note: See TracChangeset for help on using the changeset viewer.