Example #1
0
func CreateLaunchFile(autoLaunch bool) {
	var err error
	var content bytes.Buffer
	fname := appdir.InHomeDir(LaunchdPlistFile)

	lanternPath, err := osext.Executable()
	if err != nil {
		log.Errorf("Could not get Lantern directory path: %q", err)
		return
	}
	log.Debugf("Using lantern path: %v", lanternPath)

	// Create plist template and set RunAtLoad property
	t := template.Must(template.New("LaunchdPlist").Parse(LaunchdPlist))

	err = t.Execute(&content, &Plist{RunAtLoad: autoLaunch, Path: lanternPath})
	if err != nil {
		log.Errorf("Error writing plist template: %q", err)
		return
	}

	if err = ioutil.WriteFile(fname, content.Bytes(), 0755); err != nil {
		log.Errorf("Error writing to launchd plist file: %q", err)
	}
}
Example #2
0
func CreateLaunchFile(autoLaunch bool) {
	var err error
	var content bytes.Buffer
	fname := appdir.InHomeDir(LaunchdPlistFile)

	// Create plist template and set RunAtLoad property
	t := template.Must(template.New("LaunchdPlist").Parse(LaunchdPlist))

	err = t.Execute(&content, &Plist{RunAtLoad: autoLaunch})
	if err != nil {
		log.Errorf("Error writing plist template: %q", err)
		return
	}

	if err = ioutil.WriteFile(fname, content.Bytes(), 0755); err != nil {
		log.Errorf("Error writing to launchd plist file: %q", err)
	}
}