From 6ad509de3febe1f81cff87bc7db37fb9f8da3d76 Mon Sep 17 00:00:00 2001 From: kakious Date: Fri, 21 Jul 2023 08:35:02 -0700 Subject: [PATCH] Add boop-keys/setup-boop.sh --- boop-keys/setup-boop.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 boop-keys/setup-boop.sh diff --git a/boop-keys/setup-boop.sh b/boop-keys/setup-boop.sh new file mode 100644 index 0000000..7ae13ba --- /dev/null +++ b/boop-keys/setup-boop.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +echo "Running initial setup for BOOP..." + +mysql -u root -e "CREATE DATABASE IF NOT EXISTS oauth_provider;" +password=$(openssl rand -base64 32) +echo $password > /home/coder/oauth-provider/.dbpass +mysqladmin -u root password $password +mysql -u root -p$password -e "CREATE USER 'oauth_provider'@'%' IDENTIFIED BY '$password';" +mysql -u root -p$password -e "GRANT ALL PRIVILEGES ON oauth_provider.* TO 'oauth_provider'@'%';" +mysql -u root -p$password -e "FLUSH PRIVILEGES;" +chown coder:coder /home/coder/oauth-provider/.dbpass + +echo "DB Configured, setting up .env file..." + +# read /home/coder/.coder-env as they contain the workspace name and username + +WORKSPACE_ENV=$(cat /home/coder/.coder-env | grep WORKSPACE_NAME | cut -d '=' -f2) +USERNAME_ENV=$(cat /home/coder/.coder-env | grep USERNAME | cut -d '=' -f2) + +sed -i "s/DATABASE_HOST=/DATABASE_HOST=localhost/g" /home/coder/oauth-provider/.env +sed -i "s/DATABASE_PORT=/DATABASE_PORT=3306/g" /home/coder/oauth-provider/.env +sed -i "s/DATABASE_USER=/DATABASE_USER=oauth_provider/g" /home/coder/oauth-provider/.env +sed -i "s/DATABASE_PASSWORD=/DATABASE_PASSWORD=$password/g" /home/coder/oauth-provider/.env +sed -i "s/DATABASE_NAME=/DATABASE_NAME=oauth_provider/g" /home/coder/oauth-provider/.env +sed -i "s/REDIS_HOST=/REDIS_HOST=localhost/g" /home/coder/oauth-provider/.env +sed -i "s/REDIS_PORT=/REDIS_PORT=6379/g" /home/coder/oauth-provider/.env +sed -i "s/BASE_LOCAL_URL=/BASE_LOCAL_URL=https:\/\/3123--$WORKSPACE_ENV--$USERNAME_ENV.coder.kakio.us/g" /home/coder/oauth-provider/.env + +echo "Done!" \ No newline at end of file