版本基線自動化之Linux

上一篇筆者敘述瞭如何在windows平臺上進行自動化打包,此次採用linux平臺java

一、start.bat : 調用cleanall.bat腳本 ,從svn服務器中檢出代碼,並採用7-Zip工具進行壓縮並調用teasefile.bat腳本和output_linux.bat腳本;linux

  1.一、cleanall.bat:  清除環境 並利用secureCRT執行vbs腳本> aloneclean.vbsweb

  1.二、teasefile.bat:  將壓縮包利用secureCRT工具中的sfxcl命令發送到linux編譯服務器中 並利用CRT執行解壓> gunzupScript.vbswindows

  1.三、output_linux.bat:  編譯項目 >antcompilerScript.vbs,這裏我也是採用的是ant進行編譯java,c使用gcc編譯,利用smb實現linux文件共享,將安裝程序複製到svn服務器中,最後打開程序所在的位置便可;服務器

 

start.batapp

rem clean D:\yb\workspace\*
rem Create by dq
rem Create date 2017/5/10

@echo off

set _work=D:\yb\6.0\workspace
set _log=D:\tools\compilerproject\alone\cleanlog.txt
set _console=%_work%\console
set _ldapserver=%_work%\ldapserver
set _package=%_work%\package
set _package(windxldap)=%_work%\package(winxldap)
set _trunk_win=%_work%\trunk_win.rar
cd /d %_work%
 del /s /q %_trunk_win% 
 rd /s /q %_work%\.svn
 rd /s /q %_console% 
 rd /s /q %_ldapserver% 
 rd /s /q %_package% 
 rd /s /q %_package(windxldap)% 

cleanall.batwebapp

rem clean source code and installation package            
rem Create by dq
rem Create date 2017/4/30

set _work=D:\yb\QHLDAP\6.0\src
set _setup=D:\目錄服務管理系統\V6.0\QH-LDAP_6.01.001\安裝包\Linux


rem clean 192.168.0.234:D:\yb\workspace\* D:\yb\Log

rd /q /s %_work%\Linux 


rem clean installation package

rd /q /s %_setup%\* 


