#!/bin/bash #================================================= # GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= # IMPORT GENERIC HELPERS source /usr/share/yunohost/helpers # Load common variables and helpers source ./_common.sh #================================================= # LOAD SETTINGS #================================================= app=$YNH_APP_INSTANCE_NAME # Retrieve app settings domain=$(ynh_app_setting_get "$app" domain) path_url=$(ynh_app_setting_get "$app" path_url) admin=$(ynh_app_setting_get "$app" admin) 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 #================================================= # Backup the current version of the app ynh_backup_before_upgrade ynh_clean_setup() { # restore it if the upgrade fails ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script ynh_abort_if_errors #================================================= # CHECK THE PATH #================================================= # Normalize the URL path syntax path_url=$(ynh_normalize_url_path $path_url) #================================================= # STANDARD UPGRADE STEPS #================================================= # NGINX CONFIGURATION #================================================= # Modify Nginx configuration file and copy it to Nginx conf directory ynh_add_nginx_config #================================================= # CONFIGURE GITLAB #================================================= # Configure gitlab with gitlab.rb file config_gitlab #================================================= # UPGRADE DEPENDENCIES #================================================= ynh_install_app_dependencies openssh-server #================================================= # DOWNLOAD, CHECK AND INSTALL GITLAB #================================================= # Update Gitlab setup_source $architecture #================================================= # GENERIC FINALIZATION #================================================= # SETUP SSOWAT #================================================= # If app is public, add url to SSOWat conf as skipped_uris if [[ $is_public -eq 1 ]]; then # See install script ynh_app_setting_set "$app" unprotected_uris "/" fi #================================================= # RELOAD NGINX #================================================= # Reload nginx service systemctl reload nginx #================================================= # WAIT #================================================= waiting_to_start