Linux 下 实现GlassfishV3 自动部署
Deploy.sh 代码
#. `dirname "$0"`/setenv_1.sh
CheckProcess()
{
if [ "$1" = "" ];
then
return 1
fi
PROCESS_NUM='ps -ef | grep "$1" | grep -v "grep" | wc -l'
if [ $PROCESS_NUM -eq 1 ];
then
return 0
else
return 1
fi
}
#while [ 1 ] ; do
#process name
CheckProcess "glassfish"
Check_RET=$?
if [ $Check_RET -eq 1 ];
then
sh /home/glassfish3/glassfish/bin/asadmin start-domain domain1
fi
#sleep
sh /installant/apache-ant-1.8.0/bin/ant -f deploy.xml deploy
deploy.xml 代码
<!-- create by cheping.wang 2014.04.25 -->
<project default="installv10">
<property file="../../installserver/install.properties"/>
<target name="deploy" depends="deployGlassfish">
</target>
<target name="deployGlassfish">
<!--undeploy xx-->
<exec dir="." executable="sh">
<arg line="${GLASSFISHBINHOME}/asadmin" />
<arg line="--user" />
<arg line="admin" />
<arg line="--passwordfile" />
<arg line="${GLASSFISHBINHOME}/password.txt" />
<arg line="undeploy" />
<arg line="xx" />
</exec>
<!-- deploy xx war -->
<exec dir="." executable="sh">
<arg line="${GLASSFISHBINHOME}/asadmin" />
<arg line="--user" />
<arg line="admin" />
<arg line="--passwordfile" />
<arg line="${GLASSFISHBINHOME}/password.txt" />
<arg line="deploy" />
<arg line="${REPORT_HOME}/bin/distribute/${earName}" />
</exec>
<!-- start firefox and visit xxhomePage -->
</target>
</project>
password.txt 内容
AS_ADMIN_PASSWORD=admin