forked from steeve/pulsar
-
Notifications
You must be signed in to change notification settings - Fork 19
/
migration.go
41 lines (35 loc) · 1.1 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
37
38
39
40
41
package main
import (
"os"
"path/filepath"
"github.com/scakemyer/quasar/xbmc"
"github.com/scakemyer/quasar/config"
"github.com/scakemyer/quasar/repository"
)
func Migrate() bool {
firstRun := filepath.Join(config.Get().Info.Path, ".firstrun")
if _, err := os.Stat(firstRun); err == nil {
return false
}
file, _ := os.Create(firstRun)
defer file.Close()
log.Info("Preparing for first run...")
log.Info("Creating Quasar repository add-on...")
if err := repository.MakeQuasarRepositoryAddon(); err != nil {
log.Errorf("Unable to create repository add-on: %s", err)
} else {
xbmc.UpdateLocalAddons()
for _, addon := range xbmc.GetAddons("xbmc.addon.repository", "unknown", "all", []string{"name", "version", "enabled"}).Addons {
if addon.ID == "repository.quasar" && addon.Enabled == true {
log.Info("Found enabled Quasar repository add-on")
return false
}
}
log.Info("Quasar repository not installed, installing...")
xbmc.InstallAddon("repository.quasar")
xbmc.SetAddonEnabled("repository.quasar", true)
xbmc.UpdateLocalAddons()
xbmc.UpdateAddonRepos()
}
return true
}