-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun
executable file
·90 lines (74 loc) · 2.55 KB
/
run
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/bash
#
# A script to make working with docker/compose to have
# less typing.
#
# For local development only.
UI_PATH="source/SIL.AppBuilder.Portal.Frontend"
API_PATH="source/OptimaJet.DWKit.StarterApplication"
COMPOSE="docker-compose -p dwkit-vacreq"
function runstuff {
# First arg
given_command=$1
# The rest of the args
arguments=${@:2}
case $given_command in
# docker-compose proxy
dc) ${COMPOSE} $arguments;;
up:build) ${COMPOSE} up --build $arguments;;
up) ${COMPOSE} up $arguments;;
bash) ${COMPOSE} run --rm $arguments bash;;
restart) ${COMPOSE} stop $arguments && ${COMPOSE} start $arguments;;
bootstrap)
# Setup Database
PSQL="PGPASSWORD=\$POSTGRES_PASSWORD psql -h localhost -U \$POSTGRES_USER"
${COMPOSE} exec db bash -c "${PSQL} -d postgres -tc \"SELECT 1 FROM pg_database WHERE datname = '\$POSTGRES_DB'\" | grep -q 1 && ${PSQL} -d postgres -c \"DROP DATABASE \$POSTGRES_DB\""
${COMPOSE} exec db bash -c "${PSQL} -d postgres -c \"CREATE DATABASE \$POSTGRES_DB WITH ENCODING 'UTF8'\""
${COMPOSE} exec db bash -c "${PSQL} -d \$POSTGRES_DB -f /scripts/PostgreSQL/DWKitScript.sql" \
&& ${COMPOSE} exec db bash -c "${PSQL} -d \$POSTGRES_DB -f /scripts/PostgreSQL/Workflow_CreatePersistenceObjects.sql" \
&& ${COMPOSE} exec db bash -c "${PSQL} -d \$POSTGRES_DB -f /scripts/PostgreSQL/CreateObjects.sql" \
&& ${COMPOSE} exec db bash -c "${PSQL} -d \$POSTGRES_DB -f /scripts/PostgreSQL/FillData.sql" \
&& echo "DB setup with DWKit Scripts"
# other things...?
;;
# backend / api things
dotnet) ( cd $API_PATH && dotnet $arguments );;
# dotnet:api)
# Don't name any folders bin, obj, tmp, dist, or node_modules
clean:all)
echo "Cleaning..."
runstuff clean:frontend
runstuff clean:relays
;;
clean:api)
shopt -s globstar
rm -rf **/bin && \
rm -rf **/obj
;;
*) print_help;;
esac
}
function print_help {
echo ""
echo "Available Commands:"
echo ""
echo "dc : short for docker-compose"
echo "up:build"
echo "up"
echo ""
echo "bash : drop into a bash shell in a temporary docker-compose service"
echo "restart : restart a specific docker-compose service"
echo ""
echo "bootstrap : runs initial scripts for project setup"
echo ""
echo "dotnet"
echo ""
echo "clean:all : recursively removes dist, node_modules, and tmp directories"
echo "clean:api"
echo "clean:frontend"
}
if [ $1 ]; then
runstuff $*
else
print_help
fi