Add make target to activate launchagent

This commit is contained in:
Erik Westrup
2022-02-09 17:16:18 +01:00
parent 99b0bf5ac5
commit caf95ef393
2 changed files with 19 additions and 3 deletions
+17 -1
View File
@@ -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)