Created
August 21, 2017 09:58
-
-
Save erthalion/c670b233e37ec0e7d857befc022c9456 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env runhaskell | |
{-# LANGUAGE OverloadedStrings #-} | |
import Control.Monad | |
import Data.Text (unpack) | |
import Data.Text.IO as T | |
import Turtle | |
dbImage = "postgres:9.6" | |
dbContainer = "cdp-controller-db" | |
clusterTokenFile = "credentials/cluster-token-type" | |
communityTokenFile = "credentials/community-token-type" | |
clusterTokenSecretFile = "credentials/cluster-token-secret" | |
communityTokenSecretFile = "credentials/community-token-secret" | |
updateToken = do | |
T.writeFile clusterTokenSecretFile (lineToText (inproc "ztoken" [] empty)) | |
T.writeFile communityTokenSecretFile (lineToText (inproc "ztoken" [] empty)) | |
sleep 3300 | |
startDB = do | |
proc "docker" ["rm", "-fv", dbContainer] empty | |
proc "docker" ["run", "-dt", "--name", dbContainer, "-p", dbPortMap, dbImage] empty | |
where | |
dbPortMap = "5432:5432" | |
awsLogin = do | |
proc "zaws" ["login", "stups-test"] empty | |
main = do | |
putStrLn "Start PostgreSQL docker container" | |
startDB | |
putStrLn "Login to AWS account (stups-test)" | |
awsLogin | |
T.putStrLn "Create and update credentials" | |
mktree "credentials" | |
output clusterTokenFile "Bearer" | |
output communityTokenFile "Bearer" | |
forever $ updateToken |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment