3979086035
This was needed for the OSX self-contained app, but is a generally good idea. It avoids needing perl; is probably faster; and could eventually be replaced by something faster yet.
57 lines
1.7 KiB
Haskell
57 lines
1.7 KiB
Haskell
{- Assistant installation
|
|
-
|
|
- Copyright 2012 Joey Hess <joey@kitenet.net>
|
|
-
|
|
- Licensed under the GNU GPL version 3 or higher.
|
|
-}
|
|
|
|
module Assistant.Install where
|
|
|
|
import Assistant.Common
|
|
import Assistant.Install.AutoStart
|
|
import Assistant.Ssh
|
|
import Locations.UserConfig
|
|
import Utility.FileMode
|
|
import Utility.OSX
|
|
|
|
import System.Posix.Env
|
|
|
|
{- The OSX git-annex.app does not have an installation process.
|
|
- So when it's run, it needs to set up autostarting of the assistant
|
|
- daemon, as well as writing the programFile, and putting a
|
|
- git-annex-shell wrapper into ~/.ssh
|
|
-
|
|
- Note that this is done every time it's started, so if the user moves
|
|
- it around, the paths this sets up won't break.
|
|
-}
|
|
ensureInstalled :: IO ()
|
|
ensureInstalled = do
|
|
e <- getEnv "GIT_ANNEX_OSX_APP_BASE"
|
|
case e of
|
|
Nothing -> return ()
|
|
Just base -> do
|
|
let program = base ++ "/bin/git-annex"
|
|
programfile <- programFile
|
|
createDirectoryIfMissing True (parentDir programfile)
|
|
writeFile programfile program
|
|
|
|
autostartfile <- userAutoStart autoStartLabel
|
|
installAutoStart program autostartfile
|
|
|
|
{- This shim is only updated if it doesn't
|
|
- already exist with the right content. This
|
|
- ensures that there's no race where it would have
|
|
- worked, but is unavailable due to being updated. -}
|
|
sshdir <- sshDir
|
|
let shim = sshdir </> "git-annex-shell"
|
|
let content = unlines
|
|
[ "#!/bin/sh"
|
|
, "set -e"
|
|
, "exec", base </> "runshell" ++
|
|
" git-annex-shell -c \"$SSH_ORIGINAL_COMMAND\""
|
|
]
|
|
curr <- catchDefaultIO "" $ readFile shim
|
|
when (curr /= content) $ do
|
|
createDirectoryIfMissing True (parentDir shim)
|
|
writeFile shim content
|
|
modifyFileMode shim $ addModes [ownerExecuteMode]
|