From 1a906048511cf606b15d28c2f151ef8e1d848a50 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 18 Nov 2014 00:41:06 -0400 Subject: ssh won't allocate a tty; work around stdin is not a terminal, drat ssh I don't much like this workaround --- src/Propellor/CmdLine.hs | 4 ++-- src/Propellor/Message.hs | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Propellor/CmdLine.hs b/src/Propellor/CmdLine.hs index d6c85c08..21c4d95e 100644 --- a/src/Propellor/CmdLine.hs +++ b/src/Propellor/CmdLine.hs @@ -189,7 +189,7 @@ spin hn hst = do where hostprivdata = show . filterPrivData hst <$> decryptPrivData - go cacheparams url privdata = withBothHandles createProcessSuccess (proc "ssh" $ cacheparams ++ ["-t", user, bootstrapcmd]) $ \(toh, fromh) -> do + go cacheparams url privdata = withBothHandles createProcessSuccess (proc "ssh" $ cacheparams ++ [user, bootstrapcmd]) $ \(toh, fromh) -> do let finish = do senddata toh "privdata" privDataMarker privdata hClose toh @@ -303,6 +303,7 @@ boot h = do makePrivDataDir maybe noop (writeFileProtected privDataLocal) $ fromMarked privDataMarker reply + forceConsoleMode mainProperties h getUrl :: IO String @@ -364,4 +365,3 @@ sshCachingParams hn = do [ Param "localhost" ] nukeFile f tenminutes = 600 -sshCachingParams hn = return [] diff --git a/src/Propellor/Message.hs b/src/Propellor/Message.hs index e184a59e..3671e05b 100644 --- a/src/Propellor/Message.hs +++ b/src/Propellor/Message.hs @@ -6,20 +6,26 @@ import System.Console.ANSI import System.IO import System.Log.Logger import "mtl" Control.Monad.Reader +import Control.Applicative +import Data.Maybe import Propellor.Types import Utility.Monad +import Utility.Env data MessageHandle = ConsoleMessageHandle | TextMessageHandle mkMessageHandle :: IO MessageHandle -mkMessageHandle = ifM (hIsTerminalDevice stdout) +mkMessageHandle = ifM (hIsTerminalDevice stdout <||> (isJust <$> getEnv "TERM")) ( return ConsoleMessageHandle , return TextMessageHandle ) +forceConsoleMode :: IO () +forceConsoleMode = void $ setEnv "TERM" "vt100" False + whenConsole :: MessageHandle -> IO () -> IO () whenConsole ConsoleMessageHandle a = a whenConsole _ _ = return () -- cgit v1.2.3