on master help sign in
Fail 'ob deploy init' when not given a ssh-key
commit16c55aa874b6ee115579f92e0fa945df3e6c66dd authorAlexandre Esteves <alexandre.fmp.esteves@gmail.com> dateWed 30 May 2018, 23:01 (8 years ago) parent70ac8ef
1 file changed+10−10
lib/command/src/Obelisk/Command/Deploy.hs+10−10
lib/command/src/Obelisk/Command/Deploy.hs+10−10
@@ -43,16 +43,16 @@ deployInit thunkPtr configDir deployDir sshKeyPath hostnames = do
4343 , configDir
4444 , deployDir </> "config"
4545 ]
46− keyExists <- liftIO $ doesFileExist sshKeyPath
47− when keyExists $ do
48− let localKey = deployDir </> "ssh_key"
49− callProcessAndLogOutput (Notice, Error) $
50− cp [sshKeyPath, localKey]
51− liftIO $ setFileMode localKey $ ownerReadMode .|. ownerWriteMode
52− liftIO $ writeFile (deployDir </> "backend_hosts") $ unlines hostnames
53− forM_ hostnames $ \hostname -> do
54− putLog Notice $ "Verifying host keys (" <> T.pack hostname <> ")"
55− verifyHostKey (deployDir </> "backend_known_hosts") localKey hostname
46+ localKey <- liftIO (doesFileExist sshKeyPath) >>= \case
47+ False -> failWith $ T.pack $ "ob deploy init: file does not exist: " <> sshKeyPath
48+ True -> pure $ deployDir </> "ssh_key"
49+ callProcessAndLogOutput (Notice, Error) $
50+ cp [sshKeyPath, localKey]
51+ liftIO $ setFileMode localKey $ ownerReadMode .|. ownerWriteMode
52+ liftIO $ writeFile (deployDir </> "backend_hosts") $ unlines hostnames
53+ forM_ hostnames $ \hostname -> do
54+ putLog Notice $ "Verifying host keys (" <> T.pack hostname <> ")"
55+ verifyHostKey (deployDir </> "backend_known_hosts") localKey hostname
5656 liftIO $ createThunk (deployDir </> "src") thunkPtr
5757 liftIO $ setupObeliskImpl deployDir
5858 initGit deployDir