Commit 1f50040 1 parent 46cc953 commit 1f50040 Copy full SHA for 1f50040
File tree 3 files changed +8
-7
lines changed
3 files changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -13,13 +13,6 @@ import (
13
13
14
14
var ProcessPath string
15
15
16
- func init () {
17
- if RootCheck (false ) {
18
- fmt .Println ("Do not run Apx as root!" )
19
- os .Exit (1 )
20
- }
21
- }
22
-
23
16
func RootCheck (display bool ) bool {
24
17
if os .Geteuid () != 0 {
25
18
if display {
Original file line number Diff line number Diff line change 5
5
unknownCommand : " Unknown command: %s"
6
6
invalidInput : " Invalid input."
7
7
invalidChoice : " Invalid choice."
8
+ noRoot : " Do not run Apx as root."
8
9
info :
9
10
aborting : " Aborting as requested."
10
11
terminal :
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ package main
10
10
11
11
import (
12
12
"embed"
13
+ "os"
13
14
14
15
"github.com/vanilla-os/apx/cmd"
15
16
"github.com/vanilla-os/apx/core"
@@ -29,6 +30,12 @@ func main() {
29
30
30
31
apx = cmd .New (Version , fs )
31
32
33
+ // check if root, exit if so
34
+ if core .RootCheck (false ) {
35
+ cmdr .Error .Println (apx .Trans ("apx.errors.noRoot" ))
36
+ os .Exit (1 )
37
+ }
38
+
32
39
// root command
33
40
root := cmd .NewRootCommand (Version )
34
41
apx .CreateRootCommand (root )
You can’t perform that action at this time.
0 commit comments