From 420febfa9e7812702591668ab771afc6f1101fb3 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Tue, 20 Feb 2024 09:57:42 +0100 Subject: [PATCH 1/5] fix problems with deploy script, lost update? --- deployment/hetzner_cloud/install.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/deployment/hetzner_cloud/install.sh b/deployment/hetzner_cloud/install.sh index 06b92ecaf..798e77862 100755 --- a/deployment/hetzner_cloud/install.sh +++ b/deployment/hetzner_cloud/install.sh @@ -127,7 +127,13 @@ cp $SCRIPT_PATH/logrotate/gradido.conf /etc/logrotate.d/gradido.conf export DB_USER=gradido # create a new password only if it not already exist if [ -z "${DB_PASSWORD}" ]; then - export DB_PASSWORD=$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32};echo); + export DB_PASSWORD=$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c 32; echo); +fi + +# Check if DB_PASSWORD is still empty, then exit with an error +if [ -z "${DB_PASSWORD}" ]; then + echo "Error: Failed to generate DB_PASSWORD." + exit 1 fi mysql < $PROJECT_ROOT/database/.env # Configure backend -export JWT_SECRET=$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32};echo); +export JWT_SECRET=$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c 32; echo); envsubst "$(env | sed -e 's/=.*//' -e 's/^/\$/g')" < $PROJECT_ROOT/backend/.env.template > $PROJECT_ROOT/backend/.env # Configure frontend @@ -149,7 +155,7 @@ envsubst "$(env | sed -e 's/=.*//' -e 's/^/\$/g')" < $PROJECT_ROOT/frontend/.env envsubst "$(env | sed -e 's/=.*//' -e 's/^/\$/g')" < $PROJECT_ROOT/admin/.env.template > $PROJECT_ROOT/admin/.env # Configure dht-node -export FEDERATION_DHT_SEED=$(< /dev/urandom tr -dc a-f0-9 | head -c 32;echo); +export FEDERATION_DHT_SEED=$(< /dev/urandom tr -dc a-f0-9 | head -c 32; echo); envsubst "$(env | sed -e 's/=.*//' -e 's/^/\$/g')" < $PROJECT_ROOT/dht-node/.env.template > $PROJECT_ROOT/dht-node/.env # Configure federation @@ -163,4 +169,4 @@ sudo -u gradido crontab < $LOCAL_SCRIPT_DIR/crontabs.txt # Start gradido # Note: on first startup some errors will occur - nothing serious -sudo -u gradido $SCRIPT_PATH/start.sh \ No newline at end of file +sudo -u gradido $SCRIPT_PATH/start.sh $1 \ No newline at end of file From ffddfea699a9162c6373302393172243bc4d1014 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Mon, 26 Feb 2024 10:02:52 +0100 Subject: [PATCH 2/5] update remade, add migration script --- deployment/hetzner_cloud/README.md | 6 +- .../migration/2_2_0-2_2_1/README.md | 18 +++++ .../migration/2_2_0-2_2_1/fixInstall.sh | 66 +++++++++++++++++++ 3 files changed, 87 insertions(+), 3 deletions(-) create mode 100644 deployment/hetzner_cloud/migration/2_2_0-2_2_1/README.md create mode 100644 deployment/hetzner_cloud/migration/2_2_0-2_2_1/fixInstall.sh diff --git a/deployment/hetzner_cloud/README.md b/deployment/hetzner_cloud/README.md index d03ff0b46..5aec75ed5 100644 --- a/deployment/hetzner_cloud/README.md +++ b/deployment/hetzner_cloud/README.md @@ -1,7 +1,7 @@ -# Setup on Hetzner Cloud Server -Suggested minimal Plan: CX41 -4x vCPU, 16 GB Ram, 160 GB Disk Space, 20.71 € per month (04.01.2024) +# Migration +[Migration from 2.2.0 to 2.2.1](migration/2_2_0-2_2_1/README.md) +# Setup on Hetzner Cloud Server Suggested OS: Debian 12 diff --git a/deployment/hetzner_cloud/migration/2_2_0-2_2_1/README.md b/deployment/hetzner_cloud/migration/2_2_0-2_2_1/README.md new file mode 100644 index 000000000..38c4e8330 --- /dev/null +++ b/deployment/hetzner_cloud/migration/2_2_0-2_2_1/README.md @@ -0,0 +1,18 @@ +## Migrate from Gradido Version 2.2.0 to 2.2.1 +### What was wrong +In [hetzner_cloud/install.sh](../../install.sh) there was an error. +$DB_PASSWORD and $JWT_SECRET password generation method don't work with `release-2_2_0` as parameter for install.sh + +The Parameter forwarding from branch, `release-2_2_0` in this case to start.sh was also missing. + +### What you can do now +You need to only run this [fixInstall.sh](fixInstall.sh) with `release_2_2_1` as parameter +```bash +cd /home/gradido/gradido/deployment/hetzner_cloud/migration/2_2_0-2_2_1 +sudo ./fixInstall.sh `release_2_2_1` +``` + +Basically it will create a new $DB_PASSWORD, $JWT_SECRET and $FEDERATION_DHT_SEED, +update db user with new db password and update .env files in module folders. +Then it will call start.sh with first parameter if ./fixInstall.sh as his first parameter + diff --git a/deployment/hetzner_cloud/migration/2_2_0-2_2_1/fixInstall.sh b/deployment/hetzner_cloud/migration/2_2_0-2_2_1/fixInstall.sh new file mode 100644 index 000000000..5aad9c12d --- /dev/null +++ b/deployment/hetzner_cloud/migration/2_2_0-2_2_1/fixInstall.sh @@ -0,0 +1,66 @@ +#!/bin/bash +# check for parameter +if [ -z "$1" ]; then + echo "Usage: Please provide a branch name as the first argument." + exit 1 +fi + +set -o allexport +SCRIPT_PATH=$(realpath ../../../bare_metal) +SCRIPT_DIR=$(dirname $SCRIPT_PATH) +LOCAL_SCRIPT_PATH=$(realpath $0) +LOCAL_SCRIPT_DIR=$(dirname $LOCAL_SCRIPT_PATH) +PROJECT_ROOT=$SCRIPT_DIR/../../.. +set +o allexport + + +# Load .env or .env.dist if not present +# NOTE: all config values will be in process.env when starting +# the services and will therefore take precedence over the .env +if [ -f "$SCRIPT_PATH/.env" ]; then + set -o allexport + source $SCRIPT_PATH/.env + set +o allexport +else + set -o allexport + source $SCRIPT_PATH/.env.dist + set +o allexport +fi + +# create db user +export DB_USER=gradido +# create a new password only if it not already exist +export DB_PASSWORD=$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c 32; echo); + + +mysql < $PROJECT_ROOT/database/.env + +# Configure backend +export JWT_SECRET=$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c 32; echo); +envsubst "$(env | sed -e 's/=.*//' -e 's/^/\$/g')" < $PROJECT_ROOT/backend/.env.template > $PROJECT_ROOT/backend/.env + +# Configure frontend +envsubst "$(env | sed -e 's/=.*//' -e 's/^/\$/g')" < $PROJECT_ROOT/frontend/.env.template > $PROJECT_ROOT/frontend/.env + +# Configure admin +envsubst "$(env | sed -e 's/=.*//' -e 's/^/\$/g')" < $PROJECT_ROOT/admin/.env.template > $PROJECT_ROOT/admin/.env + +# Configure dht-node +export FEDERATION_DHT_SEED=$(< /dev/urandom tr -dc a-f0-9 | head -c 32; echo); +envsubst "$(env | sed -e 's/=.*//' -e 's/^/\$/g')" < $PROJECT_ROOT/dht-node/.env.template > $PROJECT_ROOT/dht-node/.env + +# Configure federation +envsubst "$(env | sed -e 's/=.*//' -e 's/^/\$/g')" < $PROJECT_ROOT/federation/.env.template > $PROJECT_ROOT/federation/.env + +# set all created or modified files back to belonging to gradido +chown -R gradido:gradido $PROJECT_ROOT + +# Start gradido +# Note: on first startup some errors will occur - nothing serious +sudo -u gradido $SCRIPT_PATH/start.sh $1 \ No newline at end of file From 93f68e4d475bec171bed265da8283df8edd2e4b9 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Mon, 26 Feb 2024 10:04:00 +0100 Subject: [PATCH 3/5] release --- CHANGELOG.md | 8 ++++++++ admin/package.json | 2 +- backend/package.json | 2 +- database/package.json | 2 +- dht-node/package.json | 2 +- dlt-connector/package.json | 2 +- federation/package.json | 2 +- frontend/package.json | 2 +- package.json | 2 +- 9 files changed, 16 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bbb49eaf5..b05bd3e70 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,16 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +#### [2.2.1](https://github.com/gradido/gradido/compare/2.2.0...2.2.1) + +- fix(other): deployment bugfixes [`#3290`](https://github.com/gradido/gradido/pull/3290) + #### [2.2.0](https://github.com/gradido/gradido/compare/2.1.1...2.2.0) +> 9 February 2024 + +- chore(release): v2.2.0 [`#3283`](https://github.com/gradido/gradido/pull/3283) +- fix(backend): prevent warning, fix env error [`#3282`](https://github.com/gradido/gradido/pull/3282) - feat(frontend): update news text [`#3279`](https://github.com/gradido/gradido/pull/3279) - feat(frontend): use params instead of query for send/identifier route [`#3277`](https://github.com/gradido/gradido/pull/3277) - fix(other): deployment bugfixes [`#3276`](https://github.com/gradido/gradido/pull/3276) diff --git a/admin/package.json b/admin/package.json index a28adad43..8157bbdaa 100644 --- a/admin/package.json +++ b/admin/package.json @@ -3,7 +3,7 @@ "description": "Administraion Interface for Gradido", "main": "index.js", "author": "Moriz Wahl", - "version": "2.2.0", + "version": "2.2.1", "license": "Apache-2.0", "private": false, "scripts": { diff --git a/backend/package.json b/backend/package.json index cdf35b725..e08d5ea5e 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "gradido-backend", - "version": "2.2.0", + "version": "2.2.1", "description": "Gradido unified backend providing an API-Service for Gradido Transactions", "main": "src/index.ts", "repository": "https://github.com/gradido/gradido/backend", diff --git a/database/package.json b/database/package.json index 2b31e033b..31ccfcc1f 100644 --- a/database/package.json +++ b/database/package.json @@ -1,6 +1,6 @@ { "name": "gradido-database", - "version": "2.2.0", + "version": "2.2.1", "description": "Gradido Database Tool to execute database migrations", "main": "src/index.ts", "repository": "https://github.com/gradido/gradido/database", diff --git a/dht-node/package.json b/dht-node/package.json index 7a73791d5..a4859e394 100644 --- a/dht-node/package.json +++ b/dht-node/package.json @@ -1,6 +1,6 @@ { "name": "gradido-dht-node", - "version": "2.2.0", + "version": "2.2.1", "description": "Gradido dht-node module", "main": "src/index.ts", "repository": "https://github.com/gradido/gradido/", diff --git a/dlt-connector/package.json b/dlt-connector/package.json index 5bc9673de..9713e740f 100644 --- a/dlt-connector/package.json +++ b/dlt-connector/package.json @@ -1,6 +1,6 @@ { "name": "gradido-dlt-connector", - "version": "2.2.0", + "version": "2.2.1", "description": "Gradido DLT-Connector", "main": "src/index.ts", "repository": "https://github.com/gradido/gradido/", diff --git a/federation/package.json b/federation/package.json index fcfaa0e46..9a74201ab 100644 --- a/federation/package.json +++ b/federation/package.json @@ -1,6 +1,6 @@ { "name": "gradido-federation", - "version": "2.2.0", + "version": "2.2.1", "description": "Gradido federation module providing Gradido-Hub-Federation and versioned API for inter community communication", "main": "src/index.ts", "repository": "https://github.com/gradido/gradido/federation", diff --git a/frontend/package.json b/frontend/package.json index 2a3eeb56a..22ad16c5d 100755 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "bootstrap-vue-gradido-wallet", - "version": "2.2.0", + "version": "2.2.1", "private": true, "scripts": { "start": "node run/server.js", diff --git a/package.json b/package.json index b85be6f24..8ed31de63 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gradido", - "version": "2.2.0", + "version": "2.2.1", "description": "Gradido", "main": "index.js", "repository": "git@github.com:gradido/gradido.git", From f750603151f691a0f962f70aca127bb07e3db417 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Mon, 26 Feb 2024 10:05:17 +0100 Subject: [PATCH 4/5] make script runnable --- deployment/hetzner_cloud/migration/2_2_0-2_2_1/fixInstall.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 deployment/hetzner_cloud/migration/2_2_0-2_2_1/fixInstall.sh diff --git a/deployment/hetzner_cloud/migration/2_2_0-2_2_1/fixInstall.sh b/deployment/hetzner_cloud/migration/2_2_0-2_2_1/fixInstall.sh old mode 100644 new mode 100755 From 7c18fd6736535a5466e255595dafc77a36346eb4 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Mon, 26 Feb 2024 10:06:32 +0100 Subject: [PATCH 5/5] fix --- deployment/hetzner_cloud/migration/2_2_0-2_2_1/fixInstall.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/hetzner_cloud/migration/2_2_0-2_2_1/fixInstall.sh b/deployment/hetzner_cloud/migration/2_2_0-2_2_1/fixInstall.sh index 5aad9c12d..1995b220d 100755 --- a/deployment/hetzner_cloud/migration/2_2_0-2_2_1/fixInstall.sh +++ b/deployment/hetzner_cloud/migration/2_2_0-2_2_1/fixInstall.sh @@ -10,7 +10,7 @@ SCRIPT_PATH=$(realpath ../../../bare_metal) SCRIPT_DIR=$(dirname $SCRIPT_PATH) LOCAL_SCRIPT_PATH=$(realpath $0) LOCAL_SCRIPT_DIR=$(dirname $LOCAL_SCRIPT_PATH) -PROJECT_ROOT=$SCRIPT_DIR/../../.. +PROJECT_ROOT=$SCRIPT_DIR/.. set +o allexport