Revision 2f441f72 htools/Ganeti/Path.hs

b/htools/Ganeti/Path.hs
23 23

  
24 24
-}
25 25

  
26
module Ganeti.Path
27
  ( defaultLuxiSocket
28
  , defaultQuerySocket
29
  , dataDir
30
  , logDir
31
  , runDir
32
  , confdHmacKey
33
  , clusterConfFile
34
  , nodedCertFile
35
  ) where
26
module Ganeti.Path where
36 27

  
37 28
import qualified Ganeti.Constants as C
38 29
import System.FilePath
30
import System.Posix.Env (getEnvDefault)
31
import System.IO.Unsafe
39 32

  
33
{-# NOINLINE getRootDir #-}
34
getRootDir :: FilePath
35
getRootDir = unsafePerformIO $ getEnvDefault "GANETI_ROOTDIR" ""
36

  
37
-- | Prefixes a path with the current root directory
38
addNodePrefix :: FilePath -> FilePath
39
addNodePrefix path = getRootDir ++ path
40 40

  
41 41
-- | Directory for data
42 42
dataDir :: FilePath
43
dataDir = C.autoconfLocalstatedir </> "lib" </> "ganeti"
43
dataDir = addNodePrefix $ C.autoconfLocalstatedir </> "lib" </> "ganeti"
44 44

  
45 45
-- | Directory for runtime files
46 46
runDir :: FilePath
47
runDir = C.autoconfLocalstatedir </> "run" </> "ganeti"
47
runDir = addNodePrefix $ C.autoconfLocalstatedir </> "run" </> "ganeti"
48 48

  
49 49
-- | Directory for log files
50 50
logDir :: FilePath
51
logDir = C.autoconfLocalstatedir </> "log" </> "ganeti"
51
logDir = addNodePrefix $ C.autoconfLocalstatedir </> "log" </> "ganeti"
52 52

  
53 53
-- | Directory for Unix sockets
54 54
socketDir :: FilePath

Also available in: Unified diff