shell 脚本执行dailybuild
2017-04-05 14:25
120 查看
#!/bin/bash
DestMailsList=("xxx@xxx.com");
BUILD_DIR=g3_asic_yocto
LOG_FILE="g3_asic_dailybuild.txt"
TAIL_FILE="./tail.txt"
#CurTime=$(date "+%Y%m%d")
DayTimeTag=$(date "+%Y%m%d")
MonTimeTag=$(date "+%Y%m")
YestTag=$(date -d '3 days ago' +%Y%m%d)
WORK_DIR=/space/pchen/g3_yocto_build/
cd $WORK_DIR
CurDIR=$(pwd)
if [ -d $MonTimeTag ]; then
echo "Have created dir $MonTimeTag"
else
mkdir $MonTimeTag
fi
mkdir $MonTimeTag/$DayTimeTag
#Gitclone Source Codes of Titan.
if [ -d $BUILD_DIR-$YestTag ]; then
echo "The Source Codes had git cloned before should be removed first."
rm $BUILD_DIR-$YestTag -rf
else
echo "The First time to Git clone the Source Code and build. "
fi
git clone -b g3-krogoth-master gitolite@cs-local-gitmirror:sw/platforms/cs-unified/distro/yocto $BUILD_DIR-$DayTimeTag
cd $BUILD_DIR-$DayTimeTag
git clone -b g3-krogoth-master gitolite@cs-local-gitmirror:sw/platforms/cs-unified/distro/openembedded/meta-openembedded
git clone -b g3-krogoth-master gitolite@cs-local-gitmirror:sw/platforms/cs-unified/distro/meta-oe-yocto-cortina
git clone -b g3-krogoth-master gitolite@cs-local-gitmirror:sw/platforms/cs-unified/distro/meta-ca-bsp
export TEMPLATECONF=meta-ca-bsp/conf/g3-eng/
#pwd
#ls
source ./oe-init-build-env
#Make build
bitbake basic-image > $CurDIR/$LOG_FILE
#Copy the output image
cd $CurDIR
#echo $CurDIR
#echo $CurTime
#if [ -d $CurTime ]; then
# echo "remove the first."
# rm $CurTime -rf
# mkdir $CurTime
#else
# echo "12233"
# mkdir $CurTime
#fi
cp $BUILD_DIR-$DayTimeTag/build/tmp/deploy/images/g3-eng/Image $MonTimeTag/$DayTimeTag
cp $BUILD_DIR-$DayTimeTag/build/tmp/deploy/images/g3-eng/Image-ca7774-engboard.dtb $MonTimeTag/$DayTimeTag
cp $BUILD_DIR-$DayTimeTag/build/tmp/deploy/images/g3-eng/basic-image-g3-eng.cpio.xz $MonTimeTag/$DayTimeTag
cp $BUILD_DIR-$DayTimeTag/build/tmp/deploy/images/g3-eng/u-boot.bin $MonTimeTag/$DayTimeTag
cp $LOG_FILE $MonTimeTag/$DayTimeTag/$DayTimeTag-$LOG_FILE
tail -10 $LOG_FILE > $TAIL_FILE
grep -I "Error" $TAIL_FILE
if [ $? -eq 0 ]; then
echo "The daily compile building had failed. --- Please refer the attchment log file!" > $TAIL_FILE
else
echo "The daily compile building had PASSED successful. --- OK!" > $TAIL_FILE
fi
echo "#######################################################" >> $TAIL_FILE
echo "" >> $TAIL_FILE
echo "... ... ..." >> $TAIL_FILE
echo "" >> $TAIL_FILE
tail -20 $LOG_FILE >> $TAIL_FILE
#Restart the Mail Services
#service postfix restart
#service sendmail restart
#Send Emails
for m in ${DestMailsList[@]}; do
echo $m
cat $TAIL_FILE | mutt -s "G3 ASIC YOCTO Daily Build - "$DayTimeTag $m -a $LOG_FILE
done
#End
DestMailsList=("xxx@xxx.com");
BUILD_DIR=g3_asic_yocto
LOG_FILE="g3_asic_dailybuild.txt"
TAIL_FILE="./tail.txt"
#CurTime=$(date "+%Y%m%d")
DayTimeTag=$(date "+%Y%m%d")
MonTimeTag=$(date "+%Y%m")
YestTag=$(date -d '3 days ago' +%Y%m%d)
WORK_DIR=/space/pchen/g3_yocto_build/
cd $WORK_DIR
CurDIR=$(pwd)
if [ -d $MonTimeTag ]; then
echo "Have created dir $MonTimeTag"
else
mkdir $MonTimeTag
fi
mkdir $MonTimeTag/$DayTimeTag
#Gitclone Source Codes of Titan.
if [ -d $BUILD_DIR-$YestTag ]; then
echo "The Source Codes had git cloned before should be removed first."
rm $BUILD_DIR-$YestTag -rf
else
echo "The First time to Git clone the Source Code and build. "
fi
git clone -b g3-krogoth-master gitolite@cs-local-gitmirror:sw/platforms/cs-unified/distro/yocto $BUILD_DIR-$DayTimeTag
cd $BUILD_DIR-$DayTimeTag
git clone -b g3-krogoth-master gitolite@cs-local-gitmirror:sw/platforms/cs-unified/distro/openembedded/meta-openembedded
git clone -b g3-krogoth-master gitolite@cs-local-gitmirror:sw/platforms/cs-unified/distro/meta-oe-yocto-cortina
git clone -b g3-krogoth-master gitolite@cs-local-gitmirror:sw/platforms/cs-unified/distro/meta-ca-bsp
export TEMPLATECONF=meta-ca-bsp/conf/g3-eng/
#pwd
#ls
source ./oe-init-build-env
#Make build
bitbake basic-image > $CurDIR/$LOG_FILE
#Copy the output image
cd $CurDIR
#echo $CurDIR
#echo $CurTime
#if [ -d $CurTime ]; then
# echo "remove the first."
# rm $CurTime -rf
# mkdir $CurTime
#else
# echo "12233"
# mkdir $CurTime
#fi
cp $BUILD_DIR-$DayTimeTag/build/tmp/deploy/images/g3-eng/Image $MonTimeTag/$DayTimeTag
cp $BUILD_DIR-$DayTimeTag/build/tmp/deploy/images/g3-eng/Image-ca7774-engboard.dtb $MonTimeTag/$DayTimeTag
cp $BUILD_DIR-$DayTimeTag/build/tmp/deploy/images/g3-eng/basic-image-g3-eng.cpio.xz $MonTimeTag/$DayTimeTag
cp $BUILD_DIR-$DayTimeTag/build/tmp/deploy/images/g3-eng/u-boot.bin $MonTimeTag/$DayTimeTag
cp $LOG_FILE $MonTimeTag/$DayTimeTag/$DayTimeTag-$LOG_FILE
tail -10 $LOG_FILE > $TAIL_FILE
grep -I "Error" $TAIL_FILE
if [ $? -eq 0 ]; then
echo "The daily compile building had failed. --- Please refer the attchment log file!" > $TAIL_FILE
else
echo "The daily compile building had PASSED successful. --- OK!" > $TAIL_FILE
fi
echo "#######################################################" >> $TAIL_FILE
echo "" >> $TAIL_FILE
echo "... ... ..." >> $TAIL_FILE
echo "" >> $TAIL_FILE
tail -20 $LOG_FILE >> $TAIL_FILE
#Restart the Mail Services
#service postfix restart
#service sendmail restart
#Send Emails
for m in ${DestMailsList[@]}; do
echo $m
cat $TAIL_FILE | mutt -s "G3 ASIC YOCTO Daily Build - "$DayTimeTag $m -a $LOG_FILE
done
#End
相关文章推荐
- shell脚本直接执行没有问题,crontab定时执行失败的解决方法
- linux下C程序插入执行shell脚本
- 在 Shell 脚本中执行语法检查调试模式
- bash shell脚本执行的几种方法
- shell脚本的执行方式和makefile常识
- JAVA执行bat文件和shell脚本文件
- 执行shell脚本的三种方式
- linux下shell脚本执行方法及exec和source命令
- Linux之Shell脚本while循环ssh登录执行命令
- 从Linux程序中执行shell(程序、脚本)并获得输出结果
- shell 脚本调试(使用shell的执行选项)
- Shell脚本实现每个工作日定时执行指定程序(学习记录)
- Shell脚本执行方式
- 执行shell脚本出现bin/bash: bad interpreter: No such file or directory
- shell 脚本执行错误
- linux下执行多个shell脚本的方法
- shell 脚本执行语法错误问题
- shell脚本执行返回的状态码
- 避免启动container运行shell脚本执行完成后docker退出
- java程序执行,调用shell命令和shell脚本