我目前正致力于创建bash脚本,以自动完成在Windows 7 VM上进行全新安装和清除Bamboo远程代理的卸载过程。
这是我的两个脚本:
全新安装:
#!/bin/bash
#Main function
main(){
URL=https://bamboo.ihs.organization.net/agentServer/agentInstaller/atlassian-bamboo-agent-installer-5.5.0.jar
mkdir -p install-directory
#download jar
cwd=$(pwd)
echo "INFO - attempting to download jar file to:"
echo $cwd
echo "..."
echo ""
wget -nc --tries=10 $URL
cwd=$(pwd)
if [ $? -eq 1 ]
then
echo "ERROR - Failed to download jar file from $URL. It may have changed in the meantime."
exit 1
else
echo "INFO - Succeeded! Jar file downloaded to LOCATION"
fi
echo "INFO - Installing bamboo agent..."
#execute jar
echo "INFO - unpacking jar file..."
cwd=$(pwd)
win_cwd=$(cygpath -w ${cwd})
echo $win_cwd
java -Dbamboo.home=$win_cwd/install-directory/ -jar atlassian-bamboo-agent-installer-5.5.0.jar https://bamboo.ihs.organization.net/agentServer/
if [ $? -eq 1 ]
then
echo "ERROR - Failed to unpack jar file."
exit 1
else
echo -n "INFO - Succeeded! Jar file unpacked to "
echo $cwd/install-directory
fi
}
main
(基本上下载atlassian-bamboo-agent-installer-5.5.0.jar并将其安装到名为“install-directory”的文件夹中)
清除卸载:
#!/bin/bash
#Main function
main(){
cwd=$(pwd)
install_dir="$cwd""/install-directory"
win_install_dir=$(cygpath -w ${install_dir})
if [ -d $install_dir ]; then
echo -n "INFO - "
echo -n $install_dir
echo " detected. "
cd "$install_dir"
cd "bin"
STOP_SCRIPT="StopBambooAgent-NT.bat"
UNINSTALL_SCRIPT="UninstallBambooAgent-NT.bat"
cmd /c "$win_install_dir"/bin/"$STOP_SCRIPT"
cmd /c "$win_install_dir"/bin/"$UNINSTALL_SCRIPT"
if [ $? -eq 1 ]
then
echo -n "ERROR - '"
echo -n "$UNINSTALL_SCRIPT"
echo "' failed. See output above."
exit 1
fi
cd "../.."
echo -n "INFO - attempting to remove"
echo -n $install_dir
echo "... "
rm -rf $install_dir
if [ $? -eq 1 ]
then
echo -n "ERROR - removing '"
echo -n "$install_dir"
echo "' failed. See output above."
else
echo -n "INFO - removing '"
echo -n "$install_dir"
echo "' succeeded!"
fi
else
echo -n "ERROR - "
echo -n $install_dir
echo " is expected to exist."
exit 1
fi
}
main
(基本上调用StopBambooAgent-NT.bat,然后调用UninstallBambooAgent-NT.bat,删除“install-directory”文件夹)
我一直在做的一系列步骤:
运行./clean-install.sh。此时代理可以工作,我可以去服务器查看,在其上运行作业等。
打开一个终端窗口作为输出:
**************************************************************** ******************************************************************************** ***********
INFO | jvm 1 | 2015/01/27 11:52:07 | 2015-01-27 03:52:07,573 INFO [Thread-1 ] [RemoteAgent] * *
INFO | jvm 1 | 2015/01/27 11:52:07 | 2015-01-27 03:52:07,573 INFO [Thread-1 ] [RemoteAgent] * Bamboo agent '10.0.2.15 (12)' ready to receive builds.
INFO | jvm 1 | 2015/01/27 11:52:07 | 2015-01-27 03:52:07,573 INFO [Thread-1 ] [RemoteAgent] * Remote Agent Home: C:\Users\vagrant\bamboo-agent-dev\install-d irectory
INFO | jvm 1 | 2015/01/27 11:52:07 | 2015-01-27 03:52:07,573 INFO [Thread-1 ] [RemoteAgent] * Broker URL: failover:(tcp://bamboo.ihs.organization.net:54663?wir eFormat.maxInactivityDuration=300000)?initialReconnectDelay=15000&maxReconnectAt tempts=10
INFO | jvm 1 | 2015/01/27 11:52:07 | 2015-01-27 03:52:07,573 INFO [Thread-1 ] [RemoteAgent] * *
INFO | jvm 1 | 2015/01/27 11:52:07 | 2015-01-27 03:52:07,573 INFO [Thread-1 ] [RemoteAgent] **************************************************************** ******************************************************************************** ***********
INFO | jvm 1 | 2015/01/27 11:52:07 | 2015-01-27 03:52:07,588 INFO [QuartzSc heduler_Worker-1] [AgentHeartBeatJob] executableBuildAgent still unavailable. He artbeat skipped.
我cntrl-C出了这个,代理仍然在服务器上,我仍然可以配置它,在它上面运行作业等等。(至少看起来是这样的。)
然后我停止代理上的所有构建作业并尝试卸载它,这就是问题所在。
问题:
基本上当我尝试运行卸载脚本时,我收到以下错误消息:
INFO - /cygdrive/c/Users/vagrant/bamboo-agent-dev/install-directory detected.
ERROR | wrapper | 2015/01/27 11:41:42 | The bamboo-remote-agent service is not installed - The specified service does not exist as an installed service. (0x424)
Press any key to continue . . .
这对应于卸载脚本运行的StopBambooAgent.bat。
此外,当我尝试删除“install-directory”文件夹时,我还会收到许多以下错误消息(每个文件一个):
rm: cannot remove ‘/cygdrive/c/Users/vagrant/bamboo-agent-dev/install-directory/bin’: Device or resource busy
向我表明我没有正确停止代理。这些文件似乎由java JVM实例保持打开状态。
为什么告诉我代理没有安装?我是否正在尝试正确停止远程代理?如何停止远程代理?
非常感谢。
答案 0 :(得分:1)
通过@Etan Reisner
我没有安装竹代理作为Windows服务,尽管这是我的意图,这就是脚本无法正常工作的原因。为了解决这个问题,我在安装脚本的java命令中传入了installntservice。