From 79f1a6c67b72b695b23db69aaa606dc79c313d86 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 17 Jul 2014 15:33:02 -0400 Subject: propellor spin --- config-joey.hs | 10 ++++++---- src/Propellor/Property/Cron.hs | 2 +- src/Propellor/Property/SiteSpecific/JoeySites.hs | 23 +++++++++++++++++++++++ 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/config-joey.hs b/config-joey.hs index d4af95ea..ec4e6aa9 100644 --- a/config-joey.hs +++ b/config-joey.hs @@ -97,7 +97,7 @@ hosts = -- (o) ` , "--exclude=/home/joey/lib" , "--exclude=.*/tmp/" ] Obnam.OnlyClient - `requires` Gpg.keyImported "" "root" + `requires` Gpg.keyImported "98147487" "root" `requires` Ssh.keyImported SshRsa "root" (Context "kite.kitenet.net") @@ -175,12 +175,13 @@ hosts = -- (o) ` & alias "eubackup.kitenet.net" & Apt.installed ["obnam", "sshfs", "rsync"] - & JoeySites.githubBackup & JoeySites.obnamRepos ["wren", "pell", "kite"] - & Ssh.knownHost hosts "usw-s002.rsync.net" "joey" + & JoeySites.githubBackup + & JoeySites.rsyncNetBackup hosts + & JoeySites.backupsBackedupTo hosts "usbackup.kitenet.net" "lib/backup/eubackup" & alias "podcatcher.kitenet.net" - & Apt.installed ["git-annex"] + & JoeySites.podcatcher & alias "znc.kitenet.net" & JoeySites.ircBouncer @@ -364,6 +365,7 @@ monsters = -- but do want to track their public keys etc. & ipv4 "67.223.19.96" & ipv6 "2001:4978:f:2d9::2" & alias "backup.kitenet.net" + & alias "usbackup.kitenet.net" & sshPubKey "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAokMXQiX/NZjA1UbhMdgAscnS5dsmy+Q7bWrQ6tsTZ/o+6N/T5cbjoBHOdpypXJI3y/PiJTDJaQtXIhLa8gFg/EvxMnMz/KG9skADW1361JmfCc4BxicQIO2IOOe6eilPr+YsnOwiHwL0vpUnuty39cppuMWVD25GzxXlS6KQsLCvXLzxLLuNnGC43UAM0q4UwQxDtAZEK1dH2o3HMWhgMP2qEQupc24dbhpO3ecxh2C9678a3oGDuDuNf7mLp3s7ptj5qF3onitpJ82U5o7VajaHoygMaSRFeWxP2c13eM57j3bLdLwxVXFhePcKXARu1iuFTLS5uUf3hN6MkQcOGw==" , host "wren.kitenet.net" & ipv4 "80.68.85.49" diff --git a/src/Propellor/Property/Cron.hs b/src/Propellor/Property/Cron.hs index 5b070eff..d7138e3b 100644 --- a/src/Propellor/Property/Cron.hs +++ b/src/Propellor/Property/Cron.hs @@ -42,7 +42,7 @@ job desc times user cddir command = cronjobfile `File.hasContent` -- | Installs a cron job, and runs it niced and ioniced. niceJob :: Desc -> CronTimes -> UserName -> FilePath -> String -> Property niceJob desc times user cddir command = job desc times user cddir - ("nice ionice -c 3 " ++ command) + ("nice ionice -c 3 sh -c " ++ shellEscape command) -- | Installs a cron job to run propellor. runPropellor :: CronTimes -> Property diff --git a/src/Propellor/Property/SiteSpecific/JoeySites.hs b/src/Propellor/Property/SiteSpecific/JoeySites.hs index c770907b..fbb1492b 100644 --- a/src/Propellor/Property/SiteSpecific/JoeySites.hs +++ b/src/Propellor/Property/SiteSpecific/JoeySites.hs @@ -348,8 +348,26 @@ githubBackup = propertyList "github-backup box" , let f = "/home/joey/.github-keys" in File.hasPrivContent f anyContext `onChange` File.ownerGroup f "joey" "joey" + , Cron.niceJob "github-backup run" "30 4 * * *" "joey" + "/home/joey/lib/backup" $ intercalate "&" + [ "mkdir -p github" + , "cd github" + , "$HOME/.github-keys && github-backup joeyh" + ] ] +rsyncNetBackup :: [Host] -> Property +rsyncNetBackup hosts = Cron.niceJob "rsync.net copied in daily" "30 5 * * *" + "joey" "/home/joey/lib/backup" "mkdir -p rsync.net && rsync --delete -az 2318@usw-s002.rsync.net: rsync.net" + `requires` Ssh.knownHost hosts "usw-s002.rsync.net" "joey" + +backupsBackedupTo :: [Host] -> HostName -> FilePath -> Property +backupsBackedupTo hosts desthost destdir = Cron.niceJob "backups copied to usbackup weekly" + "1 1 * * 3" "joey" "/" cmd + `requires` Ssh.knownHost hosts desthost "joey" + where + cmd = "rsync -az --delete /home/joey/lib/backup " ++ desthost ++ ":" ++ destdir + obnamRepos :: [String] -> Property obnamRepos rs = propertyList ("obnam repos for " ++ unwords rs) (mkbase : map mkrepo rs) @@ -360,3 +378,8 @@ obnamRepos rs = propertyList ("obnam repos for " ++ unwords rs) mkdir d = File.dirExists d `before` File.ownerGroup d "joey" "joey" +podcatcher :: Property +podcatcher = Cron.niceJob "podcatcher run hourly" "55 * * * *" + "joey" "/home/joey/lib/sound/podcasts" + "xargs git-annex importfeed -c annex.genmetadata=true < feeds; mr --quiet update" + `requires` Apt.installed ["git-annex"] -- cgit v1.2.3