-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun.sh
executable file
·37 lines (34 loc) · 1.68 KB
/
run.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
# Colors
red='\033[0;31m'
green='\033[0;32m'
clear='\033[0m'
if [ "$#" -eq 0 ]; then
printf "${green}Starting mongodb container...\n${clear}"
password=$(<./.local/db_password.txt) # Load db password from file
docker volume create mongodb_data_container_local
docker run --rm --name mongodb -d -p 27018:27017 -v mongodb_data_container_local:/data/db -e "MONGO_INITDB_ROOT_USERNAME=radiator" -e "MONGO_INITDB_ROOT_PASSWORD=$password" -e "MONGO_INITDB_DATABASE=MiniTwit" mongo:latest
printf "${green}To stop the container write 'docker stop mongodb'\n${clear}"
elif [ "$1" = "nosave" ]; then
printf "${green}Starting mongodb container...\n${clear}"
password=$(<./.local/db_password.txt) # Load db password from file
docker run --rm --name mongodb -d -p 27018:27017 -e "MONGO_INITDB_ROOT_USERNAME=radiator" -e "MONGO_INITDB_ROOT_PASSWORD=$password" -e "MONGO_INITDB_DATABASE=MiniTwit" mongo:latest
printf "${green}Starting backend...\n${clear}"
dotnet run --project MiniTwit.Server
printf "${red}Stopping and removing mongodb container...\n${clear}"
docker stop mongodb
elif [ "$1" = "secrets" ]; then
printf "${green}Creating secrets...\n${clear}"
project="MiniTwit.Server"
user="radiator"
password=$(<./.local/db_password.txt) # Load db password from file
connectionString="mongodb://$user:$password@localhost:27018"
dotnet user-secrets init --project $project
dotnet user-secrets set "ConnectionStrings:MiniTwit" "$connectionString" --project $project
elif [ "$1" = "inspectdb" ]; then
./flag_tool -i | less
elif [ "$1" = "flag" ]; then
./flag_tool "${@:2}"
else
printf "${red}Error: Unknown command\n${clear}"
fi