aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/system/retrieve.go
blob: d9f0e3dd1a25b8580b307907dcc70c02416f3999 (plain)
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
package system

import (
	"fmt"
	"os"
	"path"
	"strconv"
)

func Retrieve(verbose bool) {
	if V != nil {
		panic("system info retrieved twice")
	}

	v := &Values{Share: path.Join(os.TempDir(), "fortify."+strconv.Itoa(os.Geteuid())), Verbose: verbose}

	if r, ok := os.LookupEnv(xdgRuntimeDir); !ok {
		fmt.Println("Env variable", xdgRuntimeDir, "unset")

		// too early for fatal
		os.Exit(1)
	} else {
		v.Runtime = r
		v.RunDir = path.Join(v.Runtime, "fortify")
	}

	V = v
}