rem clean 192.168.0.92:/yb/work/*

cd /d D:\yb\SecureCRT 
SecureCRT.exe /LOG D:\yb\clean.txt /SCRIPT  Scripts/aloneclean.vbs  -2 root@192.168.0.92 /password qihang

aloneclean.vbssvn

#$language = "VBScript"
#$interface = "1.0"

crt.Screen.Synchronous = True

' This automatically generated script may need to be
' edited in order to work correctly.

Sub Main
	crt.Screen.Send "cd /" & chr(13)
	crt.Screen.WaitForString "[root@localhost /]# "
	crt.Screen.Send "cd /y" & chr(9) & "w" & chr(9) & chr(13)
	crt.Screen.WaitForString "[root@localhost work]# "
	crt.Screen.Send "rm -rf s" & chr(9) & chr(13)
	crt.Screen.WaitForString "[root@localhost work]# "
	crt.Screen.Send "rm 0" & chr(8) & "=-" & chr(8) & chr(8) & "=" & chr(8) & "-rf o" & chr(9) & chr(13)
	crt.Screen.WaitForString "[root@localhost work]# "
	crt.Screen.Send "rm -rf o" & chr(8) & "p" & chr(9) & chr(13)
	crt.Screen.WaitForString "[root@localhost work]# "
	crt.Screen.Send "rm -rf c" & chr(9) & chr(13)
	crt.Screen.WaitForString "[root@localhost work]# "
	crt.Session.Disconnect
	crt.Quit
End Sub

 

teasefile.bat工具

rem send source code             
rem Create by dq
rem Create date 2017/5/10


rem send to Linux

cd /d D:\yb\SecureCRT
sfxcl "D:\yb\QHLDAP\6.0\src\trunk_lin.gzip" sftp://root:qihang@192.168.0.92/../yb/work


rem run 'gunzipScript' script

SecureCRT.exe  /SCRIPT  Scripts/gunzipScript.vbs  -2 root@192.168.0.92 /password qihang 

gunzipScript.vbsui

#$language = "VBScript"
#$interface = "1.0"

crt.Screen.Synchronous = True

' This automatically generated script may need to be
' edited in order to work correctly.

Sub Main
	crt.Screen.Send "cd /" & chr(13)
	crt.Screen.WaitForString "[root@localhost /]# "
	crt.Screen.Send "cd /yb/w" & chr(9) & chr(13)
	crt.Screen.WaitForString "[root@localhost work]# "
	crt.Screen.Send "tar xvf t" & chr(9) & chr(13)
	crt.Screen.WaitForString "[root@localhost work]# "
	crt.Screen.Send "ls" & chr(13)
	crt.Screen.WaitForString chr(27) & "[m[root@localhost work]# "
	crt.Screen.Send "rm -rf t" & chr(9) & chr(13)
	crt.Screen.WaitForString "[root@localhost work]# "
	crt.Screen.Send "ls" & chr(13)
	crt.Session.Disconnect
	crt.Quit
End Sub

output_linux.bat

rem stop mstsc.exe; open release folder 			
rem Create by dq
rem Create date 2017/5/2


rem run 'compilerScript' scirpt

cd /d D:\yb\SecureCRT
SecureCRT.exe  /SCRIPT  Scripts/antcompilerScript.vbs  -2 root@192.168.0.92 /password qihang


rem long-distance copy installation project

net use * /del /y
net use \\192.168.0.92\public P@ssw0rd /user:root
copy \\192.168.0.92\public\* D:\目錄服務管理系統\V6.0\QH-LDAP_6.01.001\安裝包\Linux\setup


rem open installation project 

dir D:\
start D:\目錄服務管理系統\V6.0\QH-LDAP_6.01.001\安裝包\Linux
@exit

antcompilerScript.vbs

#$language = "VBScript"
#$interface = "1.0"

crt.Screen.Synchronous = True

' This automatically generated script may need to be
' edited in order to work correctly.

Sub Main
	crt.Screen.Send "cd /" & chr(13)
	crt.Screen.WaitForString "[root@localhost /]# "
	crt.Screen.Send "cd" & chr(8) & chr(8) & "chmod -R 777 /y" & chr(9) & chr(13)
	crt.Screen.WaitForString "[root@localhost /]# "
	crt.Screen.Send "cd /yb" & chr(9) & "comp" & chr(9) & chr(13)
	crt.Screen.WaitForString "[root@localhost compilerproject]# "
	crt.Screen.Send "ant -f init.xml" & chr(13)
	crt.Screen.WaitForString "[root@localhost compilerproject]# "
	crt.Screen.Send "ant -f Ld" & chr(9) & chr(13)
	crt.Screen.WaitForString "[root@localhost compilerproject]# "
	crt.Screen.Send "cd /" & chr(13)
	crt.Screen.WaitForString "[root@localhost /]# "
	crt.Screen.Send "chmod -R 777 /y" & chr(9) & chr(13)
	crt.Screen.WaitForString "[root@localhost /]# "
	crt.Screen.Send "cd /yb/work/package-x/QHLdap-Web/WEB/web/webapp/LDAPProject/WEB-INF/classes" & chr(9) & chr(13)
	crt.Screen.WaitForString "[root@localhost classes]# "
	crt.Screen.Send "rm -f *.jar" & chr(9) & chr(13)
	crt.Screen.WaitForString "[root@localhost classes]# "
	crt.Screen.Send "chmod -R 777 /y" & chr(9) & chr(13)
	crt.Screen.WaitForString "[root@localhost classes]# "
	crt.Screen.Send "cd /yb" & chr(9) & "w" & chr(9) & "s" & chr(9) & "qh" & chr(9) & chr(13)
	crt.Screen.WaitForString "[root@localhost qhldap-1.0]# "
	crt.Screen.Send "ls" & chr(13)
	crt.Screen.WaitForString chr(27) & "[m[root@localhost qhldap-1.0]# "
	crt.Screen.Send "./ldap-" & chr(9) & ".sh" & chr(13)
	crt.Screen.WaitForString "[root@localhost qhldap-1.0]# "
	crt.Screen.Send "cd /y" & chr(9) & "w" & chr(9) & "p" & chr(9) & chr(13)
	crt.Screen.WaitForString "[root@localhost package-x]# "
	crt.Screen.Send "./package." & chr(9) & chr(13)
	crt.Screen.WaitForString "[root@localhost package-x]# "
	crt.Screen.Send chr(13)
	crt.Screen.WaitForString "[root@localhost package-x]# "
	crt.Screen.Send chr(13)
	crt.Session.Disconnect
	crt.Quit
End Sub

這裏筆者說下如何使用Samba共享文件

安裝Samba

1)  檢查是否安裝  rpm –qa | grep samba

2)  修改/etc/samba/smb.conf

workgroup = WORKGROUP

hosts allow=192.168.0.234

3)  在文件的結尾加上

[public]

comment=Public Stuff

path = /yb/wroktest

public = yes

writable =yes

4)  重啓服務: service smb restart

5)  建立samba客戶:smbpasswd –a root回車後提示輸入密碼這裏的root必須在系統已經存在

6)  Windows下連接,啓動運行,輸入Linux的ip :\\192.168.0.92 輸入smb帳號密碼就能夠了

相關文章
相關標籤/搜索