Skip to content

Instantly share code, notes, and snippets.

@erthalion
Created August 21, 2017 09:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erthalion/c670b233e37ec0e7d857befc022c9456 to your computer and use it in GitHub Desktop.
Save erthalion/c670b233e37ec0e7d857befc022c9456 to your computer and use it in GitHub Desktop.
#!/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