【问题标题】:I have created automated deployment scripts for deployment but unable to run them我已经为部署创建了自动部署脚本,但无法运行它们
【发布时间】:2015-11-21 10:15:49
【问题描述】:

我为 Dev、Cert、PPE、PROD 部署创建了自动化部署脚本。开发脚本工作正常。但是我无法运行证书。任何人都可以请帮忙。这个 shell 脚本将处理以下任务: 1.从提取的“书”网络应用程序中删除现有的2个文件。 2. 复制新的 2 个文件 - 在从桥位置提取的“书”网络应用程序中。

但我在参加 CERT 时遇到了问题。

#start for each host
for i in "${servers_array[@]}"
do
  ssh_to_remote_host="ssh -l bookweb -i /export/home/apps/bookplus/.ssh/id_dsa ";

#find the hostname and it's application path
case $i in

#CERT3 Viewer Book Server
    b3pclcertview01)
                    app_path=$view_3_app_path;
                    book_config=$view_3_config_path;
                    ;;

#CERT2 Viewer Book Server
    b3bookvm14)
                    app_path=$view_2_app_path;
                    book_config=$view_2_config_path;
                    ;;

#CERT1 Viewer Book Server
    b3bookvm02)
                    app_path=$view_1_app_path;
                    book_config=$view_1_config_path;
                    ;;

#CERT SMS Viewer Book Server
    b3bookvm03)
                    app_path=$sms_1_app_path;
                    book_config=$sms_1_config_path;
                    ;;

#CERT RUMBA Viewer Book Server
    b3bookvm09)
                    app_path=$rumba_1_app_path;
                    book_config=$rumba_1_config_path;
                    ;;

*)   echo "`date "+%Y-%m-%d %H:%M:%S"`  $i is not a valid option exiting"
exit 0;;
esac #end case
if [ "$i" = $deploymentserver ]
then
        ssh_to_remote_host=""; #This is the host from deployment will be done. Therefore it is required to set off ssh command and use normal "cp" command
        i="";
fi
echo "`date "+%Y-%m-%d %H:%M:%S"`  Start deployment at hostname $i ......................"; 

#deleting files - ViewerMain_r49.swf & launchBookViewer.jsp from extracted “book” webapps
rm -rf $app_path/apache-tomcat-6.0.35/webapps/book/jsp/viewer/launchBookViewer.jsp;
rm -rf $app_path/apache-tomcat-6.0.35/webapps/book/flex/ViewerMain_r49.swf;

#verify file is deleted
if [ ! -f "$app_path/apache-tomcat-6.0.35/webapps/book/jsp/viewer/launchBookViewer.jsp" ];
then echo "File 'launchBookViewer.jsp' is deleted";
fi

if [ ! -f "$app_path/apache-tomcat-6.0.35/webapps/book/flex/ViewerMain_r49.swf" ];
then echo "File 'ViewerMain_r49.swf' is deleted";
fi

#start deployment of  file
$ssh_to_remote_host $i cp -rp  $etext_build_location/launchBookViewer.jsp  $app_path/apache-tomcat-6.0.35/webapps/book/jsp/viewer/;
$ssh_to_remote_host $i cp -rp  $etext_build_location/ViewerMain_r4121.swf  $app_path/apache-tomcat-6.0.35/webapps/book/flex/;

if [ "$?" -ne 0 ]
   then
      echo "`date "+%Y-%m-%d %H:%M:%S"`  node ${i} : files could not be deployed";
    exit 0;
else
    echo "`date "+%Y-%m-%d %H:%M:%S"`  files deployed at hostname: $i ......................";  
fi  

done #end deployment

【问题讨论】:

  • 你遇到了什么问题?
  • 请提供SSCCE

标签: bash unix deployment ssh putty


【解决方案1】:

我不确定你到底想要什么,但这段代码有些可疑。您正在本地机器上删除,然后在远程机器上复制文件。我的猜测是你必须使用scp 而不是ssh 从远程机器复制到本地机器。或者如果你想在远程机器上做所有事情,那么你也应该在删除文件时ssh

在更一般的说明中,如果您不知道它失败的原因,请使用 bash -x 运行脚本以对其进行调试。

【讨论】:

    最近更新 更多