This repository has been archived by the owner on Jan 7, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrestart.sh
executable file
·75 lines (61 loc) · 2.42 KB
/
restart.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
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
#!/usr/bin/env sh
# This script is for people who are lazy like me
# Run this to undo all database work, compile the code
# and rerun the server
# Ideally to be run during testing phase
export SCS_DBNAME="devsupplychainserver"
export BR_DBNAME="devmirzabusinessregistry"
echo Recreating the database
./manage_db.sh $SCS_DBNAME
./manage_db.sh $BR_DBNAME
# Defaulting opt to avoid error
GIVEN_OPT=$1
OPTION=${GIVEN_OPT:="some_random_text"}
echo Building the modules
if test $OPTION = '--clean'
then
stack clean
fi
stack build --fast
stack exec supplyChainServer -- --init-db --brhost localhost --brport 8200
stack exec businessRegistry -- initdb
# eventuially, we will get an updated list from ASIC and populate the db
# TODO: Update or delete this section. This is out of date.
echo "Now inserting some dummy companies"
echo
psql \
-X \
--echo-all \
--set AUTOCOMMIT=on \
--set ON_ERROR_STOP=on \
$BR_DBNAME \
<< EOF
INSERT INTO businesses \
(biz_gs1_company_prefix, biz_name, biz_function, biz_site_name, biz_address, biz_lat, biz_long) \
VALUES \
('4012345', 'Lomondo', 'Truck-driver', 'Holsworthy', '123 Holsworthy St', 123.456, 89.034);
INSERT INTO businesses \
(biz_gs1_company_prefix, biz_name, biz_function, biz_site_name, biz_address) \
VALUES \
('4000001', 'Manny''s Olive Oil', 'Farmenter', 'Warwick Farm', 'Farmland Av');
INSERT INTO businesses \
(biz_gs1_company_prefix, biz_name, biz_function, biz_site_name, biz_address) \
VALUES \
('0614141', 'Pulitzer Harvest', 'Harvester', 'Keskuskatu', 'ul. Filtrowa 68');
EOF
echo "Done"
export START_IN=2
echo "Starting the server in $START_IN s. Feed me a SIGINT (CTRL+C or equivalent) to stop."
sleep $START_IN
google-chrome "http://localhost:8000/swagger-ui/"
# The sleep here is to queue this process so that it fires AFTER
# the supplyChainServer executable is run
(sleep 2 && \
echo "Inserting a user. Username: [email protected], Password: password"
curl -X POST "http://localhost:8000/newUser" \
-H "accept: application/json;charset=utf-8"\
-H "Content-Type: application/json;charset=utf-8"\
-d "{ \"newUserPhoneNumber\": \"0412\", \"newUserEmailAddress\": \"[email protected]\", \"newUserFirstName\": \"sajid\", \"newUserLastName\": \"anower\", \"newUserCompany\": \"4000001\", \"newUserPassword\": \"password\"}")&
echo; echo
stack exec businessRegistry -- server &
stack exec supplyChainServer -- --brhost localhost --brport 8200 -e Dev