summaryrefslogtreecommitdiff
path: root/src/Propellor
diff options
context:
space:
mode:
authorJoey Hess2014-11-22 15:48:17 -0400
committerJoey Hess2014-11-22 15:48:17 -0400
commit395f311e1e07e0da31b48dc1bd0c1f5882fc3627 (patch)
tree5c490b758589d68626f7236c01511cfbaa161fb1 /src/Propellor
parent435ba8ca41668bf959a2dc3b3f2cf7b2ce3d8b97 (diff)
propellor spin
Diffstat (limited to 'src/Propellor')
-rw-r--r--src/Propellor/CmdLine.hs6
-rw-r--r--src/Propellor/Server.hs31
2 files changed, 20 insertions, 17 deletions
diff --git a/src/Propellor/CmdLine.hs b/src/Propellor/CmdLine.hs
index bb9b470e..7a4fdd7c 100644
--- a/src/Propellor/CmdLine.hs
+++ b/src/Propellor/CmdLine.hs
@@ -196,10 +196,10 @@ spin target relay hst = do
, "fi"
]
- runcmd = mkcmd [ "cd " ++ localdir ++ " && ./propellor " ++ cmd ]
+ runcmd = mkcmd [ "cd " ++ localdir ++ " && ./propellor --continue " ++ shellEscape (show cmd) ]
cmd = if isNothing relay
- then "--continue " ++ shellEscape (show (SimpleRun target))
- else "--spin " ++ shellEscape target
+ then SimpleRun target
+ else Spin target relay
runparams = catMaybes
[ if isJust relay then Just "-A" else Nothing
, Just "-t"
diff --git a/src/Propellor/Server.hs b/src/Propellor/Server.hs
index fe90a456..be2eb1d3 100644
--- a/src/Propellor/Server.hs
+++ b/src/Propellor/Server.hs
@@ -66,51 +66,54 @@ updateServer :: HostName -> Maybe HostName -> Host -> (((Handle, Handle) -> IO (
updateServer target relay hst connect = connect go
where
hn = fromMaybe target relay
+ relaying = relay == Just target
+
go (toh, fromh) = do
let loop = go (toh, fromh)
+ let restart = updateServer hn relay hst connect
+ let done = return ()
v <- (maybe Nothing readish <$> getMarked fromh statusMarker)
case v of
(Just NeedRepoUrl) -> do
sendRepoUrl toh
loop
(Just NeedPrivData) -> do
- sendPrivData hn hst toh relay
+ sendPrivData hn hst toh relaying
loop
- (Just NeedGitPush) -> do
- sendGitUpdate hn fromh toh
- -- no more protocol possible after git push
- hClose fromh
- hClose toh
(Just NeedGitClone) -> do
hClose toh
hClose fromh
sendGitClone hn
- updateServer hn relay hst connect
+ restart
(Just NeedPrecompiled) -> do
hClose toh
hClose fromh
sendPrecompiled hn
- updateServer hn relay hst connect
- Nothing -> return ()
+ restart
+ (Just NeedGitPush) -> do
+ sendGitUpdate hn fromh toh
+ hClose fromh
+ hClose toh
+ done
+ Nothing -> done
sendRepoUrl :: Handle -> IO ()
sendRepoUrl toh = sendMarked toh repoUrlMarker =<< (fromMaybe "" <$> getRepoUrl)
-sendPrivData :: HostName -> Host -> Handle -> Maybe HostName -> IO ()
-sendPrivData hn hst toh target = do
+sendPrivData :: HostName -> Host -> Handle -> Bool -> IO ()
+sendPrivData hn hst toh relaying = do
privdata <- getdata
void $ actionMessage ("Sending privdata (" ++ show (length privdata) ++ " bytes) to " ++ hn) $ do
sendMarked toh privDataMarker privdata
return True
where
getdata
- | isNothing target =
- show . filterPrivData hst <$> decryptPrivData
- | otherwise = do
+ | relaying = do
let f = privDataRelay hn
d <- readFileStrictAnyEncoding f
nukeFile f
return d
+ | otherwise = show . filterPrivData hst <$> decryptPrivData
sendGitUpdate :: HostName -> Handle -> Handle -> IO ()
sendGitUpdate hn fromh toh =