From ebcdaa9545dc72f219e9d836f06e76ae6ecae811 Mon Sep 17 00:00:00 2001 From: ysicing Date: Tue, 5 May 2020 18:48:33 +0800 Subject: [PATCH] feat: support tools install --- cmd/install.go | 11 ++++++++++- install/tools.go | 22 ++++++++++++++++++++++ version.txt | 2 +- 3 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 install/tools.go diff --git a/cmd/install.go b/cmd/install.go index 76f23d58..363e953a 100644 --- a/cmd/install.go +++ b/cmd/install.go @@ -40,6 +40,15 @@ var installNfs = &cobra.Command{ }, } +var installTools = &cobra.Command{ + Use: "tools", + Short: "tools", + Run: func(cmd *cobra.Command, args []string) { + klog.Info("🎉 安装 tools") + install.ToolsInstall() + }, +} + func init() { rootCmd.AddCommand(installCmd) installCmd.PersistentFlags().StringVar(&install.SSHConfig.User, "user", "root", "管理员") @@ -57,5 +66,5 @@ func init() { installNfs.PersistentFlags().StringVar(&install.NfsPath, "nfspath", "/k8sdata", "nfs路径") installNfs.PersistentFlags().StringVar(&install.DefaultSc, "nfssc", "nfs-data", "默认nfs storageclass") - installCmd.AddCommand(installDocker, installK8s, installNfs) + installCmd.AddCommand(installDocker, installTools, installK8s, installNfs) } diff --git a/install/tools.go b/install/tools.go new file mode 100644 index 00000000..283952a0 --- /dev/null +++ b/install/tools.go @@ -0,0 +1,22 @@ +// MIT License +// Copyright (c) 2019 ysicing + +package install + +import ( + "fmt" +) + +func ToolsInstall() { + i := InstallConfig{ + Hosts: Hosts, + } + i.ToolsInstall() +} + +func (i *InstallConfig) ToolsInstall() { + for _, ip := range i.Hosts { + toolscmd := fmt.Sprintf("docker run --rm -v /usr/local/bin:/sysdir ysicing/tools tar zxf /pkg.tgz -C /sysdir") + SSHConfig.Cmd(ip, toolscmd) + } +} diff --git a/version.txt b/version.txt index 2f453618..1d71ef97 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.2 \ No newline at end of file +0.3 \ No newline at end of file