summaryrefslogtreecommitdiff
path: root/Propellor/Property
diff options
context:
space:
mode:
authorJoey Hess2014-04-02 18:36:42 -0400
committerJoey Hess2014-04-02 18:36:42 -0400
commitcd10ceb976c38b2df0101a601022918852def4b3 (patch)
treee69193ebc200e4027452d71fe6e0ca4e8d805486 /Propellor/Property
parentb456e8aedc3328dd30113b849a4b977c6543c63b (diff)
generalized git-annex autobuilder to not need a rsync password
Diffstat (limited to 'Propellor/Property')
-rw-r--r--Propellor/Property/SiteSpecific/GitAnnexBuilder.hs20
1 files changed, 13 insertions, 7 deletions
diff --git a/Propellor/Property/SiteSpecific/GitAnnexBuilder.hs b/Propellor/Property/SiteSpecific/GitAnnexBuilder.hs
index 8fcfbd6a..7b823ed6 100644
--- a/Propellor/Property/SiteSpecific/GitAnnexBuilder.hs
+++ b/Propellor/Property/SiteSpecific/GitAnnexBuilder.hs
@@ -12,8 +12,8 @@ builduser = "builder"
builddir :: FilePath
builddir = "gitbuilder"
-builder :: Architecture -> CronTimes -> Property
-builder arch crontimes = combineProperties "gitannexbuilder"
+builder :: Architecture -> CronTimes -> Bool -> Property
+builder arch crontimes rsyncupload = combineProperties "gitannexbuilder"
[ Apt.stdSourcesList Unstable
, Apt.buildDep ["git-annex"]
, Apt.installed ["git", "rsync", "moreutils", "ca-certificates",
@@ -38,11 +38,17 @@ builder arch crontimes = combineProperties "gitannexbuilder"
, Property "rsync password" $ do
d <- homedir
let f = d </> "rsyncpassword"
- withPrivData (Password builduser) $ \p -> do
- oldp <- catchDefaultIO "" $ readFileStrict f
- if p /= oldp
- then makeChange $ writeFile f p
- else noChange
+ if rsyncupload
+ then withPrivData (Password builduser) $ \p -> do
+ oldp <- catchDefaultIO "" $ readFileStrict f
+ if p /= oldp
+ then makeChange $ writeFile f p
+ else noChange
+ else do
+ ifM (doesFileExist f)
+ ( noChange
+ , makeChange $ writeFile f "no password configured"
+ )
]
where
homedir = fromMaybe ("/home/" ++ builduser) <$> User.homedir builduser