summaryrefslogtreecommitdiff
path: root/build/configure.sh
diff options
context:
space:
mode:
authorSacheendra Talluri <sacheendra.t@gmail.com>2017-01-26 18:42:38 +0100
committerSacheendra Talluri <sacheendra.t@gmail.com>2017-01-26 18:42:38 +0100
commit01410021a7fe733edab64d7cb4b359685d89cd91 (patch)
treef54256b95068df3f62b913d5b04cab61d56c549c /build/configure.sh
parent8b123384237a40801a621a1df6c094562eee52c1 (diff)
Add Dockerfile and related build files
Diffstat (limited to 'build/configure.sh')
-rwxr-xr-xbuild/configure.sh34
1 files changed, 34 insertions, 0 deletions
diff --git a/build/configure.sh b/build/configure.sh
new file mode 100755
index 00000000..75a61e7d
--- /dev/null
+++ b/build/configure.sh
@@ -0,0 +1,34 @@
+if [ ! -f "$1/opendc.db" ]; then
+ sqlite3 "$1/opendc.db" < ./database/schema.sql
+ sqlite3 "$1/opendc.db" < ./database/test.sql
+fi
+
+if [ -z "$OAUTH_CLIENT_ID" ]
+then
+ echo "OAuth client id not found. Define environment variable OAUTH_CLIENT_ID"
+ exit 1
+fi
+
+if [ -z "$OAUTH_CLIENT_SECRET" ]
+then
+ echo "OAuth client secret not found. Define environment variable OAUTH_CLIENT_SECRET"
+ exit 2
+fi
+
+if [ -z "$SERVER_URL" ]
+then
+ echo "URL of server not found. Define environment variable SERVER_URL"
+ exit 2
+fi
+
+sed -i "s/client-id/$OAUTH_CLIENT_ID/g" ./build/keys.json
+sed -i "s/client-secret/$OAUTH_CLIENT_SECRET/g" ./build/keys.json
+
+# ignore non ASCII characters
+LC_CTYPE=C
+LANG=C
+
+find ./opendc-frontend/build -type f -exec sed -i "s/the-google-oauth-client-id/$OAUTH_CLIENT_ID/g" {} \;
+find ./opendc-frontend/build -type f -exec sed -i "s,https://opendc.ewi.tudelft.nl:443,$SERVER_URL,g" {} \;
+find ./opendc-frontend/build -type f -exec sed -i "s,https://opendc.ewi.tudelft.nl,$SERVER_URL,g" {} \;
+find ./opendc-frontend/build -type f -exec sed -i 's,LOCAL_MODE = (document.location.hostname === "localhost"),LOCAL_MODE = false,g' {} \; \ No newline at end of file