From 752ea54f7e6ba05c13b36a0b58570929148d0b21 Mon Sep 17 00:00:00 2001 From: Yarden Shoham Date: Tue, 13 Feb 2024 17:30:32 +0000 Subject: [PATCH 1/2] Fix Gitpod logic of setting ROOT_URL A long-living workspace can change its URL some times. On every startup we revaluate the URL. This is done to prevent the error on the admin page like: ![image](https://github.com/go-gitea/gitea/assets/20454870/5d7e515b-7925-4101-9422-33102d7abe51) Signed-off-by: Yarden Shoham --- .gitpod.yml | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/.gitpod.yml b/.gitpod.yml index 35b22c45ae7d..cf8338df9798 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -10,10 +10,19 @@ tasks: - name: Run backend command: | gp sync-await setup - if [ ! -f custom/conf/app.ini ] - then - mkdir -p custom/conf/ - echo -e "[server]\nROOT_URL=$(gp url 3000)/" > custom/conf/app.ini + mkdir -p custom/conf/ + + # Get the URL and extract the domain + url=$(gp url 3000) + domain=$(echo $url | awk -F[/:] '{print $4}') + + if [ -f custom/conf/app.ini ]; then + sed -i "s|^ROOT_URL =.*|ROOT_URL = ${url}/|" custom/conf/app.ini + sed -i "s|^DOMAIN =.*|DOMAIN = ${domain}|" custom/conf/app.ini + sed -i "s|^SSH_DOMAIN =.*|SSH_DOMAIN = ${domain}|" custom/conf/app.ini + sed -i "s|^NO_REPLY_ADDRESS =.*|SSH_DOMAIN = noreply.${domain}|" custom/conf/app.ini + else + echo -e "[server]\nROOT_URL = ${url}/" > custom/conf/app.ini echo -e "\n[database]\nDB_TYPE = sqlite3\nPATH = $GITPOD_REPO_ROOT/data/gitea.db" >> custom/conf/app.ini fi export TAGS="sqlite sqlite_unlock_notify" From 31a44796d569bef3e155c58ae95a280e27b60901 Mon Sep 17 00:00:00 2001 From: Yarden Shoham Date: Tue, 13 Feb 2024 20:10:01 +0000 Subject: [PATCH 2/2] mkdir only if it doesn't exists --- .gitpod.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitpod.yml b/.gitpod.yml index cf8338df9798..ed2f57f4bf6c 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -10,7 +10,6 @@ tasks: - name: Run backend command: | gp sync-await setup - mkdir -p custom/conf/ # Get the URL and extract the domain url=$(gp url 3000) @@ -22,6 +21,7 @@ tasks: sed -i "s|^SSH_DOMAIN =.*|SSH_DOMAIN = ${domain}|" custom/conf/app.ini sed -i "s|^NO_REPLY_ADDRESS =.*|SSH_DOMAIN = noreply.${domain}|" custom/conf/app.ini else + mkdir -p custom/conf/ echo -e "[server]\nROOT_URL = ${url}/" > custom/conf/app.ini echo -e "\n[database]\nDB_TYPE = sqlite3\nPATH = $GITPOD_REPO_ROOT/data/gitea.db" >> custom/conf/app.ini fi