forked from elgatito/elementum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmigration.go
36 lines (31 loc) · 1.02 KB
/
migration.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
package main
import (
"github.com/elgatito/elementum/repository"
"github.com/elgatito/elementum/xbmc"
)
func checkRepository() bool {
if xbmc.IsAddonInstalled("repository.elementum") {
if !xbmc.IsAddonEnabled("repository.elementum") {
xbmc.SetAddonEnabled("repository.elementum", true)
}
return true
}
log.Info("Creating Elementum repository add-on...")
if err := repository.MakeElementumRepositoryAddon(); err != nil {
log.Errorf("Unable to create repository add-on: %s", err)
return false
}
xbmc.UpdateLocalAddons()
for _, addon := range xbmc.GetAddons("xbmc.addon.repository", "unknown", "all", []string{"name", "version", "enabled"}).Addons {
if addon.ID == "repository.elementum" && addon.Enabled == true {
log.Info("Found enabled Elementum repository add-on")
return false
}
}
log.Info("Elementum repository not installed, installing...")
xbmc.InstallAddon("repository.elementum")
xbmc.SetAddonEnabled("repository.elementum", true)
xbmc.UpdateLocalAddons()
xbmc.UpdateAddonRepos()
return true
}