unsafePerformIO is required to go from the IO monad to pure code. Signed-off-by: Michael Hanselmann <[email protected]> --- htools/Ganeti/Path.hs | 26 ++++++++++++++------------ 1 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/htools/Ganeti/Path.hs b/htools/Ganeti/Path.hs index 5f439dd..2446f52 100644 --- a/htools/Ganeti/Path.hs +++ b/htools/Ganeti/Path.hs @@ -23,31 +23,33 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -} -module Ganeti.Path - ( defaultLuxiSocket - , defaultQuerySocket - , dataDir - , logDir - , runDir - , confdHmacKey - , clusterConfFile - ) where +module Ganeti.Path where import qualified Ganeti.Constants as C import System.FilePath +import System.Posix.Env (getEnv) +import System.IO.Unsafe +-- | Prefixes a path with the current root directory +addNodePrefix :: FilePath -> FilePath +addNodePrefix path = do + let val = unsafePerformIO $ getEnv "GANETI_ROOTDIR" + case val of + Just rootdir -> rootdir ++ path + Nothing -> path + -- | Directory for data dataDir :: FilePath -dataDir = C.autoconfLocalstatedir </> "lib" </> "ganeti" +dataDir = addNodePrefix $ C.autoconfLocalstatedir </> "lib" </> "ganeti" -- | Directory for runtime files runDir :: FilePath -runDir = C.autoconfLocalstatedir </> "run" </> "ganeti" +runDir = addNodePrefix $ C.autoconfLocalstatedir </> "run" </> "ganeti" -- | Directory for log files logDir :: FilePath -logDir = C.autoconfLocalstatedir </> "log" </> "ganeti" +logDir = addNodePrefix $ C.autoconfLocalstatedir </> "log" </> "ganeti" -- | Directory for Unix sockets socketDir :: FilePath -- 1.7.6
