#!/bin/bash
IP=`/sbin/ifconfig eth0 | grep "inet addr" | awk -F[:" "]+ '{print $4}'`
Date=`date +%Y%m%d`
DDate=`date +%Y-%m-%d -d "1 day ago"`
Datee=`date +%Y%m%d -d "1 day ago"`
Date2=`date +%Y%m%d -d "100 day ago"`
BASE_DIR="/space/hudson/jobs"
DEST_DIR="/gms2/Hudson_cfgbak/$IP/$Date"
DEST_DIR2="/gms2/Hudson_cfgbak/$IP/$Datee"
/bin/mkdir -p /gms2/Hudson_cfgbak/$IP/$Date
/bin/rm -rf /gms2/Hudson_cfgbak/$IP/$Date2
cd ${BASE_DIR}
for Job in $(ls)
do
if [ -d $Job ];then
if [ -f $Job/config.xml ];then
/bin/mkdir -p $DEST_DIR/$Job
/bin/cp $Job/config.xml ${DEST_DIR}/$Job/
/bin/ls -l $BASE_DIR/$Job/builds/ | grep $DDate | grep lrwxrwxrwx | awk -F[:" "]+ '{print $10}' > $DEST_DIR2/$Job/Node.txt
for Node in `cat $DEST_DIR2/$Job/Node.txt`
do
mkdir $DEST_DIR2/$Job/$Node
/bin/cp $BASE_DIR/$Job/builds/$Node/archive/IDH/manifest.xml $DEST_DIR2/$Job/$Node/
done
fi
fi
done