diff options
author | Ruben Pollan <meskio@sindominio.net> | 2018-02-14 00:52:45 +0100 |
---|---|---|
committer | Ruben Pollan <meskio@sindominio.net> | 2018-02-14 10:46:54 +0100 |
commit | a52abd0c722ec08cd95c8c9be76e27a04012b282 (patch) | |
tree | 7a8bfd388c0a857fde4e4586fc6a3638d6a888c3 /main.go | |
parent | 352b8dfbe7df572e5ed67f0a2ccedf6f77cdb3b2 (diff) |
[feat] install helpers if needed
- Resolves: #6
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 20 |
1 files changed, 19 insertions, 1 deletions
@@ -31,7 +31,7 @@ func main() { log.Fatal(err) } - go notificate(conf) + notify := newNotificator(conf) b, err := bitmask.Init() if err != nil { @@ -39,5 +39,23 @@ func main() { } defer b.Close() + checkAndInstallHelpers(b, notify) run(b, conf) } + +func checkAndInstallHelpers(b *bitmask.Bitmask, notify *notificator) { + helpers, priviledge, err := b.VPNCheck() + if err.Error() == "nopolkit" || (err == nil && !priviledge) { + log.Printf("No polkit found") + notify.authAgent() + } else if err != nil { + log.Fatal(err) + } + + if !helpers { + err = b.InstallHelpers() + if err != nil { + log.Println("Error installing helpers: ", err) + } + } +} |