标签:$? script info pat rem _id test done gre
#!/bin/bashdate +%F-%H-%M-%S
check_pr()
{
if [ ${s_pr_no} != 2 ]
then
echo "pls use $0 os_name(rhel76) os_versio(6/7) ";
exit 1
fi
}
check_rt()
{
if [ $? == 0 ] ;then echo "====succ";else echo "====fail" ;exit 1;fi
}
modify_db()
{
file_no=cat ${s_log} | grep remote_filename |grep -v ‘big.iso$‘ |wc -l
if [ ${file_no} != 1 ] ;
then
echo "====file Number is ${file_no} no 1";exit 1;
else
echo "====file Number is ${file_no} is 1" ;
fi
file_path=cat ${s_log} | grep remote_filename |grep -v ‘big.iso$‘ |awk -F "=" ‘{print $3}‘
echo ‘insert into io_file_upload‘
echo ‘(name, trace, create_by, create_time, status, dltimes, parent_id)‘
echo ‘values‘
case ${s_os_release} in
rhel)
echo "(‘${s_os_name}-ks.iso‘, ‘http://io.paic.com.cn/group1/${file_path}‘, ‘XUJINTAO726‘, now(), ‘1‘, 0, ‘99‘);"
;;
olinux)
echo "(‘${s_os_name}-ks.iso‘, ‘http://io.paic.com.cn/group1/${file_path}‘, ‘XUJINTAO726‘, now(), ‘1‘, 0, ‘98‘);"
;;
centos)
echo "(‘${s_os_name}-ks.iso‘, ‘http://io.paic.com.cn/group1/${file_path}‘, ‘XUJINTAO726‘, now(), ‘1‘, 0, ‘92‘);"
;;
kylin)
echo "(‘${s_os_name}-ks.iso‘, ‘http://io.paic.com.cn/group1/${file_path}‘, ‘XUJINTAO726‘, now(), ‘1‘, 0, ‘101‘);"
;;
*)
echo "faild pls check os release"
exit 1
;;
esac
}
main()
{
cd /kvm/kstool/
if [ -d /kvm/iso-temp/${s_os_name}/mnt/tools/ ]
then
echo "remove old tools"
echo "rm -rf /kvm/iso-temp/${s_os_name}/mnt/tools/"
rm -rf /kvm/iso-temp/${s_os_name}/mnt/tools/
check_rt
else
echo "/kvm/iso-temp/${s_os_name}/mnt/tools/ done exist"
exit
fi
echo "copy new tools"
cp /kvm/kstool/tools/* /kvm/iso-temp/${s_os_name}/mnt/tools/
check_rt
case ${s_os_versio} in
6)
echo "copy ks sysinit"
echo "rm -f /kvm/iso-temp/${s_os_name}/mnt/tools/sysinitel7.x86_64.rpm"
rm -f /kvm/iso-temp/${s_os_name}/mnt/tools/sysinitel7.x86_64.rpm
cp /kvm/kstool/6ks.cfg /kvm/iso-temp/${s_os_name}/mnt/tools/ks.cfg
check_rt
;;
7)
echo "copy ks sysinit"
echo "rm -f /kvm/iso-temp/${s_os_name}/mnt/tools/sysinitel6.x86_64.rpm"
rm -f /kvm/iso-temp/${s_os_name}/mnt/tools/sysinitel6.x86_64.rpm
cp /kvm/kstool/7ks.cfg /kvm/iso-temp/${s_os_name}/mnt/tools/ks.cfg
check_rt
;;
8)
echo "copy ks sysinit"
echo "rm -f /kvm/iso-temp/${s_os_name}/mnt/tools/sysinitel6.x86_64.rpm"
rm -f /kvm/iso-temp/${s_os_name}/mnt/tools/sysinitel6.x86_64.rpm
cp /kvm/kstool/8ks.cfg /kvm/iso-temp/${s_os_name}/mnt/tools/ks.cfg
check_rt
;;
*)
echo "wrong os_verion : ${s_os_versio} "
exit
esac
echo "copy osinit"
cp /kvm/kstool/osinit/linux/root/* /kvm/iso-temp/${s_os_name}/mnt/tools/ -r
check_rt
echo "create iso"
cd /kvm/iso-temp/${s_os_name}/mnt/
echo mkisofs
echo "mkisofs -relaxed-filenames -R -J -V "${s_lable}" -o /kvm/iso-ks/${s_os_name}-ks.iso -c isolinux/boot.cat -b isolinux/isolinux.bin -no-emul-boot -boot-load-size 4 -boot-info-table -eltorito-alt-boot -b images/efiboot.img -no-emul-boot /kvm/iso-temp/${s_os_name}/mnt"
mkisofs -relaxed-filenames -R -J -V "${s_lable}" -o /kvm/iso-ks/${s_os_name}-ks.iso \
-c isolinux/boot.cat -b isolinux/isolinux.bin -no-emul-boot -boot-load-size 4 \
-boot-info-table -eltorito-alt-boot -b images/efiboot.img -no-emul-boot /kvm/iso-temp/${s_os_name}/mnt
check_rt
echo "upload file"
cd /kvm/iso-ks/
echo upload
echo "/usr/bin/fdfs_test /etc/fdfs/client.conf upload /kvm/iso-ks/${s_os_name}-ks.iso"
/usr/bin/fdfs_test /etc/fdfs/client.conf upload /kvm/iso-ks/${s_os_name}-ks.iso
check_rt
modify_db
}
check_pr
main >> ${s_log} 2>&1
#main
标签:$? script info pat rem _id test done gre
原文地址:https://blog.51cto.com/12768454/2547413