From 6037f6985330d545bf2a6c1c4170cd5631e47ad8 Mon Sep 17 00:00:00 2001 From: Kayou Date: Sun, 3 Mar 2019 14:29:53 +0100 Subject: [PATCH 1/3] Fix #29 --- scripts/upgrade | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/scripts/upgrade b/scripts/upgrade index 281e6d5..04ba257 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -26,6 +26,52 @@ is_public=$(ynh_app_setting_get "$app" is_public) port=$(ynh_app_setting_get "$app" web_port) portUnicorn=$(ynh_app_setting_get "$app" unicorn_port) +#================================================= +# ENSURE DOWNWARD COMPATIBILITY +#================================================= + +# Fix is_public as a boolean value +if [ "$is_public" = "Yes" ]; then + ynh_app_setting_set $app is_public 1 + is_public=1 +elif [ "$is_public" = "No" ]; then + ynh_app_setting_set $app is_public 0 + is_public=0 +fi + +# If domain doesn't exist, retrieve it +if [ -z $domain ]; then + domain=$(grep "external_url" "/etc/gitlab/gitlab.rb" | cut -d'/' -f3) # retrieve $domain from conf file + if [ ${domain: -1} == "'" ]; then # if the last char of $domain is ' remove it + domain=${domain:0:-1} + fi + ynh_app_setting_set $app domain $domain +fi + +# If path_url doesn't exist, retrieve it +if [ -z $path_url ]; then + path_url=$(grep "location" "/etc/nginx/conf.d/${domain}.d/gitlab.conf" | cut -d'/' -f2) + path_url=$(ynh_normalize_url_path $path_url) + ynh_app_setting_set $app path_url path_url +fi + +# If port doesn't exist, retrieve it +if [ -z $port ]; then + port=$(grep -F "nginx['listen_port']" "/etc/gitlab/gitlab.rb" | cut -d'/' -f3) + ynh_app_setting_set $app web_port $port +fi + +# If port doesn't exist, retrieve it +if [ -z $portUnicorn ]; then + portUnicorn=$(grep -F "unicorn['port']" "/etc/gitlab/gitlab.rb" | cut -d'/' -f3) + ynh_app_setting_set $app unicorn_port $portUnicorn +fi + +# if this source file exist, remove it +if [ -e "/etc/apt/sources.list.d/gitlab-ce.list" ]; then + ynh_secure_remove "/etc/apt/sources.list.d/gitlab-ce.list" +fi + #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= From d8a5ceb9eb4791577887c9644bef5e3bd88ae03e Mon Sep 17 00:00:00 2001 From: Kayou Date: Sun, 3 Mar 2019 14:38:46 +0100 Subject: [PATCH 2/3] Update upgrade --- scripts/upgrade | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 04ba257..fa49981 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -50,20 +50,20 @@ fi # If path_url doesn't exist, retrieve it if [ -z $path_url ]; then - path_url=$(grep "location" "/etc/nginx/conf.d/${domain}.d/gitlab.conf" | cut -d'/' -f2) + path_url=$(grep "location" "/etc/nginx/conf.d/${domain}.d/gitlab.conf" | cut -d' ' -f2) path_url=$(ynh_normalize_url_path $path_url) ynh_app_setting_set $app path_url path_url fi # If port doesn't exist, retrieve it if [ -z $port ]; then - port=$(grep -F "nginx['listen_port']" "/etc/gitlab/gitlab.rb" | cut -d'/' -f3) + port=$(grep -F "nginx['listen_port']" "/etc/gitlab/gitlab.rb" | cut -d' ' -f3) ynh_app_setting_set $app web_port $port fi # If port doesn't exist, retrieve it if [ -z $portUnicorn ]; then - portUnicorn=$(grep -F "unicorn['port']" "/etc/gitlab/gitlab.rb" | cut -d'/' -f3) + portUnicorn=$(grep -F "unicorn['port']" "/etc/gitlab/gitlab.rb" | cut -d' ' -f3) ynh_app_setting_set $app unicorn_port $portUnicorn fi From 264ba6a48e8129ffdbc852d2327eee73f389a4fa Mon Sep 17 00:00:00 2001 From: Kayou Date: Sun, 3 Mar 2019 15:03:26 +0100 Subject: [PATCH 3/3] Adding double quote for the -z --- scripts/upgrade | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index fa49981..96cb8d1 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -40,7 +40,7 @@ elif [ "$is_public" = "No" ]; then fi # If domain doesn't exist, retrieve it -if [ -z $domain ]; then +if [ -z "$domain" ]; then domain=$(grep "external_url" "/etc/gitlab/gitlab.rb" | cut -d'/' -f3) # retrieve $domain from conf file if [ ${domain: -1} == "'" ]; then # if the last char of $domain is ' remove it domain=${domain:0:-1} @@ -49,20 +49,20 @@ if [ -z $domain ]; then fi # If path_url doesn't exist, retrieve it -if [ -z $path_url ]; then +if [ -z "$path_url" ]; then path_url=$(grep "location" "/etc/nginx/conf.d/${domain}.d/gitlab.conf" | cut -d' ' -f2) path_url=$(ynh_normalize_url_path $path_url) ynh_app_setting_set $app path_url path_url fi # If port doesn't exist, retrieve it -if [ -z $port ]; then +if [ -z "$port" ]; then port=$(grep -F "nginx['listen_port']" "/etc/gitlab/gitlab.rb" | cut -d' ' -f3) ynh_app_setting_set $app web_port $port fi # If port doesn't exist, retrieve it -if [ -z $portUnicorn ]; then +if [ -z "$portUnicorn" ]; then portUnicorn=$(grep -F "unicorn['port']" "/etc/gitlab/gitlab.rb" | cut -d' ' -f3) ynh_app_setting_set $app unicorn_port $portUnicorn fi