Exemplo n.º 1
0
func createRktGarbageService(fsc *fs.FsClient, useOverlay bool) error {
	opts := rktOptions{
		UseOverlay: useOverlay,
	}

	b, err := templates.Render(rktGarbageServiceTemplate, opts)
	if err != nil {
		return maskAny(err)
	}

	if err := fsc.Write(rktSystemdPath+rktGarbageServiceName, b.Bytes(), unitFileMode); err != nil {
		return maskAny(err)
	}

	rktGarbageTimer, err := templates.Asset(rktGarbageTimerTemplate)
	if err != nil {
		return maskAny(err)
	}

	if err := fsc.Write(rktSystemdPath+rktGarbageTimerName, rktGarbageTimer, unitFileMode); err != nil {
		return maskAny(err)
	}

	return nil
}
Exemplo n.º 2
0
func RenderRulesFromTemplate() ([]byte, error) {
	opts := ip6tablesOptions{}
	b, err := templates.Render(rulesTemplate, opts)
	if err != nil {
		return nil, maskAny(err)
	}
	return b.Bytes(), nil
}
Exemplo n.º 3
0
func RenderRulesFromTemplate(subnet, dockerSubnet, gateway string, useDockerRules bool) ([]byte, error) {
	opts := iptablesOptions{
		Subnet:         subnet,
		DockerSubnet:   dockerSubnet,
		Gateway:        gateway,
		UseDockerRules: useDockerRules,
	}

	b, err := templates.Render(rulesTemplate, opts)
	if err != nil {
		return nil, maskAny(err)
	}
	return b.Bytes(), nil
}
Exemplo n.º 4
0
func createFleetService(fsc *fs.FsClient, useOverlay bool) error {
	opts := fleetOptions{
		UseOverlay: useOverlay,
	}

	b, err := templates.Render(fleetServiceTemplate, opts)
	if err != nil {
		return maskAny(err)
	}

	if err := fsc.Write(fleetServicePath, b.Bytes(), fileMode); err != nil {
		return maskAny(err)
	}

	return nil
}
Exemplo n.º 5
0
func createDockerService(fsc *fs.FsClient, dockerVersion string, privateRegistry []string, useIPTables bool, useOverlay bool) error {
	opts := dockerOptions{
		PrivateRegistry: privateRegistry,
		StorageEngine:   getStorageEngine(dockerFolder),
		UseIPTables:     useIPTables,
		UseOverlay:      useOverlay,
		DockerExecArgs:  make([]string, 0),
	}

	options := addVersionSpecificArguments(&opts, dockerVersion)
	opts = *options

	b, err := templates.Render(serviceTemplate, opts)
	if err != nil {
		return maskAny(err)
	}

	if err := fsc.Write(servicePath, b.Bytes(), fileMode); err != nil {
		return maskAny(err)
	}

	return nil
}
Exemplo n.º 6
0
func Setup(fsc *fs.FsClient, sc *systemd.SystemdClient, distributionPath, overlayWorkdir, overlayMountPoint string) error {
	vLogger("\n# call overlay.Setup()")

	if err := fsc.MkdirAll(overlayWorkdir, fileMode); err != nil {
		return maskAny(err)
	}

	opts := struct {
		OverlayUpperdir string
		OverlayWorkdir  string
		MountPoint      string
	}{
		distributionPath,
		overlayWorkdir,
		overlayMountPoint,
	}

	b, err := templates.Render(overlayMountTemplate, opts)
	if err != nil {
		return maskAny(err)
	}

	if err := fsc.Write(overlayMountPath, b.Bytes(), fileMode); err != nil {
		return maskAny(err)
	}

	if err := sc.Reload(); err != nil {
		return maskAny(err)
	}

	if err := sc.Start(overlayMount); err != nil {
		return maskAny(err)
	}

	return nil
}