Web工程软件升级之数据库升级(二)
升级前检查
1. 用户是否存在
awk -F: '{if($1 == "xxx") print $1}' /ect/passwd
用户名
awk -F: '{if($1 == "xxx") print $6}' /ect/passwd
用户home目录是否存在也要判断
2. oracle 连接检查
conn xx/xx@ORALCESID
3. 执行数据库脚本
sqlplus /nolog >>${sqllog} << EOF
conn ${USERNAME}/${PASSWORD}@${SID}
@${script脚本文件}
commit;
exit
EOF
if [ $? -eq 0 ]; then
echo "upgrade db all success!"
else
echo "upgrade bmp dberror!"
return 1
fi
4. 检查数据库脚本执行结果
typeset result=`grep "ERROR" ${sqllog}`
if [ "X${result}" != "X" ];then
cat ${sqllog}
return 1
fi
result=`grep "Not connected" ${sqllog}`
if [ "X${result}" != "X" ];then
cat ${sqllog}
return 1
fi