From bba03dc89636295073d1719ad4ebb56da658c6a6 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 31 Mar 2014 15:05:13 -0400 Subject: [PATCH] propellor spin --- Propellor/CmdLine.hs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/Propellor/CmdLine.hs b/Propellor/CmdLine.hs index c36c137..c522468 100644 --- a/Propellor/CmdLine.hs +++ b/Propellor/CmdLine.hs @@ -75,15 +75,11 @@ spin host = do status <- getstatus fromh `catchIO` error "protocol error" case status of NeedKeyRing -> do - d <- BL.readFile keyring - putStr $ "Sending " ++ keyring ++ " (" ++ show (BL.length d) ++ " bytes) to " ++ host ++ "..." - hFlush stdout - hPutStrLn toh $ toMarked keyringMarker $ w82s $ BL.unpack $ B64.encode d - hFlush toh - putStrLn "done" + d <- w82s . BL.unpack . B64.encode + <$> BL.readFile keyring + senddata toh keyring keyringMarker d HaveKeyRing -> noop - hPutStrLn toh $ toMarked privDataMarker privdata - hFlush toh + senddata toh (privDataFile host) privDataMarker privdata hClose toh -- Display remaining output. @@ -115,6 +111,12 @@ spin host = do getstatus h Just status -> return status showremote s = putStrLn s + senddata toh f marker s = do + putStr $ "Sending " ++ f ++ " (" ++ show (length s) ++ " bytes) to " ++ host ++ "..." + hFlush stdout + hPutStrLn toh $ toMarked marker s + hFlush toh + putStrLn "done" data BootStrapStatus = HaveKeyRing | NeedKeyRing deriving (Read, Show, Eq)