commit 7112c8641d9aec090f6dc4f5cd1e1fcbb1062455
parent 5bef9183bf0fe7fd329e934b9e73b9c758ac8098
Author: Joel-Haeberli <haebu@rubigen.ch>
Date: Sat, 18 May 2024 10:50:57 +0200
chore: setup and access rights
Diffstat:
3 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
@@ -35,6 +35,7 @@ install: dependencies-check
touch ${C2EC_HOME}/c2ec-log.txt
chmod ${C2EC_FILE_PERMISSIONS} ${C2EC_HOME}/c2ec-log.txt
chown ${C2EC_USER} ${C2EC_HOME}/c2ec-log.txt
+ cp ./simulation/config.yaml ${C2EC_HOME}/sim-config.yaml
(cd ./c2ec/db; ./migrate.sh ${C2EC_POSTGRES_USER} ${C2EC_POSTGRES_PASSWORD} ${C2EC_DB_NAME} ${C2EC_DB_ADMIN_PW} ${C2EC_DB_OPERATOR_PW} ${C2EC_DB_API_PW})
echo "you may want to alter the current configuration of your installation at ${C2EC_HOME}/c2ec-config.conf"
@@ -43,4 +44,7 @@ cli: dependencies-check
simulation: dependencies-check
go build -C ./simulation/ -o ${C2EC_HOME}
- cp ./simulation/config.yaml ${C2EC_HOME}/sim-config.yaml
+
+# ONLY DO THIS WHEN YOU NOW WHAT YOUR DOING
+#wipe:
+# (cd ./install; ./wipe_db.sh ${C2EC_POSTGRES_USER} ${C2EC_POSTGRES_PASSWORD} ${C2EC_DB_NAME})
diff --git a/c2ec/db/access.sql b/c2ec/db/access.sql
@@ -13,6 +13,9 @@ CREATE USER c2ec_operator WITH ENCRYPTED PASSWORD OPERATOR_PASSWORD;
CREATE USER c2ec_api WITH ENCRYPTED PASSWORD API_PASSWORD;
GRANT USAGE ON SCHEMA _v TO c2ec_admin;
+GRANT ALL PRIVILEGES _v.patches TO c2ec_admin;
+GRANT EXECUTE ON FUNCTION _v.register_patch TO c2ec_admin;
+
GRANT ALL PRIVILEGES ON DATABASE DB_NAME TO c2ec_admin;
GRANT USAGE ON SCHEMA c2ec TO c2ec_operator;
diff --git a/setup b/setup
@@ -14,8 +14,10 @@
#export C2EC_DB_API_PW=secret
#export C2EC_FILE_PERMISSIONS=660
+# The install command must be issued once and never again without doing
+# a backup before executing again. (It will overwrite existing configurations)
# This will setup the database and the required files inside C2EC_HOME
-make install
+# make install
# This will compile the c2ec executable and save it to C2EC_HOME
make build
@@ -26,6 +28,9 @@ make cli
# This will compile the simulation and save it to C2EC_HOME
make simulation
+# This will migrate the database
+make migrate
+
unset C2EC_POSTGRES_PASSWORD
unset C2EC_DB_ADMIN_PW
unset C2EC_DB_OPERATOR_PW