reformat
This commit is contained in:
parent
09fc55586f
commit
efa3283975
|
@ -197,24 +197,28 @@ spin hn hst = do
|
||||||
void $ gitCommit [Param "--allow-empty", Param "-a", Param "-m", Param "propellor spin"]
|
void $ gitCommit [Param "--allow-empty", Param "-a", Param "-m", Param "propellor spin"]
|
||||||
void $ boolSystem "git" [Param "push"]
|
void $ boolSystem "git" [Param "push"]
|
||||||
cacheparams <- toCommand <$> sshCachingParams hn
|
cacheparams <- toCommand <$> sshCachingParams hn
|
||||||
go cacheparams =<< hostprivdata
|
comm cacheparams =<< hostprivdata
|
||||||
unlessM (boolSystem "ssh" (map Param (cacheparams ++ ["-t", user, runcmd]))) $
|
unlessM (boolSystem "ssh" (map Param (cacheparams ++ ["-t", user, runcmd]))) $
|
||||||
error $ "remote propellor failed (running: " ++ runcmd ++")"
|
error $ "remote propellor failed (running: " ++ runcmd ++")"
|
||||||
where
|
where
|
||||||
hostprivdata = show . filterPrivData hst <$> decryptPrivData
|
hostprivdata = show . filterPrivData hst <$> decryptPrivData
|
||||||
|
|
||||||
go cacheparams privdata = withBothHandles createProcessSuccess (proc "ssh" $ cacheparams ++ [user, bootstrapcmd]) $ \(toh, fromh) -> do
|
comm cacheparams privdata =
|
||||||
let loop = do
|
withBothHandles createProcessSuccess
|
||||||
status <- getMarked fromh statusMarker
|
(proc "ssh" $ cacheparams ++ [user, bootstrapcmd])
|
||||||
case readish =<< status of
|
(comm' cacheparams privdata)
|
||||||
Just NeedRepoUrl -> do
|
comm' cacheparams privdata (toh, fromh) = loop
|
||||||
|
where
|
||||||
|
loop = dispatch =<< (maybe Nothing readish <$> getMarked fromh statusMarker)
|
||||||
|
dispatch (Just NeedRepoUrl) = do
|
||||||
sendMarked toh repoUrlMarker
|
sendMarked toh repoUrlMarker
|
||||||
=<< (fromMaybe "" <$> getRepoUrl)
|
=<< (fromMaybe "" <$> getRepoUrl)
|
||||||
loop
|
loop
|
||||||
Just NeedPrivData -> do
|
dispatch (Just NeedPrivData) = do
|
||||||
sendprivdata toh privdata
|
sendprivdata toh privdata
|
||||||
loop
|
loop
|
||||||
Just NeedGitPush -> void $ actionMessage "Git update" $ do
|
dispatch (Just NeedGitPush) = do
|
||||||
|
void $ actionMessage ("Sending git update to " ++ hn) $ do
|
||||||
sendMarked toh gitPushMarker ""
|
sendMarked toh gitPushMarker ""
|
||||||
let p = (proc "git" ["upload-pack", "."])
|
let p = (proc "git" ["upload-pack", "."])
|
||||||
{ std_in = UseHandle fromh
|
{ std_in = UseHandle fromh
|
||||||
|
@ -222,29 +226,26 @@ spin hn hst = do
|
||||||
}
|
}
|
||||||
(Nothing, Nothing, Nothing, h) <- createProcess p
|
(Nothing, Nothing, Nothing, h) <- createProcess p
|
||||||
r <- waitForProcess h
|
r <- waitForProcess h
|
||||||
-- no more protocol possible after
|
-- no more protocol possible after git push
|
||||||
-- git push
|
|
||||||
hClose fromh
|
hClose fromh
|
||||||
hClose toh
|
hClose toh
|
||||||
return (r == ExitSuccess)
|
return (r == ExitSuccess)
|
||||||
Just NeedGitClone -> do
|
dispatch (Just NeedGitClone) = do
|
||||||
hClose toh
|
hClose toh
|
||||||
hClose fromh
|
hClose fromh
|
||||||
sendGitClone hn
|
sendGitClone hn
|
||||||
go cacheparams privdata
|
comm cacheparams privdata
|
||||||
-- Ready is only sent by old versions of
|
-- Ready is only sent by old versions of
|
||||||
-- propellor. They expect to get privdata,
|
-- propellor. They expect to get privdata,
|
||||||
-- and then no more protocol communication.
|
-- and then no more protocol communication.
|
||||||
Just Ready -> do
|
dispatch (Just Ready) = do
|
||||||
sendprivdata toh privdata
|
sendprivdata toh privdata
|
||||||
hClose toh
|
hClose toh
|
||||||
|
|
||||||
-- Display remaining output.
|
-- Display remaining output.
|
||||||
void $ tryIO $ forever $
|
void $ tryIO $ forever $
|
||||||
showremote =<< hGetLine fromh
|
showremote =<< hGetLine fromh
|
||||||
hClose fromh
|
hClose fromh
|
||||||
Nothing -> return ()
|
dispatch Nothing = return ()
|
||||||
loop
|
|
||||||
|
|
||||||
user = "root@"++hn
|
user = "root@"++hn
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue