本文整理匯總了Golang中github.com/eaciit/sshclient.SshSetting.SshCopyByPath方法的典型用法代碼示例。如果您正苦於以下問題:Golang SshSetting.SshCopyByPath方法的具體用法?Golang SshSetting.SshCopyByPath怎麽用?Golang SshSetting.SshCopyByPath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/eaciit/sshclient.SshSetting
的用法示例。
在下文中一共展示了SshSetting.SshCopyByPath方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: ProcessSetup
func (l *LangenvironmentController) ProcessSetup(dataServers *colonycore.Server, query *dbox.Filter, serverPathSeparator string, sshSetting sshclient.SshSetting) ([]sshclient.RunCommandResult, error) {
outputCmd := []sshclient.RunCommandResult{}
dataLanguage := []colonycore.LanguageEnviroment{}
cursor, err := colonycore.Find(new(colonycore.LanguageEnviroment), query)
cursor.Fetch(&dataLanguage, 0, false)
if err != nil {
return outputCmd, err
}
defer cursor.Close()
if cursor.Count() > 0 {
for _, eachLang := range dataLanguage {
for _, dataInstaller := range eachLang.Installer {
var sourcePath string
var destinationPath string
pathstring := []string{dataServers.DataPath, "langenvironment", "installer"}
var installShPath, uninstallShPath string
if strings.ToLower(dataServers.OS) == strings.ToLower(dataInstaller.OS) {
// targetLang := new(colonycore.InstalledLang)
// targetLang.Lang = eachLang.Language
// for _, eachLang := range dataServers.InstalledLang {
// if eachLang.Lang == targetLang.Lang {
// targetLang = eachLang
// break
// }
// }
if eachLang.Language == LANG_GO {
pathstring = append(pathstring, LANG_GO)
pathstring = append(pathstring, dataServers.OS)
sourcePath = filepath.Join(leSourcePath, LANG_GO, dataServers.OS, dataInstaller.InstallerSource)
destinationPath = strings.Join(pathstring, serverPathSeparator)
installShPath = filepath.Join(leSourcePath, LANG_GO, dataServers.OS, "install.sh")
uninstallShPath = filepath.Join(leSourcePath, LANG_GO, dataServers.OS, "uninstall.sh")
} else if eachLang.Language == LANG_JAVA {
pathstring = append(pathstring, LANG_JAVA)
pathstring = append(pathstring, dataServers.OS)
sourcePath = filepath.Join(leSourcePath, LANG_JAVA, dataServers.OS, dataInstaller.InstallerSource)
destinationPath = strings.Join(pathstring, serverPathSeparator)
installShPath = filepath.Join(leSourcePath, LANG_JAVA, dataServers.OS, "install.sh")
uninstallShPath = filepath.Join(leSourcePath, LANG_JAVA, dataServers.OS, "uninstall.sh")
} else if eachLang.Language == LANG_SCALA {
pathstring = append(pathstring, LANG_SCALA)
pathstring = append(pathstring, dataServers.OS)
sourcePath = filepath.Join(leSourcePath, LANG_SCALA, dataServers.OS, dataInstaller.InstallerSource)
destinationPath = strings.Join(pathstring, serverPathSeparator)
installShPath = filepath.Join(leSourcePath, LANG_SCALA, dataServers.OS, "install.sh")
uninstallShPath = filepath.Join(leSourcePath, LANG_SCALA, dataServers.OS, "uninstall.sh")
}
installShdestPath := strings.Join(append(pathstring, "install.sh"), serverPathSeparator)
uninstallShdestPath := strings.Join(append(pathstring, "uninstall.sh"), serverPathSeparator)
// installFilePath := strings.Join(append(pathstring, dataInstaller.InstallerSource), serverPathSeparator)
err = sshSetting.SshCopyByPath(sourcePath, destinationPath)
if err != nil {
return outputCmd, err
}
err = sshSetting.SshCopyByPath(installShPath, destinationPath)
if err != nil {
return outputCmd, err
}
err = sshSetting.SshCopyByPath(uninstallShPath, destinationPath)
if err != nil {
return outputCmd, err
}
//sed -i 's/^M//' install.sh
cmdSedInstall := fmt.Sprintf("sed -i 's/\r//g' %s", installShdestPath)
_, err = sshSetting.GetOutputCommandSsh(cmdSedInstall)
if err != nil {
return outputCmd, err
}
//sed -i 's/^M//' uninstall.sh
cmdSedUninstall := fmt.Sprintf("sed -i 's/\r//g' %s", uninstallShdestPath)
_, err = sshSetting.GetOutputCommandSsh(cmdSedUninstall)
if err != nil {
return outputCmd, err
}
// // chmod +x install.sh
cmdChmodCliInstall := fmt.Sprintf("chmod +x %s", installShdestPath)
_, err = sshSetting.GetOutputCommandSsh(cmdChmodCliInstall)
if err != nil {
return outputCmd, err
}
// // chmod +x uninstall.sh
cmdChmodCliUninstall := fmt.Sprintf("chmod +x %s", uninstallShdestPath)
_, err = sshSetting.GetOutputCommandSsh(cmdChmodCliUninstall)
if err != nil {
return outputCmd, err
}
// // sh install.sh installFilePath DESTINSTALL_PATH projectpath
cmdShCli := fmt.Sprintf("bash %s %s", uninstallShdestPath, DESTINSTALL_PATH)
//.........這裏部分代碼省略.........