avoid loop after uploading precompiled tarball
The localdir still has no .git repo, so it looped.
This commit is contained in:
parent
239581c759
commit
868d7cdcb5
|
@ -42,11 +42,12 @@ spin target relay hst = do
|
||||||
void $ boolSystem "ssh-add" []
|
void $ boolSystem "ssh-add" []
|
||||||
|
|
||||||
-- Install, or update the remote propellor.
|
-- Install, or update the remote propellor.
|
||||||
updateServer target relay hst $ withBothHandles createProcessSuccess
|
updateServer target relay hst
|
||||||
(proc "ssh" $ cacheparams ++ [user, updatecmd])
|
(proc "ssh" $ cacheparams ++ [user, shellWrap probecmd])
|
||||||
|
(proc "ssh" $ cacheparams ++ [user, shellWrap updatecmd])
|
||||||
|
|
||||||
-- And now we can run it.
|
-- And now we can run it.
|
||||||
unlessM (boolSystem "ssh" (map Param $ cacheparams ++ ["-t", user, runcmd])) $
|
unlessM (boolSystem "ssh" (map Param $ cacheparams ++ ["-t", user, shellWrap runcmd])) $
|
||||||
error $ "remote propellor failed"
|
error $ "remote propellor failed"
|
||||||
where
|
where
|
||||||
hn = fromMaybe target relay
|
hn = fromMaybe target relay
|
||||||
|
@ -55,27 +56,27 @@ spin target relay hst = do
|
||||||
relaying = relay == Just target
|
relaying = relay == Just target
|
||||||
viarelay = isJust relay && not relaying
|
viarelay = isJust relay && not relaying
|
||||||
|
|
||||||
mkcmd = shellWrap . intercalate " ; "
|
probecmd = intercalate " ; "
|
||||||
|
|
||||||
updatecmd = mkcmd
|
|
||||||
[ "if [ ! -d " ++ localdir ++ "/.git ]"
|
[ "if [ ! -d " ++ localdir ++ "/.git ]"
|
||||||
, "then (" ++ intercalate " && "
|
, "then (" ++ intercalate " && "
|
||||||
[ "if ! git --version || ! make --version; then apt-get update && apt-get --no-install-recommends --no-upgrade -y install git make; fi"
|
[ "if ! git --version || ! make --version; then apt-get update && apt-get --no-install-recommends --no-upgrade -y install git make; fi"
|
||||||
, "echo " ++ toMarked statusMarker (show NeedGitClone)
|
, "echo " ++ toMarked statusMarker (show NeedGitClone)
|
||||||
] ++ ") || echo " ++ toMarked statusMarker (show NeedPrecompiled)
|
] ++ ") || echo " ++ toMarked statusMarker (show NeedPrecompiled)
|
||||||
, "else " ++ intercalate " && "
|
, "else " ++ updatecmd
|
||||||
[ "cd " ++ localdir
|
|
||||||
, "if ! test -x ./propellor; then make deps build; fi"
|
|
||||||
, if viarelay
|
|
||||||
then "./propellor --continue " ++
|
|
||||||
shellEscape (show (Update (Just target)))
|
|
||||||
-- Still using --boot for back-compat...
|
|
||||||
else "./propellor --boot " ++ target
|
|
||||||
]
|
|
||||||
, "fi"
|
, "fi"
|
||||||
]
|
]
|
||||||
|
|
||||||
runcmd = mkcmd [ "cd " ++ localdir ++ " && ./propellor " ++ cmd ]
|
updatecmd = intercalate " && "
|
||||||
|
[ "cd " ++ localdir
|
||||||
|
, "if ! test -x ./propellor; then make deps build; fi"
|
||||||
|
, if viarelay
|
||||||
|
then "./propellor --continue " ++
|
||||||
|
shellEscape (show (Update (Just target)))
|
||||||
|
-- Still using --boot for back-compat...
|
||||||
|
else "./propellor --boot " ++ target
|
||||||
|
]
|
||||||
|
|
||||||
|
runcmd = "cd " ++ localdir ++ " && ./propellor " ++ cmd
|
||||||
cmd = if viarelay
|
cmd = if viarelay
|
||||||
then "--serialized " ++ shellEscape (show (Spin target (Just target)))
|
then "--serialized " ++ shellEscape (show (Spin target (Just target)))
|
||||||
else "--continue " ++ shellEscape (show (SimpleRun target))
|
else "--continue " ++ shellEscape (show (SimpleRun target))
|
||||||
|
@ -114,17 +115,22 @@ update forhost = do
|
||||||
-- to be relayed to the target host.
|
-- to be relayed to the target host.
|
||||||
privfile = maybe privDataLocal privDataRelay forhost
|
privfile = maybe privDataLocal privDataRelay forhost
|
||||||
|
|
||||||
-- The connect action should ssh to the remote host and run the provided
|
updateServer
|
||||||
-- calback action.
|
:: HostName
|
||||||
updateServer :: HostName -> Maybe HostName -> Host -> (((Handle, Handle) -> IO ()) -> IO ()) -> IO ()
|
-> Maybe HostName
|
||||||
updateServer target relay hst connect = connect go
|
-> Host
|
||||||
|
-> CreateProcess
|
||||||
|
-> CreateProcess
|
||||||
|
-> IO ()
|
||||||
|
updateServer target relay hst connect haveprecompiled =
|
||||||
|
withBothHandles createProcessSuccess connect go
|
||||||
where
|
where
|
||||||
hn = fromMaybe target relay
|
hn = fromMaybe target relay
|
||||||
relaying = relay == Just target
|
relaying = relay == Just target
|
||||||
|
|
||||||
go (toh, fromh) = do
|
go (toh, fromh) = do
|
||||||
let loop = go (toh, fromh)
|
let loop = go (toh, fromh)
|
||||||
let restart = updateServer hn relay hst connect
|
let restart = updateServer hn relay hst connect haveprecompiled
|
||||||
let done = return ()
|
let done = return ()
|
||||||
v <- (maybe Nothing readish <$> getMarked fromh statusMarker)
|
v <- (maybe Nothing readish <$> getMarked fromh statusMarker)
|
||||||
case v of
|
case v of
|
||||||
|
@ -143,7 +149,7 @@ updateServer target relay hst connect = connect go
|
||||||
hClose toh
|
hClose toh
|
||||||
hClose fromh
|
hClose fromh
|
||||||
sendPrecompiled hn
|
sendPrecompiled hn
|
||||||
restart
|
updateServer hn relay hst haveprecompiled (error "loop")
|
||||||
(Just NeedGitPush) -> do
|
(Just NeedGitPush) -> do
|
||||||
sendGitUpdate hn fromh toh
|
sendGitUpdate hn fromh toh
|
||||||
hClose fromh
|
hClose fromh
|
||||||
|
|
Loading…
Reference in New Issue