From 6d5919199d49384240e13ebee67348a35f3ef85b Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 30 Mar 2014 19:19:29 -0400 Subject: [PATCH] propellor spin --- CmdLine.hs | 2 ++ PrivData.hs | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/CmdLine.hs b/CmdLine.hs index 7f5cd79..1d7316f 100644 --- a/CmdLine.hs +++ b/CmdLine.hs @@ -54,6 +54,7 @@ spin host = do url <- getUrl privdata <- gpgDecrypt (privDataFile host) void $ boolSystem "git" [Param "commit", Param "-a", Param "-m", Param "propellor spin"] + void $ boolSystem "git" [Param "push"] withHandle StdinHandle createProcessSuccess (proc "ssh" ["root@"++host, bootstrap url]) $ \h -> do hPutStr h $ unlines $ map (privDataMarker ++) $ lines privdata @@ -79,6 +80,7 @@ boot props = do . filter (privDataMarker `isPrefixOf`) . lines <$> getContents + makePrivDataDir writeFileProtected privDataLocal (unlines privdata) ensureProperties props diff --git a/PrivData.hs b/PrivData.hs index c0c07fb..a74cb20 100644 --- a/PrivData.hs +++ b/PrivData.hs @@ -39,12 +39,16 @@ getPrivData field = do setPrivData :: HostName -> PrivDataField -> String -> IO () setPrivData host field value = do + makePrivDataDir let f = privDataFile host m <- fromMaybe M.empty . readish <$> gpgDecrypt f let m' = M.insert field value m gpgEncrypt f (show m') void $ boolSystem "git" [Param "add", File f] +makePrivDataDir :: IO () +makePrivDataDir = createDirectoryIfMissing False privDataDir + privDataDir :: FilePath privDataDir = "privdata"