Skip to content

Commit 3dffc33

Browse files
committed
feat(debian): update debian tools
update debian tools Signed-off-by: ysicing <i@ysicing.me>
1 parent 73dbcb4 commit 3dffc33

File tree

4 files changed

+18
-13
lines changed

4 files changed

+18
-13
lines changed

.github/workflows/tag.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
sha256sum ergo_linux_arm64 > ergo_linux_arm64.sha256sum
4343
popd
4444
./gen.sh
45-
make release
45+
cat version.txt | grep -E '(beta|rc)' && (pre-release) || (make release)
4646
make deb
4747
env:
4848
GITHUB_RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}

cmd/debian.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ func newDebianCmd(f factory.Factory) *cobra.Command {
1616
}
1717
debian := &cobra.Command{
1818
Use: "debian [flags]",
19-
Short: "初始化debian, 升级debian内核",
19+
Short: "debian tools",
2020
Aliases: []string{"deb"},
2121
Args: cobra.NoArgs,
2222
Version: "2.0.0",
2323
}
2424
init := &cobra.Command{
2525
Use: "init",
26-
Short: "初始化debian或debian系环境",
26+
Short: "init debian",
2727
Version: "2.0.0",
2828
RunE: func(cobraCmd *cobra.Command, args []string) error {
2929
return opt.Init(f)
@@ -39,7 +39,8 @@ func newDebianCmd(f factory.Factory) *cobra.Command {
3939
}
4040
upcore := &cobra.Command{
4141
Use: "upcore",
42-
Short: "升级Debian内核",
42+
Short: "upgrade debian linux core",
43+
Aliases: []string{"uc"},
4344
Version: "2.0.0",
4445
RunE: func(cobraCmd *cobra.Command, args []string) error {
4546
return opt.UpCore(f)

cmd/debian/debian.go

+12-8
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,19 @@ type Option struct {
2222
IPs []string
2323
}
2424

25+
func (cmd *Option) prepare() {
26+
if len(cmd.IPs) == 0 {
27+
cmd.Local = true
28+
}
29+
}
30+
2531
func (cmd *Option) Init(f factory.Factory) error {
26-
// cmd.log = f.GetLog()
32+
cmd.prepare()
2733
cmd.SSHCfg.Log = f.GetLog()
28-
if cmd.Local || len(cmd.IPs) == 0 {
34+
if cmd.Local {
2935
debian.RunLocalShell("init", cmd.SSHCfg.Log)
3036
return nil
3137
}
32-
33-
cmd.SSHCfg.Log.Debugf("ssh: %v, ips: %v", cmd.SSHCfg, cmd.IPs)
3438
var wg sync.WaitGroup
3539
for _, ip := range cmd.IPs {
3640
wg.Add(1)
@@ -41,13 +45,13 @@ func (cmd *Option) Init(f factory.Factory) error {
4145
}
4246

4347
func (cmd *Option) UpCore(f factory.Factory) error {
48+
cmd.prepare()
4449
cmd.SSHCfg.Log = f.GetLog()
4550
// 本地
46-
if cmd.Local || len(cmd.IPs) == 0 {
51+
if cmd.Local {
4752
debian.RunLocalShell("upcore", cmd.SSHCfg.Log)
4853
return nil
4954
}
50-
cmd.SSHCfg.Log.Debugf("ssh: %v, ips: %v", cmd.SSHCfg, cmd.IPs)
5155
var wg sync.WaitGroup
5256
for _, ip := range cmd.IPs {
5357
wg.Add(1)
@@ -58,16 +62,16 @@ func (cmd *Option) UpCore(f factory.Factory) error {
5862
}
5963

6064
func (cmd *Option) Apt(f factory.Factory) error {
65+
cmd.prepare()
6166
cmd.SSHCfg.Log = f.GetLog()
6267
// 本地
63-
if cmd.Local || len(cmd.IPs) == 0 {
68+
if cmd.Local {
6469
if file.CheckFileExists("/etc/apt/sources.list") {
6570
debian.RunLocalShell("apt", cmd.SSHCfg.Log)
6671
return nil
6772
}
6873
return fmt.Errorf("仅支持Debian系")
6974
}
70-
cmd.SSHCfg.Log.Debugf("ssh: %v, ips: %v", cmd.SSHCfg, cmd.IPs)
7175
var wg sync.WaitGroup
7276
for _, ip := range cmd.IPs {
7377
wg.Add(1)

version.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.0.0-beta
1+
3.0.0-beta1

0 commit comments

Comments
 (0)