Update environment variables to support custom data directory
This commit is contained in:
@@ -15,22 +15,31 @@ main = do
|
||||
|
||||
keyFileInit :: IO ()
|
||||
keyFileInit = do
|
||||
keyExists <- doesFileExist "./data/encryptionKey"
|
||||
dataPathStr <- dataPath
|
||||
keyExists <- doesFileExist $ dataPathStr ++ "data/encryptionKey"
|
||||
case keyExists of
|
||||
True -> putStrLn "Using existing key"
|
||||
False -> do
|
||||
key <- newKey
|
||||
B.writeFile "./data/encryptionKey" (encode key)
|
||||
B.writeFile (dataPathStr ++ "data/encryptionKey") (encode key)
|
||||
putStrLn "Creating new encryption key; any pre-existing DB entries will not decrypt"
|
||||
|
||||
dbPath :: IO String
|
||||
dbPath = getEnv "dbFile"
|
||||
|
||||
confLinkLength :: IO String
|
||||
confLinkLength = getEnv "linkLength"
|
||||
|
||||
adminEmail :: IO String
|
||||
adminEmail = getEnv "adminEmail"
|
||||
adminEmail = getEnv "ADMINEMAIL"
|
||||
|
||||
appPort :: IO String
|
||||
appPort = getEnv "applicationPort"
|
||||
appPort = getEnv "APPLICATIONPORT"
|
||||
|
||||
dataPath :: IO String
|
||||
dataPath = getEnv "DATADIR"
|
||||
|
||||
dbPath :: IO String
|
||||
dbPath = getEnv "DBFILE"
|
||||
|
||||
confLinkLength :: IO String
|
||||
confLinkLength = getEnv "LINKLENGTH"
|
||||
|
||||
encKey :: IO B.ByteString
|
||||
encKey = do
|
||||
dataPathStr <- dataPath
|
||||
B.readFile (dataPathStr ++ "data/encryptionKey")
|
||||
|
||||
Reference in New Issue
Block a user