propellor spin

This commit is contained in:
Joey Hess 2014-11-22 16:20:02 -04:00
parent dca7ec5d2c
commit a4edc404f0
Failed to extract signature
3 changed files with 11 additions and 14 deletions

View File

@ -166,11 +166,9 @@ spin target relay hst = do
void $ actionMessage "Push to central git repository" $ void $ actionMessage "Push to central git repository" $
boolSystem "git" [Param "push"] boolSystem "git" [Param "push"]
cacheparams <- if False cacheparams <- if viarelay
then pure []
else if viarelay
then pure ["-A"] then pure ["-A"]
else toCommand <$> sshCachingParams hn viarelay else toCommand <$> sshCachingParams hn
when viarelay $ when viarelay $
void $ boolSystem "ssh-add" [] void $ boolSystem "ssh-add" []

View File

@ -131,7 +131,7 @@ sendGitUpdate hn fromh toh =
sendGitClone :: HostName -> IO () sendGitClone :: HostName -> IO ()
sendGitClone hn = void $ actionMessage ("Clone git repository to " ++ hn) $ do sendGitClone hn = void $ actionMessage ("Clone git repository to " ++ hn) $ do
branch <- getCurrentBranch branch <- getCurrentBranch
cacheparams <- sshCachingParams hn False cacheparams <- sshCachingParams hn
withTmpFile "propellor.git" $ \tmp _ -> allM id withTmpFile "propellor.git" $ \tmp _ -> allM id
[ boolSystem "git" [Param "bundle", Param "create", File tmp, Param "HEAD"] [ boolSystem "git" [Param "bundle", Param "create", File tmp, Param "HEAD"]
, boolSystem "scp" $ cacheparams ++ [File tmp, Param ("root@"++hn++":"++remotebundle)] , boolSystem "scp" $ cacheparams ++ [File tmp, Param ("root@"++hn++":"++remotebundle)]
@ -156,7 +156,7 @@ sendPrecompiled hn = void $ actionMessage ("Uploading locally compiled propellor
withTmpDir "propellor" go withTmpDir "propellor" go
where where
go tmpdir = do go tmpdir = do
cacheparams <- sshCachingParams hn False cacheparams <- sshCachingParams hn
let shimdir = takeFileName localdir let shimdir = takeFileName localdir
createDirectoryIfMissing True (tmpdir </> shimdir) createDirectoryIfMissing True (tmpdir </> shimdir)
changeWorkingDirectory (tmpdir </> shimdir) changeWorkingDirectory (tmpdir </> shimdir)

View File

@ -14,17 +14,16 @@ import Data.Time.Clock.POSIX
-- minutes, and if so stop that ssh process, in order to not try to -- minutes, and if so stop that ssh process, in order to not try to
-- use an old stale connection. (atime would be nicer, but there's -- use an old stale connection. (atime would be nicer, but there's
-- a good chance a laptop uses noatime) -- a good chance a laptop uses noatime)
sshCachingParams :: HostName -> Bool -> IO [CommandParam] sshCachingParams :: HostName -> IO [CommandParam]
sshCachingParams hn viarelay = do sshCachingParams hn = do
home <- myHomeDir home <- myHomeDir
let cachedir = home </> ".ssh" </> "propellor" let cachedir = home </> ".ssh" </> "propellor"
createDirectoryIfMissing False cachedir createDirectoryIfMissing False cachedir
let socketfile = cachedir </> hn ++ ".sock" let socketfile = cachedir </> hn ++ ".sock"
let ps = catMaybes let ps =
[ if viarelay then Just (Param "-A") else Nothing [ Param "-o"
, Just $ Param "-o" , Param ("ControlPath=" ++ socketfile)
, Just $ Param ("ControlPath=" ++ socketfile) , Params "-o ControlMaster=auto -o ControlPersist=yes"
, Just $ Params "-o ControlMaster=auto -o ControlPersist=yes"
] ]
maybe noop (expireold ps socketfile) maybe noop (expireold ps socketfile)