30 lines
No EOL
1.6 KiB
Bash
30 lines
No EOL
1.6 KiB
Bash
#!/bin/bash
|
|
|
|
echo "[BOOTSTRAP] 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 "[BOOTSTRAP] 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_ENV | cut -d '=' -f2)
|
|
USERNAME_ENV=$(cat /home/coder/.coder-env | grep USERNAME_ENV | 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 "[BOOTSTRAP] Script has finished running." |