-
-
Notifications
You must be signed in to change notification settings - Fork 23
/
main.go
91 lines (72 loc) · 2.3 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package main
/* License: GPLv3
Authors:
Mirko Brombin <[email protected]>
Vanilla OS Contributors <https://github.com/vanilla-os/>
Copyright: 2024
Description:
ABRoot is utility which provides full immutability and
atomicity to a Linux system, by transacting between
two root filesystems. Updates are performed using OCI
images, to ensure that the system is always in a
consistent state.
*/
import (
"embed"
"github.com/containers/storage/pkg/reexec"
"github.com/vanilla-os/abroot/cmd"
"github.com/vanilla-os/abroot/settings"
"github.com/vanilla-os/orchid/cmdr"
)
var Version = "development"
//go:embed locales/*.yml
var fs embed.FS
var abroot *cmdr.App
func main() {
if reexec.Init() {
return
}
abroot = cmd.New(Version, fs)
// root command
root := cmd.NewRootCommand(Version)
abroot.CreateRootCommand(root, abroot.Trans("abroot.msg.help"), abroot.Trans("abroot.msg.version"))
msgs := cmdr.UsageStrings{
Usage: abroot.Trans("abroot.msg.usage"),
Aliases: abroot.Trans("abroot.msg.aliases"),
Examples: abroot.Trans("abroot.msg.examples"),
AvailableCommands: abroot.Trans("abroot.msg.availableCommands"),
AdditionalCommands: abroot.Trans("abroot.msg.additionalCommands"),
Flags: abroot.Trans("abroot.msg.flags"),
GlobalFlags: abroot.Trans("abroot.msg.globalFlags"),
AdditionalHelpTopics: abroot.Trans("abroot.msg.additionalHelpTopics"),
MoreInfo: abroot.Trans("abroot.msg.moreInfo"),
}
abroot.SetUsageStrings(msgs)
upgrade := cmd.NewUpgradeCommand()
root.AddCommand(upgrade)
kargs := cmd.NewKargsCommand()
root.AddCommand(kargs)
// we only add the pkg command if the ABRoot configuration
// has the IPkgMng enabled in any way (1 or 2)
if settings.Cnf.IPkgMngStatus > 0 {
pkg := cmd.NewPkgCommand()
root.AddCommand(pkg)
}
rollback := cmd.NewRollbackCommand()
root.AddCommand(rollback)
status := cmd.NewStatusCommand()
root.AddCommand(status)
updateInitramfs := cmd.NewUpdateInitfsCommand()
root.AddCommand(updateInitramfs)
cnf := cmd.NewConfCommand()
root.AddCommand(cnf)
unlockVar := cmd.NewUnlockVarCommand()
root.AddCommand(unlockVar)
mntSys := cmd.NewMountSysCommand()
root.AddCommand(mntSys)
// run the app
err := abroot.Run()
if err != nil {
cmdr.Error.Println(err)
}
}