From f8010caeb4499bdea244417c72a8f4d9e13c945e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Bourr=C3=A9?= Date: Mon, 24 Dec 2018 16:25:32 +0100 Subject: [PATCH 01/16] add only_ldap option and upgrade to 1.6.0 --- manifest.json | 13 ++++++++++--- scripts/install | 7 +++++-- scripts/upgrade.d/upgrade.sh | 6 +++--- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/manifest.json b/manifest.json index f5861eb..5a8da2f 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "name": "Gitlab", "id": "gitlab", "packaging_format": 1, - "version": "1.5.3~ynh1", + "version": "1.6.0~ynh1", "description": { "en": "Gitlab for Yunohost.", "fr": "Gitlab pour YunoHost." @@ -59,9 +59,16 @@ "fr": "Est-ce une application publique ?" }, "default": true + }, + { + "name": "only_use_ldap", + "type": "boolean", + "ask": { + "en": "Use only Yunohost account to sign in?", + "fr": "Utiliser seulement les comptes Yunohost pour se connecter ?" + }, + "default": true } - - ] } } diff --git a/scripts/install b/scripts/install index ede2903..5b5ebf8 100644 --- a/scripts/install +++ b/scripts/install @@ -22,6 +22,7 @@ source ./_common.sh domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH is_public=$YNH_APP_ARG_IS_PUBLIC +only_use_ldap=$YNH_APP_ARG_IS_PUBLIC admin=$YNH_APP_ARG_ADMIN #================================================= @@ -49,6 +50,7 @@ ynh_user_exists "$admin" \ ynh_app_setting_set $app admin $admin ynh_app_setting_set $app path_url $path_url ynh_app_setting_set $app is_public $is_public +ynh_app_setting_set $app only_use_ldap $only_use_ldap #================================================= # STANDARD MODIFICATIONS @@ -94,7 +96,7 @@ setup_source $architecture #================================================= # SPECIFIC SETUP #================================================= -# GETTING ADMIN INFO AND ADD AS A GITLAB USER +# GETTING ADMIN INFO AND ADD AS A GITLAB USER AND CONFIGURE SIGN IN SYSTEM #================================================= mailadmin=$(ynh_user_get_info $admin mail) @@ -104,7 +106,8 @@ echo "newuser = User.new({ \"email\"=>'$mailadmin', \"username\"=>'$admin', \"na newuser.admin = true newuser.confirmed_at = Time.now newuser.confirmation_token = nil -newuser.save" | sudo gitlab-rails console +newuser.save +ApplicationSetting.last.update_attributes(password_authentication_enabled_for_web: $only_use_ldap, signup_enabled: $only_use_ldap)" | sudo gitlab-rails console #================================================= # RESTART TO TAKE INTO ACCOUNT CHANGES diff --git a/scripts/upgrade.d/upgrade.sh b/scripts/upgrade.d/upgrade.sh index fb6ccf7..57396a8 100644 --- a/scripts/upgrade.d/upgrade.sh +++ b/scripts/upgrade.d/upgrade.sh @@ -1,5 +1,5 @@ -gitlab_version="11.5.3" +gitlab_version="11.6.0" -gitlab_x86_64_source_sha256="fdbea3e92eb1f613897659e99b20660d64524eaf5b1cd57a323cd6f61c573e7f" +gitlab_x86_64_source_sha256="040ac5917d71c45b3fbdeccbeaf2e7b3181fcce0ed9ca65ac68d3d15081b8b02" -gitlab_arm_source_sha256="81d37736442be80d687b52299604ef38bc4000b7545b241094b7f5a027c9fac4" \ No newline at end of file +gitlab_arm_source_sha256="18d385af2a59fb37c6282298ccb7bbbf091d8ff39fbcde581226e35d5f3792dc" From a4c169584a2c264c646481612eaa9db1e1116856 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Bourr=C3=A9?= Date: Mon, 24 Dec 2018 16:25:49 +0100 Subject: [PATCH 02/16] update backup and restore scripts --- scripts/backup | 60 ++++++++++++++++++++++------------- scripts/restore | 83 +++++++++++++++++++++++++++---------------------- 2 files changed, 83 insertions(+), 60 deletions(-) diff --git a/scripts/backup b/scripts/backup index af8ccd9..12f69e4 100644 --- a/scripts/backup +++ b/scripts/backup @@ -1,33 +1,49 @@ #!/bin/bash -# Exit on command errors and treat unset variables as an error -set -eu - -# See comments in install script -app=$YNH_APP_INSTANCE_NAME +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= # Source YunoHost helpers source /usr/share/yunohost/helpers -# Backup sources & data -# Note: the last argument is where to save this path, see the restore script. -ynh_backup "/var/www/${app}" "sources" +# Load common variables and helpers +source ./_common.sh -### MySQL (remove if not used) ### -# If a MySQL database is used: -# # Dump the database -# dbname=$app -# dbuser=$app -# dbpass=$(ynh_app_setting_get "$app" mysqlpwd) -# mysqldump -u "$dbuser" -p"$dbpass" --no-create-db "$dbname" > ./dump.sql -### MySQL end ### +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +ynh_clean_setup () { + ### Remove this function if there's nothing to clean before calling the remove script. + true +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# LOAD SETTINGS +#================================================= # Copy NGINX configuration domain=$(ynh_app_setting_get "$app" domain) -ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "nginx.conf" -### PHP (remove if not used) ### -# If a dedicated php-fpm process is used: -# # Copy PHP-FPM pool configuration -# ynh_backup "/etc/php5/fpm/pool.d/${app}.conf" "php-fpm.conf" -### PHP end ### +#================================================= +# STANDARD BACKUP STEPS +#================================================= +# BACKUP THE NGINX CONFIGURATION +#================================================= + +ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" + +#================================================= +# BACKUP THE APP MAIN DIR +#================================================= + +# Use gitlab-rake to backup +gitlab-rake gitlab:backup:create + +ynh_backup "$config_path/gitlab-secrets.json" "gitlab-secrets.json" +ynh_backup "$config_path/gitlab.rb" "gitlab.rb" \ No newline at end of file diff --git a/scripts/restore b/scripts/restore index 93169e9..336be39 100644 --- a/scripts/restore +++ b/scripts/restore @@ -1,52 +1,59 @@ #!/bin/bash -# Note: each files and directories you've saved using the ynh_backup helper -# will be located in the current directory, regarding the last argument. - -# Exit on command errors and treat unset variables as an error -set -eu - -# See comments in install script -app=$YNH_APP_INSTANCE_NAME +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= # Source YunoHost helpers source /usr/share/yunohost/helpers -# Retrieve old app settings +# Load common variables and helpers +source ./_common.sh + +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +ynh_clean_setup () { + ### Remove this function if there's nothing to clean before calling the remove script. + true +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# LOAD SETTINGS +#================================================= + +# Copy NGINX configuration domain=$(ynh_app_setting_get "$app" domain) -path_url=$(ynh_app_setting_get "$app" path_url) -# Check domain/path availability -sudo yunohost app checkurl "${domain}${path_url}" -a "$app" \ - || ynh_die "Path not available: ${domain}${path_url}" +#================================================= +# STANDARD RESTORATION STEPS +#================================================= +# RESTORE THE NGINX CONFIGURATION +#================================================= -# Restore sources & data -src_path="/var/www/${app}" -sudo cp -a ./sources "$src_path" +ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" -# Restore permissions to app files -# you may need to make some file and/or directory writeable by www-data (nginx user) -sudo chown -R root: "$src_path" +#================================================= +# RESTORE THE APP MAIN DIR +#================================================= -### MySQL (remove if not used) ### -# If a MySQL database is used: -# # Create and restore the database -# dbname=$app -# dbuser=$app -# dbpass=$(ynh_app_setting_get "$app" mysqlpwd) -# ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass" -# ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ./dump.sql -### MySQL end ### +gitlab-ctl stop unicorn +gitlab-ctl stop sidekiq -# Restore NGINX configuration -sudo cp -a ./nginx.conf "/etc/nginx/conf.d/${domain}.d/${app}.conf" +fullfile=$(ls /var/opt/gitlab/backups/*_gitlab* --file -c1 | head -1) +basename="/var/opt/gitlab/backups/" +last_backup="${filename%_gitlab_backup.tar}" -### PHP (remove if not used) ### -# If a dedicated php-fpm process is used: -# # Copy PHP-FPM pool configuration and reload the service -# sudo cp -a ./php-fpm.conf "/etc/php5/fpm/pool.d/${app}.conf" -# sudo service php5-fpm reload -### PHP end ### +# Use gitlab-rake to backup +gitlab-rake gitlab:backup:restore force=yes BACKUP=$last_backup -# Restart webserver -sudo service nginx reload +ynh_backup "$config_path/gitlab-secrets.json" "gitlab-secrets.json" +ynh_backup "$config_path/gitlab.rb" "gitlab.rb" + +gitlab-ctl restart +gitlab-rake gitlab:check SANITIZE=true From 3abea81969503b58a2ac31a4eef0b16124a628ff Mon Sep 17 00:00:00 2001 From: bourreP Date: Mon, 24 Dec 2018 18:16:01 +0100 Subject: [PATCH 03/16] Update backup --- scripts/backup | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/backup b/scripts/backup index 12f69e4..5fdec5a 100644 --- a/scripts/backup +++ b/scripts/backup @@ -10,7 +10,7 @@ source /usr/share/yunohost/helpers # Load common variables and helpers -source ./_common.sh +source ../settings/scripts/_common.sh #================================================= # MANAGE SCRIPT FAILURE @@ -46,4 +46,4 @@ ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" gitlab-rake gitlab:backup:create ynh_backup "$config_path/gitlab-secrets.json" "gitlab-secrets.json" -ynh_backup "$config_path/gitlab.rb" "gitlab.rb" \ No newline at end of file +ynh_backup "$config_path/gitlab.rb" "gitlab.rb" From 67d1961ce6e314ac1d6431cae987fc392f153b4f Mon Sep 17 00:00:00 2001 From: bourreP Date: Mon, 24 Dec 2018 18:16:16 +0100 Subject: [PATCH 04/16] Update restore --- scripts/restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/restore b/scripts/restore index 336be39..277e242 100644 --- a/scripts/restore +++ b/scripts/restore @@ -10,7 +10,7 @@ source /usr/share/yunohost/helpers # Load common variables and helpers -source ./_common.sh +source ../settings/scripts/_common.sh #================================================= # MANAGE SCRIPT FAILURE From 1bc5173c78206f73f97b6a15909ad436267e87d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Bourr=C3=A9?= Date: Mon, 24 Dec 2018 19:10:30 +0100 Subject: [PATCH 05/16] fix restore --- scripts/backup | 9 +++------ scripts/restore | 28 ++++++++++++++++++++++------ 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/scripts/backup b/scripts/backup index 5fdec5a..60e2900 100644 --- a/scripts/backup +++ b/scripts/backup @@ -16,10 +16,6 @@ source ../settings/scripts/_common.sh # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { - ### Remove this function if there's nothing to clean before calling the remove script. - true -} # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -37,6 +33,7 @@ domain=$(ynh_app_setting_get "$app" domain) #================================================= ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_backup "$final_path" #================================================= # BACKUP THE APP MAIN DIR @@ -45,5 +42,5 @@ ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" # Use gitlab-rake to backup gitlab-rake gitlab:backup:create -ynh_backup "$config_path/gitlab-secrets.json" "gitlab-secrets.json" -ynh_backup "$config_path/gitlab.rb" "gitlab.rb" +ynh_backup "$config_path/gitlab-secrets.json" +ynh_backup "$config_path/gitlab.rb" diff --git a/scripts/restore b/scripts/restore index 277e242..6e42948 100644 --- a/scripts/restore +++ b/scripts/restore @@ -16,10 +16,6 @@ source ../settings/scripts/_common.sh # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { - ### Remove this function if there's nothing to clean before calling the remove script. - true -} # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -29,6 +25,16 @@ ynh_abort_if_errors # Copy NGINX configuration domain=$(ynh_app_setting_get "$app" domain) +path_url=$(ynh_app_setting_get "$app" path_url) + +#================================================= +# CHECK IF THE APP CAN BE RESTORED +#================================================= + +ynh_webpath_available $domain $path_url \ +|| ynh_die "Path not available: ${domain}${path_url}" +test ! -d $final_path \ +|| ynh_die "There is already a directory: $final_path " #================================================= # STANDARD RESTORATION STEPS @@ -42,6 +48,16 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" # RESTORE THE APP MAIN DIR #================================================= +ynh_restore_file "$final_path" + +#================================================= +# SPECIFIC RESTORATION +#================================================= +# REINSTALL DEPENDENCIES +#================================================= + +ynh_install_app_dependencies openssh-server + gitlab-ctl stop unicorn gitlab-ctl stop sidekiq @@ -52,8 +68,8 @@ last_backup="${filename%_gitlab_backup.tar}" # Use gitlab-rake to backup gitlab-rake gitlab:backup:restore force=yes BACKUP=$last_backup -ynh_backup "$config_path/gitlab-secrets.json" "gitlab-secrets.json" -ynh_backup "$config_path/gitlab.rb" "gitlab.rb" +ynh_restore_file "$config_path/gitlab-secrets.json" +ynh_restore_file "$config_path/gitlab.rb" gitlab-ctl restart gitlab-rake gitlab:check SANITIZE=true From b1062284fd7ab82a44bcb3c1272b6f4b0fa23c7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Bourr=C3=A9?= Date: Mon, 24 Dec 2018 19:31:51 +0100 Subject: [PATCH 06/16] fix restore --- scripts/backup | 2 +- scripts/restore | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/scripts/backup b/scripts/backup index 60e2900..917a9ef 100644 --- a/scripts/backup +++ b/scripts/backup @@ -33,7 +33,6 @@ domain=$(ynh_app_setting_get "$app" domain) #================================================= ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" -ynh_backup "$final_path" #================================================= # BACKUP THE APP MAIN DIR @@ -42,5 +41,6 @@ ynh_backup "$final_path" # Use gitlab-rake to backup gitlab-rake gitlab:backup:create +ynh_backup "/var/opt/$app/backups/" ynh_backup "$config_path/gitlab-secrets.json" ynh_backup "$config_path/gitlab.rb" diff --git a/scripts/restore b/scripts/restore index 6e42948..ae77983 100644 --- a/scripts/restore +++ b/scripts/restore @@ -44,12 +44,6 @@ test ! -d $final_path \ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# RESTORE THE APP MAIN DIR -#================================================= - -ynh_restore_file "$final_path" - #================================================= # SPECIFIC RESTORATION #================================================= @@ -58,11 +52,19 @@ ynh_restore_file "$final_path" ynh_install_app_dependencies openssh-server +#================================================= +# RESTORE THE APP MAIN DIR +#================================================= + +setup_source $architecture + +ynh_restore_file "$/var/opt/$app/backups/" + gitlab-ctl stop unicorn gitlab-ctl stop sidekiq -fullfile=$(ls /var/opt/gitlab/backups/*_gitlab* --file -c1 | head -1) -basename="/var/opt/gitlab/backups/" +fullfile=$(ls /var/opt/$app/backups/*_gitlab* --file -c1 | head -1) +basename="/var/opt/$app/backups/" last_backup="${filename%_gitlab_backup.tar}" # Use gitlab-rake to backup From 2cb2f36f5db8b3a1b22edf268fbb1c85542e53df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Bourr=C3=A9?= Date: Mon, 24 Dec 2018 19:55:59 +0100 Subject: [PATCH 07/16] fix restore --- scripts/backup | 1 + scripts/restore | 23 ++++++++++++++--------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/scripts/backup b/scripts/backup index 917a9ef..a646fe1 100644 --- a/scripts/backup +++ b/scripts/backup @@ -41,6 +41,7 @@ ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" # Use gitlab-rake to backup gitlab-rake gitlab:backup:create +ynh_backup "$final_path" ynh_backup "/var/opt/$app/backups/" ynh_backup "$config_path/gitlab-secrets.json" ynh_backup "$config_path/gitlab.rb" diff --git a/scripts/restore b/scripts/restore index ae77983..296780f 100644 --- a/scripts/restore +++ b/scripts/restore @@ -44,6 +44,14 @@ test ! -d $final_path \ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" +#================================================= +# RESTORE THE APP MAIN DIR +#================================================= + +ynh_restore_file "$final_path" + +ynh_restore_file "/var/opt/$app/backups/" + #================================================= # SPECIFIC RESTORATION #================================================= @@ -52,19 +60,16 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" ynh_install_app_dependencies openssh-server -#================================================= -# RESTORE THE APP MAIN DIR -#================================================= - -setup_source $architecture - -ynh_restore_file "$/var/opt/$app/backups/" +ln -s /opt/gitlab/bin/gitlab-ctl /usr/bin/gitlab-ctl +ln -s /opt/gitlab/bin/gitlab-psql /usr/bin/gitlab-psql +ln -s /opt/gitlab/bin/gitlab-rails /usr/bin/gitlab-rails +ln -s /opt/gitlab/bin/gitlab-rake /usr/bin/gitlab-rake gitlab-ctl stop unicorn gitlab-ctl stop sidekiq -fullfile=$(ls /var/opt/$app/backups/*_gitlab* --file -c1 | head -1) -basename="/var/opt/$app/backups/" +fullfile=$(ls /var/opt/gitlab/backups/*_gitlab* --file -c1 | head -1) +basename="/var/opt/gitlab/backups/" last_backup="${filename%_gitlab_backup.tar}" # Use gitlab-rake to backup From 35bff9524ecfd8b85f7dde28de20ba3ab8047019 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Bourr=C3=A9?= Date: Tue, 25 Dec 2018 19:01:57 +0100 Subject: [PATCH 08/16] fix restore --- scripts/restore | 3 --- 1 file changed, 3 deletions(-) diff --git a/scripts/restore b/scripts/restore index 296780f..288ea0c 100644 --- a/scripts/restore +++ b/scripts/restore @@ -65,9 +65,6 @@ ln -s /opt/gitlab/bin/gitlab-psql /usr/bin/gitlab-psql ln -s /opt/gitlab/bin/gitlab-rails /usr/bin/gitlab-rails ln -s /opt/gitlab/bin/gitlab-rake /usr/bin/gitlab-rake -gitlab-ctl stop unicorn -gitlab-ctl stop sidekiq - fullfile=$(ls /var/opt/gitlab/backups/*_gitlab* --file -c1 | head -1) basename="/var/opt/gitlab/backups/" last_backup="${filename%_gitlab_backup.tar}" From 3ddbb2f48352203a47c1d272df4d5cb1d2e7dacf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Bourr=C3=A9?= Date: Tue, 25 Dec 2018 19:22:24 +0100 Subject: [PATCH 09/16] fix restore --- scripts/backup | 1 - scripts/restore | 12 ++++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/scripts/backup b/scripts/backup index a646fe1..917a9ef 100644 --- a/scripts/backup +++ b/scripts/backup @@ -41,7 +41,6 @@ ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" # Use gitlab-rake to backup gitlab-rake gitlab:backup:create -ynh_backup "$final_path" ynh_backup "/var/opt/$app/backups/" ynh_backup "$config_path/gitlab-secrets.json" ynh_backup "$config_path/gitlab.rb" diff --git a/scripts/restore b/scripts/restore index 288ea0c..01c8b26 100644 --- a/scripts/restore +++ b/scripts/restore @@ -11,6 +11,7 @@ source /usr/share/yunohost/helpers # Load common variables and helpers source ../settings/scripts/_common.sh +source ../settings/scripts/upgrade.d/upgrade.sh #================================================= # MANAGE SCRIPT FAILURE @@ -48,7 +49,9 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" # RESTORE THE APP MAIN DIR #================================================= -ynh_restore_file "$final_path" +ynh_install_app_dependencies openssh-server + +setup_source $architecture ynh_restore_file "/var/opt/$app/backups/" @@ -58,13 +61,6 @@ ynh_restore_file "/var/opt/$app/backups/" # REINSTALL DEPENDENCIES #================================================= -ynh_install_app_dependencies openssh-server - -ln -s /opt/gitlab/bin/gitlab-ctl /usr/bin/gitlab-ctl -ln -s /opt/gitlab/bin/gitlab-psql /usr/bin/gitlab-psql -ln -s /opt/gitlab/bin/gitlab-rails /usr/bin/gitlab-rails -ln -s /opt/gitlab/bin/gitlab-rake /usr/bin/gitlab-rake - fullfile=$(ls /var/opt/gitlab/backups/*_gitlab* --file -c1 | head -1) basename="/var/opt/gitlab/backups/" last_backup="${filename%_gitlab_backup.tar}" From 59c5d4a0dbd794e1cdc0ddc84ce9bd1f6cb7224e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Bourr=C3=A9?= Date: Tue, 25 Dec 2018 19:32:44 +0100 Subject: [PATCH 10/16] fix restore --- scripts/restore | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/restore b/scripts/restore index 01c8b26..d3d882c 100644 --- a/scripts/restore +++ b/scripts/restore @@ -6,12 +6,19 @@ # IMPORT GENERIC HELPERS #================================================= +if [ ! -e _common.sh ]; then + # Get the _common.sh file if it's not in the current directory + cp ../settings/scripts/_common.sh ./_common.sh + mkdir ./upgrade.d + cp ../settings/upgrade.d/upgrade.sh ./upgrade.d/upgrade.sh + chmod a+rx _common.sh upgrade.d/upgrade.sh +fi + # Source YunoHost helpers source /usr/share/yunohost/helpers # Load common variables and helpers -source ../settings/scripts/_common.sh -source ../settings/scripts/upgrade.d/upgrade.sh +source _common.sh #================================================= # MANAGE SCRIPT FAILURE From 9f3db97b7891a705bee2f10e47f57fef63372bd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Bourr=C3=A9?= Date: Tue, 25 Dec 2018 19:41:43 +0100 Subject: [PATCH 11/16] fix restore --- scripts/restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/restore b/scripts/restore index d3d882c..7f9e433 100644 --- a/scripts/restore +++ b/scripts/restore @@ -10,7 +10,7 @@ if [ ! -e _common.sh ]; then # Get the _common.sh file if it's not in the current directory cp ../settings/scripts/_common.sh ./_common.sh mkdir ./upgrade.d - cp ../settings/upgrade.d/upgrade.sh ./upgrade.d/upgrade.sh + cp ../settings/scripts/upgrade.d/upgrade.sh ./upgrade.d/upgrade.sh chmod a+rx _common.sh upgrade.d/upgrade.sh fi From c85da3979508b1882f722a809cd5d30362c73591 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Bourr=C3=A9?= Date: Tue, 25 Dec 2018 19:51:27 +0100 Subject: [PATCH 12/16] fix restore --- scripts/restore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/restore b/scripts/restore index 7f9e433..ca07a3b 100644 --- a/scripts/restore +++ b/scripts/restore @@ -10,7 +10,9 @@ if [ ! -e _common.sh ]; then # Get the _common.sh file if it's not in the current directory cp ../settings/scripts/_common.sh ./_common.sh mkdir ./upgrade.d + mkdir ../conf cp ../settings/scripts/upgrade.d/upgrade.sh ./upgrade.d/upgrade.sh + cp ../settings/conf/*.default ../conf/ chmod a+rx _common.sh upgrade.d/upgrade.sh fi From 67616b642171ab318df04f43dddede8f200c004a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Bourr=C3=A9?= Date: Tue, 25 Dec 2018 20:08:49 +0100 Subject: [PATCH 13/16] fix restore --- scripts/restore | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/restore b/scripts/restore index ca07a3b..b5424b0 100644 --- a/scripts/restore +++ b/scripts/restore @@ -60,6 +60,9 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" ynh_install_app_dependencies openssh-server +ynh_restore_file "$config_path/gitlab-secrets.json" +ynh_restore_file "$config_path/gitlab.rb" + setup_source $architecture ynh_restore_file "/var/opt/$app/backups/" @@ -77,8 +80,5 @@ last_backup="${filename%_gitlab_backup.tar}" # Use gitlab-rake to backup gitlab-rake gitlab:backup:restore force=yes BACKUP=$last_backup -ynh_restore_file "$config_path/gitlab-secrets.json" -ynh_restore_file "$config_path/gitlab.rb" - gitlab-ctl restart gitlab-rake gitlab:check SANITIZE=true From 38d9632d8c691a4f4399ffbccb6a93ef2115520e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Bourr=C3=A9?= Date: Tue, 25 Dec 2018 20:31:52 +0100 Subject: [PATCH 14/16] fix restore --- scripts/restore | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/restore b/scripts/restore index b5424b0..daf9b31 100644 --- a/scripts/restore +++ b/scripts/restore @@ -75,6 +75,7 @@ ynh_restore_file "/var/opt/$app/backups/" fullfile=$(ls /var/opt/gitlab/backups/*_gitlab* --file -c1 | head -1) basename="/var/opt/gitlab/backups/" +filename=$(basename -- "$fullfile") last_backup="${filename%_gitlab_backup.tar}" # Use gitlab-rake to backup From ce8aeddb0d04fa8e28b7f9551f0393f6f8082343 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Bourr=C3=A9?= Date: Tue, 25 Dec 2018 20:55:11 +0100 Subject: [PATCH 15/16] fix restore --- scripts/backup | 13 ++++++++++++- scripts/restore | 29 +++++++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/scripts/backup b/scripts/backup index 917a9ef..fad059a 100644 --- a/scripts/backup +++ b/scripts/backup @@ -16,6 +16,12 @@ source ../settings/scripts/_common.sh # MANAGE SCRIPT FAILURE #================================================= +ynh_clean_setup () { + + rm /var/opt/gitlab/backups/*_gitlab_backup.tar + true +} + # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -35,12 +41,17 @@ domain=$(ynh_app_setting_get "$app" domain) ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= -# BACKUP THE APP MAIN DIR +# BACKUP GITLAB DATABASE #================================================= # Use gitlab-rake to backup gitlab-rake gitlab:backup:create ynh_backup "/var/opt/$app/backups/" + +#================================================= +# BACKUP CONF FILES +#================================================= + ynh_backup "$config_path/gitlab-secrets.json" ynh_backup "$config_path/gitlab.rb" diff --git a/scripts/restore b/scripts/restore index daf9b31..1f7e6c5 100644 --- a/scripts/restore +++ b/scripts/restore @@ -26,6 +26,12 @@ source _common.sh # MANAGE SCRIPT FAILURE #================================================= +ynh_clean_setup () { + + rm /var/opt/gitlab/backups/*_gitlab_backup.tar + true +} + # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -55,14 +61,22 @@ test ! -d $final_path \ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= -# RESTORE THE APP MAIN DIR +# REINSTALL DEPENDENCIES #================================================= ynh_install_app_dependencies openssh-server +#================================================= +# RESTORE CONF FILES +#================================================= + ynh_restore_file "$config_path/gitlab-secrets.json" ynh_restore_file "$config_path/gitlab.rb" +#================================================= +# RESTORE THE APP MAIN DIR +#================================================= + setup_source $architecture ynh_restore_file "/var/opt/$app/backups/" @@ -70,7 +84,7 @@ ynh_restore_file "/var/opt/$app/backups/" #================================================= # SPECIFIC RESTORATION #================================================= -# REINSTALL DEPENDENCIES +# RESTORE GITLAB DATABASE #================================================= fullfile=$(ls /var/opt/gitlab/backups/*_gitlab* --file -c1 | head -1) @@ -78,8 +92,19 @@ basename="/var/opt/gitlab/backups/" filename=$(basename -- "$fullfile") last_backup="${filename%_gitlab_backup.tar}" +gitlab-ctl stop unicorn +gitlab-ctl stop sidekiq + # Use gitlab-rake to backup gitlab-rake gitlab:backup:restore force=yes BACKUP=$last_backup gitlab-ctl restart gitlab-rake gitlab:check SANITIZE=true + +#================================================= +# GENERIC FINALIZATION +#================================================= +# RELOAD NGINX +#================================================= + +systemctl reload nginx \ No newline at end of file From 67cf132f42dd6c2c02427630dcb2e6389d2c1c59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Bourr=C3=A9?= Date: Tue, 25 Dec 2018 21:03:39 +0100 Subject: [PATCH 16/16] fix restore --- scripts/restore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/restore b/scripts/restore index 1f7e6c5..1bb89e6 100644 --- a/scripts/restore +++ b/scripts/restore @@ -9,8 +9,8 @@ if [ ! -e _common.sh ]; then # Get the _common.sh file if it's not in the current directory cp ../settings/scripts/_common.sh ./_common.sh - mkdir ./upgrade.d - mkdir ../conf + mkdir ./upgrade.d + mkdir ../conf cp ../settings/scripts/upgrade.d/upgrade.sh ./upgrade.d/upgrade.sh cp ../settings/conf/*.default ../conf/ chmod a+rx _common.sh upgrade.d/upgrade.sh