summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorRuben Pollan <meskio@sindominio.net>2018-02-14 00:52:45 +0100
committerRuben Pollan <meskio@sindominio.net>2018-02-14 10:46:54 +0100
commita52abd0c722ec08cd95c8c9be76e27a04012b282 (patch)
tree7a8bfd388c0a857fde4e4586fc6a3638d6a888c3 /main.go
parent352b8dfbe7df572e5ed67f0a2ccedf6f77cdb3b2 (diff)
[feat] install helpers if needed
- Resolves: #6
Diffstat (limited to 'main.go')
-rw-r--r--main.go20
1 files changed, 19 insertions, 1 deletions
diff --git a/main.go b/main.go
index 08d1579..82a3a9e 100644
--- a/main.go
+++ b/main.go
@@ -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)
+ }
+ }
+}