From 7f8e11e66d60e64fa361e7b5db14eebd841ef23a Mon Sep 17 00:00:00 2001 From: Andrea Spacca Date: Wed, 17 Nov 2021 09:32:16 +0100 Subject: [PATCH 1/3] support full urls --- configure-instance.sh | 26 +++++++++++++++++--------- template/config.properties | 6 +++--- template/docker-compose.caddy.yml | 2 +- template/docker-compose.nginx.yml | 2 +- 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/configure-instance.sh b/configure-instance.sh index 68ddbf5..2b75e5d 100755 --- a/configure-instance.sh +++ b/configure-instance.sh @@ -1,11 +1,11 @@ -echo "Enter a hostname for the Frontend (eg: piped.kavin.rocks):" -read frontend +echo "Enter an url for the Frontend (eg: https://piped.kavin.rocks):" +read frontend_url -echo "Enter a hostname for the Backend (eg: pipedapi.kavin.rocks):" -read backend +echo "Enter an url for the Backend (eg: https://pipedapi.kavin.rocks):" +read backend_url -echo "Enter a hostname for the Proxy (eg: pipedproxy.kavin.rocks):" -read proxy +echo "Enter an hostname for the Proxy (eg: https://pipedproxy.kavin.rocks):" +read proxy_url echo "Enter the reverse proxy you would like to use (either caddy or nginx):" read reverseproxy @@ -15,8 +15,16 @@ rm -f docker-compose.yml cp -r template/ config/ -sed -i "s/FRONTEND_HOSTNAME/$frontend/g" config/* -sed -i "s/BACKEND_HOSTNAME/$backend/g" config/* -sed -i "s/PROXY_HOSTNAME/$proxy/g" config/* +frontend_hostname=$(echo "$frontend_url"| awk -F[/:] '{print $4}') +backend_hostname=$(echo "$backend_url"| awk -F[/:] '{print $4}') +proxy_hostname=$(echo "$proxy_url"| awk -F[/:] '{print $4}') + +sed -i "s@FRONT_URL@$frontend_url@g" config/* +sed -i "s@BACKEND_URL@$backend_url@g" config/* +sed -i "s@PROXY_URL@$proxy_url@g" config/* + +sed -i "s@FRONTEND_HOSTNAME@$frontend_hostname@g" config/* +sed -i "s@BACKEND_HOSTNAME@$backend_hostname@g" config/* +sed -i "s@PROXY_HOSTNAME@$proxy_hostname@g" config/* mv config/docker-compose.$reverseproxy.yml docker-compose.yml diff --git a/template/config.properties b/template/config.properties index fc1050a..93baa8c 100644 --- a/template/config.properties +++ b/template/config.properties @@ -5,7 +5,7 @@ PORT: 8080 HTTP_WORKERS: 2 # Proxy -PROXY_PART: https://PROXY_HOSTNAME +PROXY_PART: PROXY_URL # Outgoing HTTP Proxy - eg: 127.0.0.1:8118 #HTTP_PROXY: 127.0.0.1:8118 @@ -15,10 +15,10 @@ CAPTCHA_BASE_URL: https://api.capmonster.cloud/ CAPTCHA_API_KEY: INSERT_HERE # Public API URL -API_URL: https://BACKEND_HOSTNAME +API_URL: BACKEND_URL # Public Frontend URL -FRONTEND_URL: https://FRONTEND_HOSTNAME +FRONTEND_URL: FRONT_URL # Hibernate properties hibernate.connection.url: jdbc:postgresql://postgres:5432/piped diff --git a/template/docker-compose.caddy.yml b/template/docker-compose.caddy.yml index df64ec5..254399c 100644 --- a/template/docker-compose.caddy.yml +++ b/template/docker-compose.caddy.yml @@ -5,7 +5,7 @@ services: depends_on: - piped container_name: piped-frontend - entrypoint: ash -c 'sed -i s/pipedapi.kavin.rocks/BACKEND_HOSTNAME/g /usr/share/nginx/html/js/* && /docker-entrypoint.sh && nginx -g "daemon off;"' + entrypoint: ash -c 'sed -i s@https://pipedapi.kavin.rocks@BACKEND_URL@g /usr/share/nginx/html/js/* && /docker-entrypoint.sh && nginx -g "daemon off;"' ytproxy: image: 1337kavin/ytproxy:latest restart: unless-stopped diff --git a/template/docker-compose.nginx.yml b/template/docker-compose.nginx.yml index c3234e7..d39271e 100644 --- a/template/docker-compose.nginx.yml +++ b/template/docker-compose.nginx.yml @@ -5,7 +5,7 @@ services: depends_on: - piped container_name: piped-frontend - entrypoint: ash -c 'sed -i s/pipedapi.kavin.rocks/BACKEND_HOSTNAME/g /usr/share/nginx/html/js/* && /docker-entrypoint.sh && nginx -g "daemon off;"' + entrypoint: ash -c 'sed -i s@https://pipedapi.kavin.rocks@BACKEND_URL@g /usr/share/nginx/html/js/* && /docker-entrypoint.sh && nginx -g "daemon off;"' ytproxy: image: 1337kavin/ytproxy:latest restart: unless-stopped From 514d010e8980e35815d33aeeb8ddd575cadb2887 Mon Sep 17 00:00:00 2001 From: Andrea Spacca Date: Tue, 18 Jan 2022 15:59:38 +0100 Subject: [PATCH 2/3] fix extra quote --- configure-instance.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure-instance.sh b/configure-instance.sh index c0e1cdc..920cad7 100755 --- a/configure-instance.sh +++ b/configure-instance.sh @@ -17,7 +17,7 @@ echo "Enter an url for the Frontend (eg: https://piped.kavin.rocks):" && read -r echo "Enter an url for the Backend (eg: https://pipedapi.kavin.rocks):"" && read -r backend_url -echo "Enter an hostname for the Proxy (eg: https://pipedproxy.kavin.rocks):"" && read -r proxy_url +echo "Enter an hostname for the Proxy (eg: https://pipedproxy.kavin.rocks):" && read -r proxy_url echo "Enter the reverse proxy you would like to use (either caddy or nginx):"" && read -r reverseproxy From 7b171c2f9bdc42afe4c8a2587009cc4dff713d49 Mon Sep 17 00:00:00 2001 From: Andrea Spacca Date: Tue, 18 Jan 2022 16:00:15 +0100 Subject: [PATCH 3/3] fix extra quotes --- configure-instance.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure-instance.sh b/configure-instance.sh index 920cad7..bac5407 100755 --- a/configure-instance.sh +++ b/configure-instance.sh @@ -15,11 +15,11 @@ fi echo "Enter an url for the Frontend (eg: https://piped.kavin.rocks):" && read -r frontend_url -echo "Enter an url for the Backend (eg: https://pipedapi.kavin.rocks):"" && read -r backend_url +echo "Enter an url for the Backend (eg: https://pipedapi.kavin.rocks):" && read -r backend_url echo "Enter an hostname for the Proxy (eg: https://pipedproxy.kavin.rocks):" && read -r proxy_url -echo "Enter the reverse proxy you would like to use (either caddy or nginx):"" && read -r reverseproxy +echo "Enter the reverse proxy you would like to use (either caddy or nginx):" && read -r reverseproxy rm -rf config/ rm -f docker-compose.yml