on master help sign in
allow user to set initial keystore password
commit76d44d4520c65cfe3dfb957f6f3e053e1f6809d5 authorhsloan <ishaqsloan@gmail.com> dateMon 5 Nov 2018, 16:57 (8 years ago) parent26158cf
1 file changed+12−2
lib/command/src/Obelisk/Command/Deploy.hs+12−2
lib/command/src/Obelisk/Command/Deploy.hs+12−2
@@ -8,7 +8,7 @@ module Obelisk.Command.Deploy where
88
99import Control.Lens
1010import Control.Monad
11−import Control.Monad.Catch (Exception (displayException), MonadThrow, throwM, try)
11+import Control.Monad.Catch (Exception (displayException), MonadThrow, throwM, try, bracket_)
1212import Control.Monad.IO.Class (liftIO)
1313import Data.Aeson (FromJSON, ToJSON, encode, eitherDecode)
1414import Data.Bits
@@ -25,6 +25,7 @@ import GHC.Generics
2525import System.Directory
2626import System.Environment (getEnvironment)
2727import System.FilePath
28+import System.IO
2829import System.Posix.Files
2930import System.Process (delegate_ctlc, env, proc, readCreateProcess, cwd)
3031import Text.URI (URI)
@@ -179,10 +180,15 @@ deployMobile platform mobileArgs = withProjectRoot "." $ \root -> do
179180 when (not hasKeystore) $ do
180181 -- TODO log instructions for how to modify the keystore
181182 putLog Notice $ "Creating keystore: " <> T.pack keystorePath
183+ putLog Notice "Enter a keystore password: "
184+ keyStorePassword <- liftIO $ withEcho False getLine
185+ putLog Notice "Re-enter the keystore password: "
186+ keyStorePassword' <- liftIO $ withEcho False getLine
187+ unless (keyStorePassword' == keyStorePassword) $ failWith "passwords do not match"
182188 let keyToolConf = KeytoolConfig
183189 { _keytoolConfig_keystore = keystorePath
184190 , _keytoolConfig_alias = "obelisk"
185− , _keytoolConfig_storepass = "obelisk"
191+ , _keytoolConfig_storepass = keyStorePassword
186192 , _keytoolConfig_dname = "CN=mqttserver.ibm.com, OU=ID, O=IBM, L=Hursley, S=Hants, C=GB" -- TODO Read these from config?
187193 }
188194 createKeystore root $ keyToolConf
@@ -202,6 +208,10 @@ deployMobile platform mobileArgs = withProjectRoot "." $ \root -> do
202208 , _target_expr = Just $ "with (import " <> srcDir <> " {}); " <> platform <> ".frontend.override (drv: { releaseKey = (if builtins.isNull drv.releaseKey then {} else drv.releaseKey) // " <> T.unpack releaseKey <> "; })"
203209 }
204210 callProcessAndLogOutput (Notice, Error) $ proc (result </> "bin" </> "deploy") mobileArgs
211+ where
212+ withEcho showEcho f = do
213+ prevEcho <- hGetEcho stdin
214+ bracket_ (hSetEcho stdin showEcho) (hSetEcho stdin prevEcho) f
205215
206216data KeytoolConfig = KeytoolConfig
207217 { _keytoolConfig_keystore :: FilePath