Add boop-keys/setup-boop.sh
This commit is contained in:
parent
e20fbd2b6a
commit
6ad509de3f
1 changed files with 30 additions and 0 deletions
30
boop-keys/setup-boop.sh
Normal file
30
boop-keys/setup-boop.sh
Normal file
|
@ -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!"
|
Loading…
Reference in a new issue