summaryrefslogtreecommitdiff
path: root/Assistant/Install.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-09-26 17:19:45 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-09-26 17:23:45 -0400
commitae5533c707148088a14130da7c3ca23bb113d309 (patch)
tree2659507e298e0d071d32054ae626c76388ec2360 /Assistant/Install.hs
parent6dfae4212ea292199e0ab215f4f27af182caf74a (diff)
install a git-annex-shell shim script when the standalone OSX app runs
I put it in ~/.ssh/ because there's no reliable way to get it into PATH, and OSX ssh doesn't even honor user's PATH by default. authorized_keys generators will need to check if it's there. Not done yet.
Diffstat (limited to 'Assistant/Install.hs')
-rw-r--r--Assistant/Install.hs39
1 files changed, 25 insertions, 14 deletions
diff --git a/Assistant/Install.hs b/Assistant/Install.hs
index efcfbfe6e..b404bc4b6 100644
--- a/Assistant/Install.hs
+++ b/Assistant/Install.hs
@@ -7,26 +7,30 @@
module Assistant.Install where
+import Assistant.Common
+import Assistant.Install.AutoStart
+import Assistant.Ssh
import Locations.UserConfig
+import Utility.FileMode
import Utility.OSX
-import Utility.Path
import System.Posix.Env
-import System.Directory
{- 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.
+ - 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 "OSX_GIT_ANNEX_APP_PROGRAM"
+ e <- getEnv "GIT_ANNEX_OSX_APP_BASE"
case e of
Nothing -> return ()
- Just program -> do
+ Just base -> do
+ let program = base ++ "/bin/git-annex"
programfile <- programFile
createDirectoryIfMissing True (parentDir programfile)
writeFile programfile program
@@ -34,12 +38,19 @@ ensureInstalled = do
autostartfile <- userAutoStart autoStartLabel
installAutoStart program autostartfile
-{- Installs an autostart plist file for OSX. -}
-installAutoStart :: FilePath -> FilePath -> IO ()
-installAutoStart command file = do
- createDirectoryIfMissing True (parentDir file)
- writeFile file $ genOSXAutoStartFile autoStartLabel command
- ["assistant", "--autostart"]
-
-autoStartLabel :: String
-autoStartLabel = "com.branchable.git-annex.assistant"
+ {- 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 \"$@\""
+ ]
+ curr <- catchDefaultIO "" $ readFile shim
+ when (curr /= content) $ do
+ createDirectoryIfMissing True (parentDir shim)
+ writeFile shim content
+ modifyFileMode shim $ addModes [ownerExecuteMode]