Add make target to activate launchagent
This commit is contained in:
18
Makefile
18
Makefile
@@ -18,7 +18,8 @@
|
||||
.PHONY: help clean uninstall \
|
||||
install-systemd install-cron \
|
||||
install-targets-script install-targets-conf install-targets-systemd \
|
||||
install-targets-cron
|
||||
install-targets-cron \
|
||||
activate-launchagent deactivate-launchagent
|
||||
|
||||
#### Macros ###################################################################
|
||||
NOW := $(shell date +%Y-%m-%d_%H:%M:%S)
|
||||
@@ -39,6 +40,11 @@ MKDIR_PARENTS=sh -c '\
|
||||
test -d $$dir || mkdir -p $$dir \
|
||||
' MKDIR_PARENTS
|
||||
|
||||
# LaunchAgent names.
|
||||
UID := $(shell id -u)
|
||||
LAUNCHAGENT = com.github.erikw.restic-automatic-backup
|
||||
LAUNCHAGENT_TARGET = gui/$(UID)/$(LAUNCHAGENT)
|
||||
|
||||
# Source directories.
|
||||
DIR_SCRIPT = bin
|
||||
DIR_CONF = etc/restic
|
||||
@@ -163,3 +169,13 @@ $(DEST_DIR_LAUNCHAGENT)/%: $(BUILD_DIR_LAUNCHAGENT)/%
|
||||
# Install destination mac log dir.
|
||||
$(DEST_DIR_MAC_LOG):
|
||||
mkdir -p $@
|
||||
|
||||
# target: activate-launchagent - Activate the LaunchAgent.
|
||||
activate-launchagent:
|
||||
launchctl bootstrap gui/$(UID) $(DEST_TARGS_LAUNCHAGENT)
|
||||
launchctl enable $(LAUNCHAGENT_TARGET)
|
||||
launchctl kickstart -p $(LAUNCHAGENT_TARGET)
|
||||
|
||||
# target: deactivate-launchagent - Deactivate and remove the LaunchAgent.
|
||||
deactivate-launchagent:
|
||||
launchctl bootout $(LAUNCHAGENT_TARGET)
|
||||
|
||||
@@ -44,12 +44,11 @@ Tip: use the Section icon in the top left of this document to navigate the secti
|
||||
* Arch: part of the `base-devel` meta package, Debian/Ubuntu: part of the `build-essential` meta package, macOS: use the preinstalled or a more recent with Homebrew)
|
||||
|
||||
|
||||
|
||||
# Setup
|
||||
Depending on your system, the setup will look different. Choose one of
|
||||
* <img height="16" width="16" src="https://unpkg.com/simple-icons@v6/icons/linux.svg" /> [Linux + Systemd](#setup-linux-systemd)
|
||||
* <img height="16" width="16" src="https://unpkg.com/simple-icons@v6/icons/apple.svg" /> [macOS + LaunchAgent](#setup-macos-launchagent)
|
||||
* [Cron](#setup-cron) - for any system having a cron daemon. Tested on FreeBSD and macOS.
|
||||
* <img height="16" width="16" src="https://unpkg.com/simple-icons@v6/icons/clockify.svg" /> [Cron](#setup-cron) - for any system having a cron daemon. Tested on FreeBSD and macOS.
|
||||
|
||||
## Setup Linux Systemd
|
||||
### TL;DR Setup
|
||||
@@ -282,6 +281,7 @@ LaunchAgent is the modern service scheduler in in macOS that uses [Launchd](http
|
||||
$ launchctl enable gui/$UID/com.github.erikw.restic-automatic-backup
|
||||
$ launchctl kickstart -p gui/$UID/com.github.erikw.restic-automatic-backup
|
||||
```
|
||||
As a convenience, a shortcut for the above commands are `$ make activate-launchagent`.
|
||||
|
||||
Use the `disable` command to temporarily pause the agent, or `bootout` to uninstall it.
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user