launchdaemon

package
Version: v0.9.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 14, 2020 License: MIT, MIT Imports: 3 Imported by: 0

README

launchdaemon

launchdaemon install package for macOS

  • install path
    • $HOME/Library/LaunchAgents (local)
    • /Library/LaunchDaemons (global)

Installation

$ go get github.com/gnue/inst/pkgs/launchdaemon

Usage

import "github.com/gnue/inst/pkgs/launchdaemon"

Examples

Install
package main

import (
	"fmt"
	"github.com/gnue/inst"
	"github.com/gnue/inst/launchd"
	"github.com/gnue/inst/pkgs/launchdaemon"
)

func main() {
	data := &launchd.Service{
		ProgramArguments: []string{"server"},
		KeepAlive:        true,
		RunAtLoad:        true,
	}

	fname, err := launchdaemon.Install("label", data, inst.Global, false)
	if err != nil {
		fmt.Println(err)
	} else {
		fmt.Printf("install %q\n", fname)
	}
}

install launchd plist

Uninstall
package main

import (
	"fmt"
	"github.com/gnue/inst"
	"github.com/gnue/inst/pkgs/launchdaemon"
)

func main() {
	fname, err := launchdaemon.Uninstall("label", inst.Global)
	if err != nil {
		fmt.Println(err)
	} else {
		fmt.Printf("uninstall %q\n", fname)
	}
}

uninstall launchd plist

Author

gnue

License

MIT

Documentation

Overview

launchdaemon install package for macOS

* install path

* $HOME/Library/LaunchAgents (local)
* /Library/LaunchDaemons (global)

Index

Examples

Constants

This section is empty.

Variables

View Source
var Globals = []string{"/Library/LaunchDaemons"}
View Source
var Locals = []string{"$HOME/Library/LaunchAgents"}
View Source
var Pkg = &inst.Pkg{
	Template:        &plist.Template{},
	Locals:          Locals,
	Globals:         Globals,
	InstallAction:   launchd.InstallAction,
	UninstallAction: launchd.UninstallAction,
}

Functions

func Install

func Install(name string, data *launchd.Service, loc inst.Locate, force bool) (string, error)
Example

install launchd plist

package main

import (
	"fmt"

	"github.com/gnue/inst"
	"github.com/gnue/inst/launchd"
	"github.com/gnue/inst/pkgs/launchdaemon"
)

func main() {
	data := &launchd.Service{
		ProgramArguments: []string{"server"},
		KeepAlive:        true,
		RunAtLoad:        true,
	}

	fname, err := launchdaemon.Install("label", data, inst.Global, false)
	if err != nil {
		fmt.Println(err)
	} else {
		fmt.Printf("install %q\n", fname)
	}
}
Output:

func Uninstall

func Uninstall(name string, loc inst.Locate) (string, error)
Example

uninstall launchd plist

package main

import (
	"fmt"

	"github.com/gnue/inst"
	"github.com/gnue/inst/pkgs/launchdaemon"
)

func main() {
	fname, err := launchdaemon.Uninstall("label", inst.Global)
	if err != nil {
		fmt.Println(err)
	} else {
		fmt.Printf("uninstall %q\n", fname)
	}
}
Output:

Types

This section is empty.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL