Changeset e6d5635


Ignore:
Timestamp:
08/06/13 11:06:17 (14 months ago)
Author:
Ken Moore <ken@…>
Branches:
master, 9.2-release, releng/10.0, releng/10.0.1, releng/10.0.2, releng/10.0.3
Children:
d5ff236
Parents:
940aaf0 (diff), a4ac142 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of github.com:pcbsd/pcbsd

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src-sh/lpreserver/backend/functions.sh

    r4e5cced rfeb0fb0  
    1414if [ ! -d "$DBDIR" ] ; then mkdir -p ${DBDIR} ; fi 
    1515CMDLOG="${DBDIR}/lp-lastcmdout" 
     16CMDLOG2="${DBDIR}/lp-lastcmdout2" 
    1617REPCONF="${DBDIR}/replication" 
    1718LOGDIR="/var/log" 
     
    180181  echo "$LDATA:$TIME:$HOST:$USER:$PORT:$RDATA" >> ${REPCONF} 
    181182 
     183  if [ "$TIME" != "sync" ] ; then 
     184    cronscript="${PROGDIR}/backend/runrep.sh" 
     185    cLine="0    $TIME       *       *       *" 
     186    echo -e "$cLine\troot    ${cronscript} ${LDATA}" >> /etc/crontab 
     187  fi 
    182188} 
    183189 
     
    186192  cat ${REPCONF} | grep -v "^${1}:" > ${REPCONF}.tmp 
    187193  mv ${REPCONF}.tmp ${REPCONF} 
    188 } 
    189  
     194 
     195  # Make sure we remove any old replication entries for this dataset 
     196  cronscript="${PROGDIR}/backend/runrep.sh" 
     197  cat /etc/crontab | grep -v " $cronscript $1" > /etc/crontab.new 
     198  mv /etc/crontab.new /etc/crontab 
     199} 
     200 
     201list_rep_task() { 
     202  if [ ! -e "$REPCONF" ] ; then return ; fi 
     203 
     204  echo "Scheduled replications:" 
     205  echo "---------------------------------" 
     206 
     207  while read line 
     208  do 
     209     LDATA=`echo $line | cut -d ':' -f 1` 
     210     TIME=`echo $line | cut -d ':' -f 2` 
     211     HOST=`echo $line | cut -d ':' -f 3` 
     212     USER=`echo $line | cut -d ':' -f 4` 
     213     PORT=`echo $line | cut -d ':' -f 5` 
     214     RDATA=`echo $line | cut -d ':' -f 6` 
     215 
     216     echo "$LDATA -> $USER@$HOST[$PORT]:$RDATA Time: $TIME" 
     217 
     218  done < ${REPCONF} 
     219} 
     220 
     221check_rep_task() { 
     222  export DIDREP=0 
     223  if [ ! -e "$REPCONF" ] ; then return 0; fi 
     224 
     225  repLine=`cat ${REPCONF} | grep "^${1}:"` 
     226  if [ -z "$repLine" ] ; then return 0; fi 
     227 
     228  # We have a replication task for this dataset, lets check if we need to do it now 
     229  LDATA="$1" 
     230  TIME=`echo $repLine | cut -d ':' -f 2` 
     231 
     232  # Export the replication variables we will be using 
     233  export REPHOST=`echo $repLine | cut -d ':' -f 3` 
     234  export REPUSER=`echo $repLine | cut -d ':' -f 4` 
     235  export REPPORT=`echo $repLine | cut -d ':' -f 5` 
     236  export REPRDATA=`echo $repLine | cut -d ':' -f 6` 
     237 
     238  # If we are checking for a sync task, and the rep isn't marked as sync we can return 
     239  if [ "$2" = "sync" -a "$TIME" != "sync" ] ; then return 0; fi 
     240 
     241  # Is this a sync-task we do at the time of a snapshot? 
     242  if [ "$2" = "sync" -a "$TIME" = "sync" ] ; then 
     243     export DIDREP=1 
     244     echo_log "`date`: Starting replication SYNC task on ${DATASET}\n" 
     245     queue_msg "`date`: Starting replication SYNC task on ${DATASET}\n" 
     246     start_rep_task "$LDATA" 
     247     return $? 
     248  else 
     249     # Ready to do a scheduled replication 
     250     export DIDREP=1 
     251     echo_log "`date`: Starting replication SCHEDULED task on ${DATASET}\n" 
     252     queue_msg "`date`: Starting replication SCHEDULED task on ${DATASET}\n" 
     253     start_rep_task "$LDATA" 
     254     return $? 
     255  fi 
     256} 
     257 
     258start_rep_task() { 
     259  LDATA="$1" 
     260 
     261  # Check for the last snapshot marked as replicated already 
     262  lastSEND=`zfs get -r backup:lpreserver ${LDATA} | grep LATEST | awk '{$1=$1}1' OFS=" " | tail -1 | cut -d '@' -f 2 | cut -d ' ' -f 1` 
     263 
     264  # Lets get the last snapshot for this dataset 
     265  lastSNAP=`zfs list -t snapshot -d 1 -H ${LDATA} | tail -1 | awk '{$1=$1}1' OFS=" " | cut -d '@' -f 2 | cut -d ' ' -f 1` 
     266  
     267  if [ "$lastSEND" = "$lastSNAP" ] ; then 
     268     queue_msg "`date`: Last snapshot $lastSNAP is already marked as replicated!" 
     269     return 1 
     270  fi 
     271 
     272  # Starting replication, first lets check if we can do an incremental send 
     273  if [ -n "$lastSEND" ] ; then 
     274     zFLAGS="-Rv -I $lastSEND $LDATA@$lastSNAP" 
     275  else 
     276     zFLAGS="-Rv $LDATA@$lastSNAP" 
     277  fi 
     278 
     279  zSEND="zfs send $zFLAGS" 
     280  zRCV="ssh -p ${REPPORT} ${REPUSER}@${REPHOST} zfs receive -dvuF ${REPRDATA}" 
     281 
     282  queue_msg "Using ZFS send command:\n$zSEND | $zRCV\n\n" 
     283 
     284  # Start up our process 
     285  $zSEND 2>${CMDLOG} | $zRCV >${CMDLOG2} 2>${CMDLOG2} 
     286  zStatus=$? 
     287  queue_msg "ZFS SEND LOG:\n--------------\n`cat ${CMDLOG}`\n\n" 
     288  queue_msg "ZFS RCV LOG:\n--------------\n`cat ${CMDLOG2}`\n\n" 
     289 
     290  if [ $zStatus -eq 0 ] ; then 
     291     # SUCCESS! 
     292     # Lets mark our new latest snapshot and unmark the last one 
     293     zfs set backup:lpreserver=' ' ${LDATA}@$lastSEND 
     294     zfs set backup:lpreserver=LATEST ${LDATA}@$lastSNAP 
     295     echo_log "`date`: Finished replication task on ${DATASET}\n" 
     296  else 
     297     # FAILED :-( 
     298     # Lets save the output for us to look at later 
     299     FLOG=${LOGDIR}/lpreserver_failed.log 
     300     echo "Failed with command:\n$zSEND | $zRCV\n" > ${FLOG} 
     301     echo "\nSending log:\n" >> ${FLOG} 
     302     cat ${CMDLOG} >> ${FLOG} 
     303     echo "\nRecv log:\n" >> ${FLOG} 
     304     cat ${CMDLOG2} >> ${FLOG} 
     305     echo_log "`date`: FAILED replication task on ${DATASET}: LOGFILE: $FLOG\n" 
     306  fi 
     307 
     308  return $zStatus 
     309} 
     310 
     311get_data_props() { 
     312 
     313  # Lets start by building a list of props to keep 
     314  pTag=`echo $DATASET | md5` 
     315 
     316  if [ "$RECURMODE" = "ON" ] ; then 
     317     zfs get -r all $DATASET | grep ' local$' | awk '{$1=$1}1' OFS=" " > /tmp/.propList.$$ 
     318  else 
     319     zfs get all $DATASET | grep ' local$' | awk '{$1=$1}1' OFS=" " > /tmp/.propList.$$ 
     320  fi 
     321  
     322  cat /tmp/.propList.$$ 
     323  rm /tmp/.propList.$$ 
     324 
     325} 
  • src-sh/lpreserver/backend/runrep.sh

    r9fa96a3 rfeb0fb0  
    1111 
    1212DATASET="${1}" 
     13TIME="${2}" 
    1314 
    1415if [ -z "${DATASET}" ]; then 
     
    1617fi 
    1718 
    18 # Lets start by building a list of props to keep 
    19 pTag=`echo $DATASET | md5` 
     19check_rep_task "$DATASET" "$TIME" 
     20status=$? 
    2021 
    21 if [ "$RECURMODE" = "ON" ] ; then 
    22    zfs get -r all $DATASET | grep ' local$' | awk '{$1=$1}1' OFS=" " > /tmp/.propList.$$ 
     22# No replication was needed / done 
     23if [ $DIDREP -eq 0 ] ; then exit 0 ; fi 
     24 
     25if [ $status -eq 0 ] ; then 
     26  title="Success" 
    2327else 
    24    zfs get all $DATASET | grep ' local$' | awk '{$1=$1}1' OFS=" " > /tmp/.propList.$$ 
     28  title="FAILED" 
    2529fi 
    2630 
    27 cat /tmp/.propList.$$ 
    28 rm /tmp/.propList.$$ 
    29  
    30 if [ "$EMAILMODE" = "ALL" ] ; then 
    31    #email_msg "Automated Snapshot" "`echo_queue_msg`" 
    32 fi 
     31case $EMAILMODE in 
     32    ALL) email_msg "Automated Replication - $title" "`echo_queue_msg`" ;; 
     33    *) if [ $status -ne 0 ] ; then 
     34          email_msg "Automated Replication - $title" "`echo_queue_msg`" 
     35       fi 
     36       ;; 
     37esac 
  • src-sh/lpreserver/backend/runsnap.sh

    r0fe982e rfeb0fb0  
    6363   email_msg "Automated Snapshot" "`echo_queue_msg`" 
    6464fi 
     65 
     66# Check if we need to run a replication task for this dataset 
     67${PROGDIR}/backend/runrep.sh ${DATASET} sync 
  • src-sh/lpreserver/lpreserver

    r4e5cced rfeb0fb0  
    375375            case ${1} in 
    376376                add) add_rep_task "$2" "$3" "$4" "$5" "$6" "$7" ;; 
    377                 list) ;; 
     377                list) list_rep_task ;; 
    378378                remove) cat ${REPCONF} | grep -q "^${2}:"  
    379379                        if [ $? -eq 0 ] ; then 
  • src-qt4/pc-mounttray/menuItem.cpp

    r1620346 r940aaf0  
    106106bool MenuItem::isMounted(){ 
    107107  //Check if device is mounted 
     108  QStringList chk = pcbsd::Utils::runShellCommand("mount"); 
     109  bool mounted=false; 
     110  for(int i=0; i<chk.length(); i++){ 
     111    mounted = chk[i].contains(device) || chk[i].contains(devLabel->text()) || chk[i].contains(devLabel->text().replace(" ","-")); 
     112    if(mounted){  
     113      //Save the mountpoint if it is mounted 
     114      mountpoint = chk[i].section(" on ",1,10).section("(",0,0).simplified(); 
     115      break;  
     116    } 
     117  } 
     118  return mounted; 
     119  /* 
    108120  QString chk = pcbsd::Utils::runShellCommandSearch("mount",device);   
    109121  if(chk.isEmpty() ){ chk = pcbsd::Utils::runShellCommandSearch("mount",devLabel->text().replace(" ","-")); }  
    110  
    111122  if(chk.isEmpty() ){ return FALSE; } 
    112123  else{ return TRUE; } 
     124  */ 
    113125} 
    114126 
     
    248260void MenuItem::unmountItem(){ 
    249261  //Unmount the device 
    250  
     262         
    251263  //Check to see if the current mountpoint exists or if it is somewhere else 
    252264  if( !QFile::exists(mountpoint) ){ 
    253     if( isMounted() ){  //double check that it is actually mounted 
    254       //mounted someplace else - find it 
    255       QString output = pcbsd::Utils::runShellCommandSearch("mount",device); 
    256       mountpoint = output.section(" on ",1,1).section(" (",0,0).replace(" ","-"); 
    257     }else{ 
     265    if( !isMounted() ){  //double check that it is actually mounted (and fix the mountpoint) 
    258266      //it is not mounted to begin with 
    259267      return; 
    260268    } 
    261269  } 
    262    
    263   QString cmd1 = "umount " + mountpoint; 
    264   QString cmd2 = "rmdir " + mountpoint; 
     270  //Make sure there are no spaces in the mounpoint path 
     271  QString cmd1 = "umount \"" + mountpoint +"\""; 
     272  QString cmd2 = "rmdir \"" + mountpoint +"\""; 
    265273  qDebug() << "Unmounting device from" << mountpoint; 
    266274  //Run the commands 
     
    297305  bool ok = FALSE; 
    298306  if(isMounted()){ 
    299     QString cmd = "df "+mountpoint; 
     307    QString cmd = "df \""+mountpoint+"\""; 
    300308    QStringList output = systemCMD(cmd); //make sure we use the one with a 1K blocksize 
    301309    if(output.length() > 1){ 
Note: See TracChangeset for help on using the changeset viewer.