Skip to content

Commit 4a9ad23

Browse files
committed
Fixing disabled ufw
1 parent 1c87602 commit 4a9ad23

File tree

3 files changed

+62
-57
lines changed

3 files changed

+62
-57
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*.dylib
77

88
cmd/tufw/tufw
9+
.github-token
910

1011
# Test binary, built with `go test -c`
1112
*.test

.goreleaser.yaml

+43-43
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,56 @@
1-
# This is an example .goreleaser.yml file with some sensible defaults.
2-
# Make sure to check the documentation at https://goreleaser.com
1+
version: 2
32
env:
4-
- GO111MODULE=on
3+
- GO111MODULE=on
54
before:
65
hooks:
7-
# You may remove this if you don't use go modules.
8-
- go mod download
9-
- go mod tidy
6+
# You may remove this if you don't use go modules.
7+
- go mod download
8+
- go mod tidy
109
builds:
11-
- main: ./cmd/tufw/main.go
12-
env:
13-
- CGO_ENABLED=0
14-
goos:
15-
- linux
16-
goarch:
17-
- amd64
10+
- main: ./cmd/tufw/main.go
11+
env:
12+
- CGO_ENABLED=0
13+
goos:
14+
- linux
15+
goarch:
16+
- arm64
17+
- amd64
1818
archives:
19-
- name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
20-
files:
21-
- README.md
19+
- name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
20+
files:
21+
- README.md
2222
snapshot:
2323
name_template: "{{ .Version }}-SNAPSHOT-{{ .CommitTimestamp }}-{{ .ShortCommit }}"
2424
changelog:
2525
sort: asc
2626
filters:
2727
exclude:
28-
- '^docs:'
29-
- '^test:'
28+
- '^docs:'
29+
- '^test:'
3030
nfpms:
31-
-
32-
id: packages
33-
homepage: https://github.com/peltho/tufw
34-
maintainer: Thomas Pellegatta <[email protected]>
35-
description: "A terminal user interface for ufw"
36-
license: MIT
37-
formats:
38-
- deb
39-
- rpm
40-
dependencies:
41-
- ufw
31+
- id: packages
32+
homepage: https://github.com/peltho/tufw
33+
maintainer: Thomas Pellegatta <[email protected]>
34+
description: "A terminal user interface for ufw"
35+
license: MIT
36+
formats:
37+
- deb
38+
- rpm
39+
dependencies:
40+
- ufw
4241
aurs:
43-
-
44-
name: tufw-bin
45-
description: "Terminal UI for ufw"
46-
homepage: "https://github.com/peltho/tufw"
47-
maintainers:
48-
- "Thomas Pellegatta <[email protected]>"
49-
license: "MIT"
50-
git_url: "ssh://[email protected]/tufw-git.git"
51-
skip_upload: false
52-
depends:
53-
- ufw
54-
commit_author:
55-
name: goreleaserbot
56-
42+
- name: tufw-bin
43+
description: "Terminal UI for ufw"
44+
homepage: "https://github.com/peltho/tufw"
45+
maintainers:
46+
- "Thomas Pellegatta <[email protected]>"
47+
license: "MIT"
48+
git_url: "ssh://[email protected]/tufw-git.git"
49+
skip_upload: false
50+
depends:
51+
- ufw
52+
commit_author:
53+
name: goreleaserbot
54+
55+
env_files:
56+
github_token: .github-token

internal/core/service/tufw.go

+18-14
Original file line numberDiff line numberDiff line change
@@ -460,20 +460,24 @@ func (t *Tui) Build(data []string) {
460460
root := t.CreateLayout()
461461

462462
if len(data) <= 1 {
463-
t.pages.HidePage("base")
464-
t.CreateModal("ufw is disabled.\nDo you want to enable it?",
465-
func() {
466-
utils.Shellout("ufw --force enable")
467-
},
468-
func() {
469-
t.app.Stop()
470-
},
471-
func() {
472-
t.pages.HidePage("modal")
473-
t.pages.ShowPage("base")
474-
t.app.SetFocus(t.menu)
475-
},
476-
)
463+
if len(data) == 1 && strings.Contains(data[0], "inactive") {
464+
t.pages.HidePage("base")
465+
t.CreateModal("ufw is disabled.\nDo you want to enable it?",
466+
func() {
467+
utils.Shellout("ufw --force enable")
468+
},
469+
func() {
470+
t.app.Stop()
471+
},
472+
func() {
473+
t.pages.HidePage("modal")
474+
t.pages.ShowPage("base")
475+
t.app.SetFocus(t.menu)
476+
},
477+
)
478+
} else {
479+
panic("ufw is not installed.\nBe sure to install it before launching tufw")
480+
}
477481
}
478482

479483
t.CreateTable(data)

0 commit comments

Comments
 (0)