Skip to content
Browse files

Add launchd definitions for backups on Mac OS X

  • Loading branch information...
1 parent c4c9130 commit f1a6f5b00e8eb7fc3b122feb1a8e7fc4eb6a10f5 Nikolai Weibull committed Dec 16, 2012
View
11 Makefile
@@ -12,13 +12,20 @@ shell_quote = $(subst $(space),\ ,$(1))
# 1: File
# 2: Target
-# 3: Mode
-define GROUP_template_file
+define GROUP_template_diff_file
GROUP_diff_target := $(2).diff
.PHONY diff: $$(GROUP_diff_target)
$$(GROUP_diff_target):
@$$(DIFF) -u $(2) $(1) || true
+endef
+
+# 1: File
+# 2: Target
+# 3: Mode
+define GROUP_template_file
+$(call GROUP_template_diff_file,$(1),$(2))
+
install: $(2)
$(2): $(1)
$$(INSTALL) -D --mode=$(if $(3),$(3),644) --preserve-timestamps $$< $$(call shell_quote,$$@)
View
43 os/Darwin/Library/LaunchAgents/se.disu.backup.daily.plist
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
+ "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+ <dict>
+ <key>Label</key>
+ <string>se.disu.backup.daily</string>
+
+ <key>EnvironmentVariables</key>
+ <dict>
+ <key>PATH</key>
+ <string>/opt/local/bin:/usr/bin:/bin</string>
+ </dict>
+
+ <key>ProgramArguments</key>
+ <array>
+ <string>/Users/now/bin/backup-home</string>
+ <string>diff</string>
+ </array>
+
+ <key>Nice</key>
+ <integer>1</integer>
+
+ <key>StartCalendarInterval</key>
+ <dict>
+ <key>Minute</key>
+ <integer>0</integer>
+
+ <key>Hour</key>
+ <integer>21</integer>
+
+ <key>Weekday</key>
+ <array>
+ <integer>2</integer>
+ <integer>3</integer>
+ <integer>4</integer>
+ <integer>5</integer>
+ <integer>6</integer>
+ <integer>7</integer>
+ </array>
+ </dict>
+ </dict>
+</plist>
View
35 os/Darwin/Library/LaunchAgents/se.disu.backup.weekly.plist
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
+ "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+ <dict>
+ <key>Label</key>
+ <string>se.disu.backup.weekly</string>
+
+ <key>EnvironmentVariables</key>
+ <dict>
+ <key>PATH</key>
+ <string>/opt/local/bin:/usr/bin:/bin</string>
+ </dict>
+
+ <key>ProgramArguments</key>
+ <array>
+ <string>/Users/now/bin/backup-home</string>
+ </array>
+
+ <key>Nice</key>
+ <integer>1</integer>
+
+ <key>StartCalendarInterval</key>
+ <dict>
+ <key>Minute</key>
+ <integer>0</integer>
+
+ <key>Hour</key>
+ <integer>21</integer>
+
+ <key>Weekday</key>
+ <integer>1</integer>
+ </dict>
+ </dict>
+</plist>
View
27 os/Darwin/os.mk
@@ -0,0 +1,27 @@
+DOTFILES = \
+ os/Darwin/Library/LaunchAgents/se.disu.backup.daily.plist \
+ os/Darwin/Library/LaunchAgents/se.disu.backup.weekly.plist
+
+LAUNCHCTL = launchctl
+
+# 1: File
+# 2: Target
+define LAUNCHCTL_template_file
+$(call GROUP_template_diff_file,$(1),$(2))
+
+install: $(2)
+$(2): $(1)
+ $$(INSTALL) -D --mode=644 --preserve-timestamps $$< $$(call shell_quote,$$@)
+ $$(LAUNCHCTL) unload $(2)
+ $$(LAUNCHCTL) load $(2)
+
+endef
+
+# 1: Files
+# 2: Parent directory
+# 4: Prefix to strip
+define LAUNCHCTL_template
+$(eval $(foreach file,$(1),$(call LAUNCHCTL_template_file,$(file),$(2)/$(file:$(3)%=%))))
+endef
+
+$(call LAUNCHCTL_template,$(DOTFILES),$(userconfdir),os/Darwin/)

0 comments on commit f1a6f5b

Please sign in to comment.
Something went wrong with that request. Please try again.