summaryrefslogtreecommitdiff
path: root/Propellor
diff options
context:
space:
mode:
authorJoey Hess2014-03-31 15:05:13 -0400
committerJoey Hess2014-03-31 15:05:13 -0400
commitbba03dc89636295073d1719ad4ebb56da658c6a6 (patch)
tree678d6285a2e5bf0c808320540136b4b146fd1497 /Propellor
parent35d79711fcbb2f2f436e50a734ae7d64dda78ea8 (diff)
propellor spin
Diffstat (limited to 'Propellor')
-rw-r--r--Propellor/CmdLine.hs18
1 files changed, 10 insertions, 8 deletions
diff --git a/Propellor/CmdLine.hs b/Propellor/CmdLine.hs
index c36c1377..c5224682 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)