This repository has been archived by the owner on Feb 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 887
/
path.go
49 lines (39 loc) · 1.53 KB
/
path.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
42
43
44
45
46
47
48
49
//+build linux
package main
import (
"path/filepath"
"github.com/appc/spec/schema/types"
"github.com/coreos/rocket/path"
)
const (
unitsDir = path.Stage1Dir + "/usr/lib/systemd/system"
defaultWantsDir = unitsDir + "/default.target.wants"
socketsWantsDir = unitsDir + "/sockets.target.wants"
)
// ServiceUnitName returns a systemd service unit name for the given imageID
func ServiceUnitName(imageID types.Hash) string {
return imageID.String() + ".service"
}
// ServiceUnitPath returns the path to the systemd service file for the given
// imageID
func ServiceUnitPath(root string, imageID types.Hash) string {
return filepath.Join(root, unitsDir, ServiceUnitName(imageID))
}
// ServiceWantPath returns the systemd default.target want symlink path for the
// given imageID
func ServiceWantPath(root string, imageID types.Hash) string {
return filepath.Join(filepath.Join(root, defaultWantsDir), ServiceUnitName(imageID))
}
// SocketUnitName returns a systemd socket unit name for the given imageID
func SocketUnitName(imageID types.Hash) string {
return imageID.String() + ".socket"
}
// SocketUnitPath returns the path to the systemd socket file for the given imageID
func SocketUnitPath(root string, imageID types.Hash) string {
return filepath.Join(root, unitsDir, SocketUnitName(imageID))
}
// SocketWantPath returns the systemd sockets.target.wants symlink path for the
// given imageID
func SocketWantPath(root string, imageID types.Hash) string {
return filepath.Join(filepath.Join(root, socketsWantsDir), SocketUnitName(imageID))
}