You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.5 KiB
43 lines
1.5 KiB
package main
|
|
|
|
import (
|
|
"dsSso/Utils/ConfigUtil"
|
|
"dsSso/Utils/SftpUtil"
|
|
"dsSso/Utils/SshUtil"
|
|
"io/ioutil"
|
|
"log"
|
|
)
|
|
|
|
func main() {
|
|
//声明远端SSH管理器
|
|
cli := SshUtil.New(ConfigUtil.DistributeIp, ConfigUtil.DistributeUser, ConfigUtil.DistributePwd,int(ConfigUtil.DistributePort))
|
|
//杀掉进程
|
|
cli.Run("mkdir /usr/local/dsMin/dsSso -p")
|
|
cli.Run("ps -ef |grep dsSso |awk '{print $2}'|xargs kill -9")
|
|
|
|
//sftp上传文件及文件夹
|
|
sftpClient, err := SftpUtil.Connect(ConfigUtil.DistributeUser, ConfigUtil.DistributePwd, ConfigUtil.DistributeIp,int(ConfigUtil.DistributePort))
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
defer sftpClient.Close()
|
|
_, errStat := sftpClient.Stat(ConfigUtil.DistributeRemotePath)
|
|
if errStat != nil {
|
|
log.Fatal(ConfigUtil.DistributeRemotePath + " remote path not exists!")
|
|
}
|
|
_, err = ioutil.ReadDir(ConfigUtil.DistributeLocalPath)
|
|
if err != nil {
|
|
log.Fatal(ConfigUtil.DistributeLocalPath + " local path not exists!")
|
|
}
|
|
SftpUtil.UploadDirectory(sftpClient, ConfigUtil.DistributeLocalPath, ConfigUtil.DistributeRemotePath)
|
|
//执行SSH命令行,授权
|
|
cli.Run("chmod +x /usr/local/dsMin/dsSso/dsSso")
|
|
cli.Run("chmod +x /usr/local/dsMin/dsSso/start.sh")
|
|
cli.Run("chmod +x /usr/local/dsMin/dsSso/debug.sh")
|
|
cli.Run("chmod +x /usr/local/dsMin/dsSso/stop.sh")
|
|
cli.Run("cd /usr/local/dsMin/dsSso/ && dos2unix *.sh")
|
|
//启动
|
|
cli.Run("cd /usr/local/dsMin/dsSso && ./start.sh")
|
|
log.Println("恭喜,统一认证服务上传并启动成功!")
|
|
}
|