From 392a0d3c1cc175161cd0c6d82b098e92d6adf9e6 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 22 Nov 2014 16:06:44 -0400 Subject: propellor spin --- src/Propellor/CmdLine.hs | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'src/Propellor/CmdLine.hs') diff --git a/src/Propellor/CmdLine.hs b/src/Propellor/CmdLine.hs index e719e149..b44cbc28 100644 --- a/src/Propellor/CmdLine.hs +++ b/src/Propellor/CmdLine.hs @@ -166,8 +166,8 @@ spin target relay hst = do void $ actionMessage "Push to central git repository" $ boolSystem "git" [Param "push"] - cacheparams <- toCommand <$> sshCachingParams hn - when (isJust relay) $ + cacheparams <- toCommand <$> sshCachingParams hn viarelay + when viarelay $ void $ boolSystem "ssh-add" [] -- Install, or update the remote propellor. @@ -175,12 +175,14 @@ spin target relay hst = do (proc "ssh" $ cacheparams ++ [user, updatecmd]) -- And now we can run it. - unlessM (boolSystem "ssh" (map Param $ cacheparams ++ runparams)) $ + unlessM (boolSystem "ssh" (map Param $ cacheparams ++ ["-t", user, runcmd])) $ error $ "remote propellor failed" where hn = fromMaybe target relay user = "root@"++hn + relaying = relay == Just target + viarelay = isJust relay && not relaying mkcmd = shellWrap . intercalate " ; " @@ -193,22 +195,16 @@ spin target relay hst = do , "else " ++ intercalate " && " [ "cd " ++ localdir , "if ! test -x ./propellor; then make deps build; fi" - , if isNothing relay - -- Still using --boot for back-compat... - then "./propellor --boot " ++ target - else "./propellor --continue " ++ + , if viarelay + then "./propellor --continue " ++ shellEscape (show (Update (Just target))) + -- Still using --boot for back-compat... + else "./propellor --boot " ++ target ] , "fi" ] runcmd = mkcmd [ "cd " ++ localdir ++ " && ./propellor " ++ cmd ] - cmd = if isNothing relay - then "--continue " ++ shellEscape (show (SimpleRun target)) - else "--serialized " ++ shellEscape (show (Spin target (Just target))) - runparams = catMaybes - [ if isJust relay then Just "-A" else Nothing - , Just "-t" - , Just user - , Just runcmd - ] + cmd = if viarelay + then "--serialized " ++ shellEscape (show (Spin target (Just target))) + else "--continue " ++ shellEscape (show (SimpleRun target)) -- cgit v1.2.3