mirror of
https://github.com/YunoHost-Apps/gitlab_ynh.git
synced 2024-09-03 18:36:35 +02:00
Merge pull request #48 from YunoHost-Apps/update-with-getops
Normalization from example_ynh
This commit is contained in:
commit
2145ecc67c
10 changed files with 239 additions and 240 deletions
|
@ -46,6 +46,7 @@ Yes with LDAP support.
|
|||
|
||||
* Report a bug: https://github.com/YunoHost-Apps/gitlab_ynh/issues
|
||||
* App website: https://gitlab.com
|
||||
* Upstream app repository: https://gitlab.com/gitlab-org/omnibus-gitlab - https://gitlab.com/gitlab-org/gitlab-ce
|
||||
* YunoHost website: https://yunohost.org/
|
||||
|
||||
---
|
||||
|
|
|
@ -26,7 +26,7 @@ app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID}
|
|||
# CHECK IF AN ACTION HAS TO BE DONE
|
||||
#=================================================
|
||||
|
||||
is_public_old=$(ynh_app_setting_get $app is_public)
|
||||
is_public_old=$(ynh_app_setting_get --app=$app --key=is_public)
|
||||
|
||||
if [ $is_public -eq $is_public_old ]
|
||||
then
|
||||
|
@ -43,27 +43,27 @@ if [ $is_public -eq 0 ]; then
|
|||
else
|
||||
public_private="public"
|
||||
fi
|
||||
ynh_print_info --message="Moving the application to $public_private..."
|
||||
ynh_script_progression --message=--message="Moving the application to $public_private..." --weight=1
|
||||
|
||||
# Make app public if necessary
|
||||
if [ $is_public -eq 0 ]; then
|
||||
ynh_app_setting_delete $app unprotected_uris
|
||||
else
|
||||
# unprotected_uris allows SSO credentials to be passed anyway.
|
||||
ynh_app_setting_set $app unprotected_uris "/"
|
||||
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
|
||||
fi
|
||||
|
||||
ynh_print_info --message="Reconfiguring SSOwat..."
|
||||
ynh_script_progression --message=--message="Reconfiguring SSOwat..." --weight=1
|
||||
# Regen ssowat configuration
|
||||
yunohost app ssowatconf
|
||||
|
||||
# Update the config of the app
|
||||
ynh_app_setting_set $app is_public $is_public
|
||||
ynh_app_setting_set --app=$app --key=is_public --value=$is_public
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_print_info --message="Reloading nginx web server..."
|
||||
ynh_script_progression --message=--message="Reloading nginx web server..." --weight=1
|
||||
|
||||
ynh_systemd_action --action=reload --service_name=nginx
|
||||
|
||||
|
@ -71,4 +71,4 @@ ynh_systemd_action --action=reload --service_name=nginx
|
|||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info --message="Execution completed"
|
||||
ynh_script_progression --message="Execution completed" --last
|
|
@ -26,7 +26,7 @@ app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID}
|
|||
# CHECK IF AN ACTION HAS TO BE DONE
|
||||
#=================================================
|
||||
|
||||
use_web_account_old=$(ynh_app_setting_get $app use_web_account)
|
||||
use_web_account_old=$(ynh_app_setting_get --app=$app --key=use_web_account)
|
||||
|
||||
if [ $use_web_account -eq $use_web_account_old ]
|
||||
then
|
||||
|
@ -43,15 +43,15 @@ if [ $use_web_account -eq 0 ]; then
|
|||
else
|
||||
web_account="Disable"
|
||||
fi
|
||||
ynh_print_info --message="$web_account web user creation..."
|
||||
ynh_script_progression --message=--message="$web_account web user creation..." --weight=13
|
||||
|
||||
echo "ApplicationSetting.last.update_attributes(password_authentication_enabled_for_web: $use_web_account, signup_enabled: $use_web_account)" | gitlab-rails console
|
||||
|
||||
# Update the config of the app
|
||||
ynh_app_setting_set $app use_web_account $use_web_account
|
||||
ynh_app_setting_set --app=$app --key=use_web_account --value=$use_web_account
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info --message="Execution completed"
|
||||
ynh_script_progression --message="Execution completed" --last
|
|
@ -24,48 +24,48 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_print_info "Loading installation settings..."
|
||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
config_path=$(ynh_app_setting_get $app config_path)
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
config_path=$(ynh_app_setting_get --app=$app --key=config_path)
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
|
||||
#=================================================
|
||||
# STANDARD BACKUP STEPS
|
||||
#=================================================
|
||||
# BACKUP THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info "Backing up nginx web server configuration..."
|
||||
ynh_script_progression --message="Backing up nginx web server configuration..." --weight=1
|
||||
|
||||
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# BACKUP GITLAB DATABASE
|
||||
#=================================================
|
||||
ynh_print_info "Backuping of Gitlab..."
|
||||
ynh_script_progression --message="Backuping of Gitlab..." --weight=9
|
||||
|
||||
# Use gitlab-rake to backup
|
||||
gitlab-rake gitlab:backup:create > backup.log
|
||||
|
||||
# Searching in backup logs the
|
||||
# Searching in backup logs the name of the backup archive created
|
||||
last_backup=$(grep _gitlab_backup.tar backup.log | cut -d' ' -f4)
|
||||
mv "/var/opt/$app/backups/$last_backup" "/var/opt/$app/backups/last_gitlab_backup.tar"
|
||||
|
||||
ynh_backup "/var/opt/$app/backups/last_gitlab_backup.tar"
|
||||
ynh_backup --src_path="/var/opt/$app/backups/last_gitlab_backup.tar"
|
||||
|
||||
#=================================================
|
||||
# BACKUP CONF FILES
|
||||
#=================================================
|
||||
ynh_print_info "Backuping configuration files of Gitlab..."
|
||||
ynh_script_progression --message="Backuping configuration files of Gitlab..." --weight=1
|
||||
|
||||
ynh_backup "$config_path/gitlab-secrets.json"
|
||||
ynh_backup "$config_path/gitlab.rb"
|
||||
ynh_backup "$config_path/gitlab-persistent.rb"
|
||||
ynh_backup --src_path="$config_path/gitlab-secrets.json"
|
||||
ynh_backup --src_path="$config_path/gitlab.rb"
|
||||
ynh_backup --src_path="$config_path/gitlab-persistent.rb"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
||||
ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last
|
||||
|
|
|
@ -24,25 +24,16 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_print_info "Loading installation settings..."
|
||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||
|
||||
# Needed for helper "ynh_add_nginx_config"
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
config_path=$(ynh_app_setting_get $app config_path)
|
||||
port=$(ynh_app_setting_get "$app" web_port)
|
||||
portUnicorn=$(ynh_app_setting_get "$app" unicorn_port)
|
||||
portSidekiq=$(ynh_app_setting_get "$app" sidekiq_port)
|
||||
unicorn_worker_processes=$(ynh_app_setting_get "$app" unicorn_worker_processes)
|
||||
client_max_body_size=$(ynh_app_setting_get "$app" client_max_body_size)
|
||||
|
||||
#=================================================
|
||||
# CHECK THE SYNTAX OF THE PATHS
|
||||
#=================================================
|
||||
|
||||
test -n "$old_path" || old_path="/"
|
||||
test -n "$new_path" || new_path="/"
|
||||
new_path=$(ynh_normalize_url_path $new_path)
|
||||
old_path=$(ynh_normalize_url_path $old_path)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
config_path=$(ynh_app_setting_get --app=$app --key=config_path)
|
||||
port=$(ynh_app_setting_get --app="$app" --key=web_port)
|
||||
portUnicorn=$(ynh_app_setting_get --app="$app" --key=unicorn_port)
|
||||
portSidekiq=$(ynh_app_setting_get --app="$app" --key=sidekiq_port)
|
||||
unicorn_worker_processes=$(ynh_app_setting_get --app="$app" --key=unicorn_worker_processes)
|
||||
client_max_body_size=$(ynh_app_setting_get --app="$app" --key=client_max_body_size)
|
||||
|
||||
#=================================================
|
||||
# CHECK WHICH PARTS SHOULD BE CHANGED
|
||||
|
@ -63,12 +54,12 @@ fi
|
|||
#=================================================
|
||||
# MODIFY URL IN NGINX CONF
|
||||
#=================================================
|
||||
ynh_print_info "Updating nginx web server configuration..."
|
||||
ynh_script_progression --message="Updating nginx web server configuration..." --weight=1
|
||||
|
||||
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
||||
|
||||
if [ $change_path -eq 1 ]; then
|
||||
ynh_print_info "Changing path..."
|
||||
ynh_script_progression --message="Changing path..." --weight=4
|
||||
|
||||
#doc in: https://docs.gitlab.com/omnibus/settings/configuration.html#configuring-the-external-url-for-gitlab
|
||||
|
||||
|
@ -76,7 +67,7 @@ if [ $change_path -eq 1 ]; then
|
|||
gitlab-ctl stop sidekiq
|
||||
|
||||
# Make a backup of the original nginx config file if modified
|
||||
ynh_backup_if_checksum_is_different "$nginx_conf_path"
|
||||
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
|
||||
# Set global variables for nginx helper
|
||||
domain="$old_domain"
|
||||
path_url="$new_path"
|
||||
|
@ -86,13 +77,13 @@ fi
|
|||
|
||||
# Change the domain for nginx
|
||||
if [ $change_domain -eq 1 ]; then
|
||||
ynh_print_info "Changing domain..."
|
||||
ynh_script_progression --message="Changing domain..." --weight=4
|
||||
|
||||
# Delete file checksum for the old conf file location
|
||||
ynh_delete_file_checksum "$nginx_conf_path"
|
||||
ynh_delete_file_checksum --file="$nginx_conf_path"
|
||||
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
||||
# Store file checksum for the new config file location
|
||||
ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
@ -100,9 +91,9 @@ fi
|
|||
#=================================================
|
||||
# CONFIGURE GITLAB
|
||||
#=================================================
|
||||
ynh_print_info "Configure gitlab..."
|
||||
ynh_script_progression --message="Configure gitlab..." --weight=28
|
||||
|
||||
ynh_backup_if_checksum_is_different "$config_path/gitlab.rb"
|
||||
ynh_backup_if_checksum_is_different --file="$config_path/gitlab.rb"
|
||||
|
||||
mkdir -p $config_path
|
||||
|
||||
|
@ -112,15 +103,15 @@ ssh_port=$(grep -P "Port\s+\d+" /etc/ssh/sshd_config | grep -P -o "\d+")
|
|||
domain="$new_domain"
|
||||
path_url="$new_path"
|
||||
|
||||
ynh_replace_string "__GENERATED_EXTERNAL_URL__" "https://$domain${path_url%/}" "$config_path/gitlab.rb"
|
||||
ynh_replace_string "__PORT__" "$port" "$config_path/gitlab.rb"
|
||||
ynh_replace_string "__UNICORN_PORT__" "$portUnicorn" "$config_path/gitlab.rb"
|
||||
ynh_replace_string "__UNICORN_WORKER_PROCESSES__" "$unicorn_worker_processes" "$config_path/gitlab.rb"
|
||||
ynh_replace_string "__CLIENT_MAX_BODY_SIZE__" "$client_max_body_size" "$config_path/gitlab.rb"
|
||||
ynh_replace_string "__SSH_PORT__" "$ssh_port" "$config_path/gitlab.rb"
|
||||
ynh_replace_string "__SIDEKIQ_PORT__" "$portSidekiq" "$config_path/gitlab.rb"
|
||||
ynh_replace_string --match_string="__GENERATED_EXTERNAL_URL__" --replace_string="https://$domain${path_url%/}" --target_file="$config_path/gitlab.rb"
|
||||
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$config_path/gitlab.rb"
|
||||
ynh_replace_string --match_string="__UNICORN_PORT__" --replace_string="$portUnicorn" --target_file="$config_path/gitlab.rb"
|
||||
ynh_replace_string --match_string="__UNICORN_WORKER_PROCESSES__" --replace_string="$unicorn_worker_processes" --target_file="$config_path/gitlab.rb"
|
||||
ynh_replace_string --match_string="__CLIENT_MAX_BODY_SIZE__" --replace_string="$client_max_body_size" --target_file="$config_path/gitlab.rb"
|
||||
ynh_replace_string --match_string="__SSH_PORT__" --replace_string="$ssh_port" --target_file="$config_path/gitlab.rb"
|
||||
ynh_replace_string --match_string="__SIDEKIQ_PORT__" --replace_string="$portSidekiq" --target_file="$config_path/gitlab.rb"
|
||||
|
||||
ynh_store_file_checksum "$config_path/gitlab.rb"
|
||||
ynh_store_file_checksum --file="$config_path/gitlab.rb"
|
||||
|
||||
#=================================================
|
||||
# RECONFIGURE GITLAB
|
||||
|
@ -136,7 +127,7 @@ fi
|
|||
#=================================================
|
||||
# WAITING GITLAB
|
||||
#=================================================
|
||||
ynh_print_info "Waiting for gitlab..."
|
||||
ynh_script_progression --message="Waiting for gitlab..." --weight=15
|
||||
|
||||
# Action status to just wait the service
|
||||
ynh_systemd_action --action=status --service_name="gitlab-runsvdir" --log_path="/var/log/$app/unicorn/current" --line_match="adopted" --timeout=3600
|
||||
|
@ -146,7 +137,7 @@ ynh_systemd_action --action=status --service_name="gitlab-runsvdir" --log_path="
|
|||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_print_info "Reloading nginx web server..."
|
||||
ynh_script_progression --message="Reloading nginx web server..." --weight=1
|
||||
|
||||
ynh_systemd_action --action=reload --service_name=nginx
|
||||
|
||||
|
@ -154,4 +145,4 @@ ynh_systemd_action --action=reload --service_name=nginx
|
|||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Change of URL completed for $app"
|
||||
ynh_script_progression --message="Change of URL completed for $app" --last
|
||||
|
|
|
@ -26,17 +26,17 @@ app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID}
|
|||
# Otherwise, keep the value from the app config.
|
||||
|
||||
# is_public
|
||||
old_is_public="$(ynh_app_setting_get $app is_public)"
|
||||
old_is_public="$(ynh_app_setting_get --app=$app --key=is_public)"
|
||||
old_is_public=$(bool_to_true_false $old_is_public)
|
||||
is_public="${YNH_CONFIG_MAIN_IS_PUBLIC_IS_PUBLIC:-$old_is_public}"
|
||||
|
||||
# Overwrite nginx configuration
|
||||
old_overwrite_nginx="$(ynh_app_setting_get $app overwrite_nginx)"
|
||||
old_overwrite_nginx="$(ynh_app_setting_get --app=$app --key=overwrite_nginx)"
|
||||
old_overwrite_nginx=$(bool_to_true_false $old_overwrite_nginx)
|
||||
overwrite_nginx="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_NGINX:-$old_overwrite_nginx}"
|
||||
|
||||
# use_web_account
|
||||
old_use_web_account="$(ynh_app_setting_get $app use_web_account)"
|
||||
old_use_web_account="$(ynh_app_setting_get --app=$app --key=use_web_account)"
|
||||
old_use_web_account=$(bool_to_true_false $old_use_web_account)
|
||||
use_web_account="${YNH_CONFIG_MAIN_USERS_USE_WEB_ACCOUNT:-$old_use_web_account}"
|
||||
|
||||
|
@ -77,7 +77,7 @@ apply_config() {
|
|||
fi
|
||||
|
||||
# Set overwrite_nginx
|
||||
ynh_app_setting_set $app overwrite_nginx "$overwrite_nginx"
|
||||
ynh_app_setting_set --app=$app --key=overwrite_nginx --value="$overwrite_nginx"
|
||||
}
|
||||
|
||||
#=================================================
|
||||
|
|
110
scripts/install
110
scripts/install
|
@ -14,7 +14,7 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
|
||||
ynh_clean_setup () {
|
||||
ynh_secure_remove "$tempdir" 2>&1
|
||||
ynh_exec_warn_less ynh_secure_remove --file="$tempdir"
|
||||
|
||||
ynh_clean_check_starting
|
||||
}
|
||||
|
@ -36,11 +36,11 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
#=================================================
|
||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||
#=================================================
|
||||
ynh_print_info "Validating installation parameters..."
|
||||
ynh_script_progression --message="Validating installation parameters..." --weight=1
|
||||
|
||||
config_path=/etc/$app
|
||||
final_path=/opt/$app
|
||||
test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
||||
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
||||
|
||||
# Detect the system architecture
|
||||
if [ -n "$(uname -m | grep 64)" ]; then
|
||||
|
@ -50,7 +50,7 @@ elif [ -n "$(uname -m | grep 86)" ]; then
|
|||
elif [ -n "$(uname -m | grep arm)" ]; then
|
||||
architecture="arm"
|
||||
else
|
||||
ynh_die "Unable to detect your achitecture, please open a bug describing \
|
||||
ynh_die --message="Unable to detect your achitecture, please open a bug describing \
|
||||
your hardware and the result of the command \"uname -m\"." 1
|
||||
fi
|
||||
|
||||
|
@ -69,48 +69,46 @@ fi
|
|||
# Could be an option?
|
||||
client_max_body_size="250m"
|
||||
|
||||
path_url=$(ynh_normalize_url_path $path_url)
|
||||
|
||||
# Register (book) web path
|
||||
ynh_webpath_register $app $domain $path_url
|
||||
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
||||
|
||||
#=================================================
|
||||
# STORE SETTINGS FROM MANIFEST
|
||||
#=================================================
|
||||
ynh_print_info "Storing installation settings..."
|
||||
ynh_script_progression --message="Storing installation settings..." --weight=2
|
||||
|
||||
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 use_web_account $use_web_account
|
||||
ynh_app_setting_set $app final_path $final_path
|
||||
ynh_app_setting_set $app config_path $config_path
|
||||
ynh_app_setting_set $app architecture $architecture
|
||||
ynh_app_setting_set $app unicorn_worker_processes $unicorn_worker_processes
|
||||
ynh_app_setting_set $app client_max_body_size $client_max_body_size
|
||||
ynh_app_setting_set --app=$app --key=admin --value=$admin
|
||||
ynh_app_setting_set --app=$app --key=path_url --value=$path_url
|
||||
ynh_app_setting_set --app=$app --key=is_public --value=$is_public
|
||||
ynh_app_setting_set --app=$app --key=use_web_account --value=$use_web_account
|
||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||
ynh_app_setting_set --app=$app --key=config_path --value=$config_path
|
||||
ynh_app_setting_set --app=$app --key=architecture --value=$architecture
|
||||
ynh_app_setting_set --app=$app --key=unicorn_worker_processes --value=$unicorn_worker_processes
|
||||
ynh_app_setting_set --app=$app --key=client_max_body_size --value=$client_max_body_size
|
||||
|
||||
ynh_app_setting_set $app overwrite_nginx "1"
|
||||
ynh_app_setting_set --app=$app --key=overwrite_nginx --value="1"
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
# FIND A PORT
|
||||
#=================================================
|
||||
ynh_print_info "Find internal port..."
|
||||
ynh_script_progression --message="Find internal port..." --weight=1
|
||||
|
||||
# Find free ports
|
||||
port=$(ynh_find_port 8080)
|
||||
portUnicorn=$(ynh_find_port $(($port + 1)))
|
||||
portSidekiq=$(ynh_find_port $(($portUnicorn + 1)))
|
||||
port=$(ynh_find_port --port=8080)
|
||||
portUnicorn=$(ynh_find_port --port=$(($port + 1)))
|
||||
portSidekiq=$(ynh_find_port --port=$(($portUnicorn + 1)))
|
||||
|
||||
ynh_app_setting_set $app web_port $port
|
||||
ynh_app_setting_set $app unicorn_port $portUnicorn
|
||||
ynh_app_setting_set $app sidekiq_port $portSidekiq
|
||||
ynh_app_setting_set --app=$app --key=web_port --value=$port
|
||||
ynh_app_setting_set --app=$app --key=unicorn_port --value=$portUnicorn
|
||||
ynh_app_setting_set --app=$app --key=sidekiq_port --value=$portSidekiq
|
||||
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_print_info "Installing dependencies..."
|
||||
ynh_script_progression --message="Installing dependencies..." --weight=5
|
||||
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
|
@ -133,13 +131,13 @@ if [ $(($total_swap + $swap_needed)) -lt 2048 ]; then
|
|||
swap_needed=$((2048 - $total_swap))
|
||||
fi
|
||||
|
||||
ynh_print_info "Adding $swap_needed to swap..."
|
||||
ynh_add_swap $swap_needed
|
||||
ynh_script_progression --message="Adding $swap_needed Mo to swap..." --weight=1
|
||||
ynh_add_swap --size=$swap_needed
|
||||
|
||||
#=================================================
|
||||
# PRECONFIGURE GITLAB
|
||||
#=================================================
|
||||
ynh_print_info "Preconfigure gitlab..."
|
||||
ynh_script_progression --message="Preconfigure gitlab..." --weight=1
|
||||
|
||||
mkdir -p $config_path
|
||||
|
||||
|
@ -149,35 +147,35 @@ chown admin: "$config_path/gitlab-persistent.rb"
|
|||
cp -f ../conf/gitlab.rb "$config_path/gitlab.rb"
|
||||
ssh_port=$(grep -P "Port\s+\d+" /etc/ssh/sshd_config | grep -P -o "\d+")
|
||||
|
||||
ynh_replace_string "__GENERATED_EXTERNAL_URL__" "https://$domain${path_url%/}" "$config_path/gitlab.rb"
|
||||
ynh_replace_string "__PORT__" "$port" "$config_path/gitlab.rb"
|
||||
ynh_replace_string "__UNICORN_PORT__" "$portUnicorn" "$config_path/gitlab.rb"
|
||||
ynh_replace_string "__UNICORN_WORKER_PROCESSES__" "$unicorn_worker_processes" "$config_path/gitlab.rb"
|
||||
ynh_replace_string "__CLIENT_MAX_BODY_SIZE__" "$client_max_body_size" "$config_path/gitlab.rb"
|
||||
ynh_replace_string "__SSH_PORT__" "$ssh_port" "$config_path/gitlab.rb"
|
||||
ynh_replace_string "__SIDEKIQ_PORT__" "$portSidekiq" "$config_path/gitlab.rb"
|
||||
ynh_replace_string --match_string="__GENERATED_EXTERNAL_URL__" --replace_string="https://$domain${path_url%/}" --target_file="$config_path/gitlab.rb"
|
||||
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$config_path/gitlab.rb"
|
||||
ynh_replace_string --match_string="__UNICORN_PORT__" --replace_string="$portUnicorn" --target_file="$config_path/gitlab.rb"
|
||||
ynh_replace_string --match_string="__UNICORN_WORKER_PROCESSES__" --replace_string="$unicorn_worker_processes" --target_file="$config_path/gitlab.rb"
|
||||
ynh_replace_string --match_string="__CLIENT_MAX_BODY_SIZE__" --replace_string="$client_max_body_size" --target_file="$config_path/gitlab.rb"
|
||||
ynh_replace_string --match_string="__SSH_PORT__" --replace_string="$ssh_port" --target_file="$config_path/gitlab.rb"
|
||||
ynh_replace_string --match_string="__SIDEKIQ_PORT__" --replace_string="$portSidekiq" --target_file="$config_path/gitlab.rb"
|
||||
|
||||
#=================================================
|
||||
# STORE THE CONFIG FILE CHECKSUM
|
||||
#=================================================
|
||||
|
||||
ynh_store_file_checksum "$config_path/gitlab.rb"
|
||||
ynh_store_file_checksum --file="$config_path/gitlab.rb"
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_print_info "Setting up source files..."
|
||||
ynh_script_progression --message="Setting up source files..." --weight=200
|
||||
|
||||
update_src_version() {
|
||||
source ./upgrade.d/upgrade.last.sh
|
||||
cp ../conf/$architecture.src.default ../conf/$architecture.src
|
||||
ynh_replace_string "__VERSION__" "$gitlab_version" "../conf/$architecture.src"
|
||||
ynh_replace_string "__SOURCE_FILENAME__" "$gitlab_filename" "../conf/$architecture.src"
|
||||
ynh_replace_string --match_string="__VERSION__" --replace_string="$gitlab_version" --target_file="../conf/$architecture.src"
|
||||
ynh_replace_string --match_string="__SOURCE_FILENAME__" --replace_string="$gitlab_filename" --target_file="../conf/$architecture.src"
|
||||
|
||||
if [ $architecture = "x86-64" ]; then
|
||||
ynh_replace_string "__SHA256_SUM__" "$gitlab_x86_64_source_sha256" "../conf/$architecture.src"
|
||||
ynh_replace_string --match_string="__SHA256_SUM__" --replace_string="$gitlab_x86_64_source_sha256" --target_file="../conf/$architecture.src"
|
||||
elif [ $architecture = "arm" ]; then
|
||||
ynh_replace_string "__SHA256_SUM__" "$gitlab_arm_source_sha256" "../conf/$architecture.src"
|
||||
ynh_replace_string --match_string="__SHA256_SUM__" --replace_string="$gitlab_arm_source_sha256" --target_file="../conf/$architecture.src"
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -185,21 +183,21 @@ update_src_version
|
|||
|
||||
tempdir="$(mktemp -d)"
|
||||
|
||||
ynh_setup_source $tempdir $architecture
|
||||
ynh_setup_source --dest_dir=$tempdir --source_id=$architecture
|
||||
|
||||
if IS_PACKAGE_CHECK; then
|
||||
if ! dpkg -i $tempdir/$gitlab_filename ; then # This command will fail in lxc env
|
||||
ynh_replace_string "command \"cat \/etc\/sysctl.conf \/etc\/sysctl.d\/\*.conf | sysctl -e -p -\"" "command \"cat \/etc\/sysctl.conf\"" "$final_path/embedded/cookbooks/package/resources/sysctl.rb"
|
||||
dpkg --configure gitlab-ce
|
||||
if ! ynh_exec_warn_less dpkg -i $tempdir/$gitlab_filename ; then # This command will fail in lxc env
|
||||
ynh_replace_string --match_string="command \"cat \/etc\/sysctl.conf \/etc\/sysctl.d\/\*.conf | sysctl -e -p -\"" --replace_string="command \"cat \/etc\/sysctl.conf\"" --target_file="$final_path/embedded/cookbooks/package/resources/sysctl.rb"
|
||||
ynh_exec_warn_less dpkg --configure gitlab-ce
|
||||
fi
|
||||
else
|
||||
dpkg -i $tempdir/$gitlab_filename
|
||||
ynh_exec_warn_less dpkg -i $tempdir/$gitlab_filename
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info "Configuring nginx web server..."
|
||||
ynh_script_progression --message="Configuring nginx web server..." --weight=2
|
||||
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config client_max_body_size
|
||||
|
@ -209,10 +207,10 @@ ynh_add_nginx_config client_max_body_size
|
|||
#=================================================
|
||||
# ADD USER AND CONFIGURE SIGN IN SYSTEM
|
||||
#=================================================
|
||||
ynh_print_info "Creating an administrator user..."
|
||||
ynh_script_progression --message="Creating an administrator user..." --weight=13
|
||||
|
||||
mailadmin=$(ynh_user_get_info $admin mail)
|
||||
rdmPass=$(ynh_string_random 30)
|
||||
mailadmin=$(ynh_user_get_info --username=$admin --key=mail)
|
||||
rdmPass=$(ynh_string_random --length=30)
|
||||
|
||||
echo "newuser = User.new({ \"email\"=>'$mailadmin', \"username\"=>'$admin', \"name\"=>'$admin', \"password\"=>'$rdmPass'})
|
||||
newuser.admin = true
|
||||
|
@ -224,7 +222,7 @@ ApplicationSetting.last.update_attributes(password_authentication_enabled_for_we
|
|||
#=================================================
|
||||
# RECONFIGURE TO TAKE INTO ACCOUNT CHANGES
|
||||
#=================================================
|
||||
ynh_print_info "Reconfigure gitlab..."
|
||||
ynh_script_progression --message="Reconfigure gitlab..." --weight=13
|
||||
|
||||
gitlab-ctl reconfigure
|
||||
|
||||
|
@ -239,18 +237,18 @@ yunohost service add "gitlab-runsvdir" --log "/var/log/$app/gitlab-rails/applica
|
|||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
ynh_print_info "Configuring SSOwat..."
|
||||
ynh_script_progression --message="Configuring SSOwat..." --weight=1
|
||||
|
||||
# Make app public if necessary
|
||||
if [ $is_public -eq 1 ]; then
|
||||
# unprotected_uris allows SSO credentials to be passed anyway.
|
||||
ynh_app_setting_set $app unprotected_uris "/"
|
||||
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_print_info "Reloading nginx web server..."
|
||||
ynh_script_progression --message="Reloading nginx web server..." --weight=1
|
||||
|
||||
ynh_systemd_action --action=reload --service_name=nginx
|
||||
|
||||
|
@ -258,4 +256,4 @@ ynh_systemd_action --action=reload --service_name=nginx
|
|||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Installation of $app completed"
|
||||
ynh_script_progression --message="Installation of $app completed" --last
|
||||
|
|
|
@ -12,15 +12,15 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_print_info "Loading installation settings..."
|
||||
ynh_script_progression --message="Loading installation settings..." --weight=2
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
port=$(ynh_app_setting_get "$app" web_port)
|
||||
portUnicorn=$(ynh_app_setting_get "$app" unicorn_port)
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
config_path=$(ynh_app_setting_get $app config_path)
|
||||
domain=$(ynh_app_setting_get --app="$app" --key=domain)
|
||||
port=$(ynh_app_setting_get --app="$app" --key=web_port)
|
||||
portUnicorn=$(ynh_app_setting_get --app="$app" --key=unicorn_port)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
config_path=$(ynh_app_setting_get --app=$app --key=config_path)
|
||||
|
||||
#=================================================
|
||||
# STANDARD REMOVE
|
||||
|
@ -30,28 +30,28 @@ config_path=$(ynh_app_setting_get $app config_path)
|
|||
|
||||
if yunohost service status "gitlab-runsvdir" >/dev/null 2>&1
|
||||
then
|
||||
ynh_print_info "Removing $app service"
|
||||
ynh_script_progression --message="Removing $app service" --weight=1
|
||||
yunohost service remove "gitlab-runsvdir"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# STOP GITLAB
|
||||
#=================================================
|
||||
ynh_print_info "Stopping gitlab"
|
||||
ynh_script_progression --message="Stopping gitlab" --weight=8
|
||||
|
||||
gitlab-ctl stop
|
||||
|
||||
#=================================================
|
||||
# REMOVE GITLAB
|
||||
#=================================================
|
||||
ynh_print_info "Removing Gitlab"
|
||||
ynh_script_progression --message="Removing Gitlab" --weight=4
|
||||
|
||||
dpkg --remove gitlab-ce
|
||||
|
||||
#=================================================
|
||||
# REMOVE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_print_info "Removing dependencies"
|
||||
ynh_script_progression --message="Removing dependencies" --weight=3
|
||||
|
||||
# Remove metapackage and its dependencies
|
||||
ynh_remove_app_dependencies
|
||||
|
@ -59,16 +59,16 @@ ynh_remove_app_dependencies
|
|||
#=================================================
|
||||
# REMOVE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_print_info "Removing app main directory"
|
||||
ynh_script_progression --message="Removing app main directory" --weight=1
|
||||
|
||||
# Remove the app directory securely
|
||||
ynh_secure_remove "$final_path"
|
||||
ynh_secure_remove "$config_path"
|
||||
ynh_secure_remove --file="$final_path"
|
||||
ynh_secure_remove --file="$config_path"
|
||||
|
||||
#=================================================
|
||||
# REMOVE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info "Removing nginx web server configuration"
|
||||
ynh_script_progression --message="Removing nginx web server configuration" --weight=1
|
||||
|
||||
# Remove the dedicated nginx config
|
||||
ynh_remove_nginx_config
|
||||
|
@ -79,12 +79,12 @@ ynh_remove_nginx_config
|
|||
|
||||
# These ports are no longer open but were in previous versions
|
||||
if yunohost firewall list | grep -q "\- $port$"; then
|
||||
ynh_print_info "Closing port $port"
|
||||
ynh_script_progression --message="Closing port $port" --weight=1
|
||||
ynh_exec_warn_less yunohost firewall disallow TCP $port
|
||||
fi
|
||||
|
||||
if yunohost firewall list | grep -q "\- $portUnicorn$"; then
|
||||
ynh_print_info "Closing port $portUnicorn"
|
||||
ynh_script_progression --message="Closing port $portUnicorn" --weight=1
|
||||
ynh_exec_warn_less yunohost firewall disallow TCP $portUnicorn
|
||||
fi
|
||||
|
||||
|
@ -94,10 +94,10 @@ fi
|
|||
# REMOVE GITLAB FILES
|
||||
#=================================================
|
||||
|
||||
ynh_secure_remove "/var/opt/$app"
|
||||
ynh_secure_remove --file="/var/opt/$app"
|
||||
|
||||
# Remove the log files
|
||||
ynh_secure_remove "/var/log/$app"
|
||||
ynh_secure_remove --file="/var/log/$app"
|
||||
|
||||
# Remove swap
|
||||
|
||||
|
@ -107,4 +107,4 @@ ynh_del_swap
|
|||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Removal of $app completed"
|
||||
ynh_script_progression --message="Removal of $app completed" --last
|
||||
|
|
|
@ -15,7 +15,7 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
|
||||
ynh_clean_setup () {
|
||||
ynh_secure_remove "$tempdir" 2>&1
|
||||
ynh_exec_warn_less ynh_secure_remove --file="$tempdir"
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
@ -23,27 +23,27 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_print_info "Loading settings..."
|
||||
ynh_script_progression --message="Loading settings..." --weight=1
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
path_url=$(ynh_app_setting_get $app path)
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
config_path=$(ynh_app_setting_get $app config_path)
|
||||
port=$(ynh_app_setting_get "$app" web_port)
|
||||
portUnicorn=$(ynh_app_setting_get "$app" unicorn_port)
|
||||
architecture=$(ynh_app_setting_get "$app" architecture)
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
config_path=$(ynh_app_setting_get --app=$app --key=config_path)
|
||||
port=$(ynh_app_setting_get --app="$app" --key=web_port)
|
||||
portUnicorn=$(ynh_app_setting_get --app="$app" --key=unicorn_port)
|
||||
architecture=$(ynh_app_setting_get --app="$app" --key=architecture)
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE RESTORED
|
||||
#=================================================
|
||||
ynh_print_info "Validating restoration parameters..."
|
||||
ynh_script_progression --message="Validating restoration parameters..." --weight=1
|
||||
|
||||
ynh_webpath_available $domain $path_url \
|
||||
|| ynh_die "Path not available: ${domain}${path_url}"
|
||||
ynh_webpath_available --domain=$domain --path_url=$path_url \
|
||||
|| ynh_die --message="Path not available: ${domain}${path_url}"
|
||||
test ! -d $final_path \
|
||||
|| ynh_die "There is already a directory: $final_path "
|
||||
|| ynh_die --message="There is already a directory: $final_path "
|
||||
|
||||
#=================================================
|
||||
# STANDARD RESTORATION STEPS
|
||||
|
@ -51,12 +51,12 @@ test ! -d $final_path \
|
|||
# RESTORE THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# REINSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_print_info "Reinstalling dependencies..."
|
||||
ynh_script_progression --message="Reinstalling dependencies..." --weight=5
|
||||
|
||||
# Define and install dependencies
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
|
@ -64,7 +64,6 @@ ynh_install_app_dependencies $pkg_dependencies
|
|||
#=================================================
|
||||
# ADD SWAP IF NEEDED
|
||||
#=================================================
|
||||
ynh_print_info "Adding swap..."
|
||||
|
||||
total_memory=$(ynh_check_ram)
|
||||
total_swap=$(ynh_check_ram --only_swap)
|
||||
|
@ -81,34 +80,34 @@ if [ $(($total_swap + $swap_needed)) -lt 2048 ]; then
|
|||
swap_needed=$((2048 - $total_swap))
|
||||
fi
|
||||
|
||||
ynh_print_info "Adding $swap_needed to swap..."
|
||||
ynh_add_swap $swap_needed
|
||||
ynh_script_progression --message="Adding $swap_needed Mo to swap..." --weight=1
|
||||
ynh_add_swap --size=$swap_needed
|
||||
|
||||
#=================================================
|
||||
# RESTORE CONF FILES
|
||||
#=================================================
|
||||
ynh_print_info "Restoring configuration files of Gitlab..."
|
||||
ynh_script_progression --message="Restoring configuration files of Gitlab..." --weight=1
|
||||
|
||||
ynh_restore_file "$config_path/gitlab-secrets.json"
|
||||
ynh_restore_file "$config_path/gitlab.rb"
|
||||
ynh_restore_file "$config_path/gitlab-persistent.rb"
|
||||
ynh_restore_file --origin_path="$config_path/gitlab-secrets.json"
|
||||
ynh_restore_file --origin_path="$config_path/gitlab.rb"
|
||||
ynh_restore_file --origin_path="$config_path/gitlab-persistent.rb"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_print_info "Reinstalling gitlab..."
|
||||
ynh_script_progression --message="Reinstalling gitlab..." --weight=200
|
||||
|
||||
update_src_version() {
|
||||
source ../settings/scripts/upgrade.d/upgrade.last.sh
|
||||
mkdir -p ../conf/
|
||||
cp ../settings/conf/$architecture.src.default ../conf/$architecture.src
|
||||
ynh_replace_string "__VERSION__" "$gitlab_version" "../conf/$architecture.src"
|
||||
ynh_replace_string "__SOURCE_FILENAME__" "$gitlab_filename" "../conf/$architecture.src"
|
||||
ynh_replace_string --match_string="__VERSION__" --replace_string="$gitlab_version" --target_file="../conf/$architecture.src"
|
||||
ynh_replace_string --match_string="__SOURCE_FILENAME__" --replace_string="$gitlab_filename" --target_file="../conf/$architecture.src"
|
||||
|
||||
if [ $architecture = "x86-64" ]; then
|
||||
ynh_replace_string "__SHA256_SUM__" "$gitlab_x86_64_source_sha256" "../conf/$architecture.src"
|
||||
ynh_replace_string --match_string="__SHA256_SUM__" --replace_string="$gitlab_x86_64_source_sha256" --target_file="../conf/$architecture.src"
|
||||
elif [ $architecture = "arm" ]; then
|
||||
ynh_replace_string "__SHA256_SUM__" "$gitlab_arm_source_sha256" "../conf/$architecture.src"
|
||||
ynh_replace_string --match_string="__SHA256_SUM__" --replace_string="$gitlab_arm_source_sha256" --target_file="../conf/$architecture.src"
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -116,15 +115,15 @@ update_src_version
|
|||
|
||||
tempdir="$(mktemp -d)"
|
||||
|
||||
ynh_setup_source $tempdir $architecture
|
||||
ynh_setup_source --dest_dir=$tempdir --source_id=$architecture
|
||||
|
||||
if IS_PACKAGE_CHECK; then
|
||||
if ! dpkg -i $tempdir/$gitlab_filename ; then # This command will fail in lxc env
|
||||
ynh_replace_string "command \"cat \/etc\/sysctl.conf \/etc\/sysctl.d\/\*.conf | sysctl -e -p -\"" "command \"cat \/etc\/sysctl.conf\"" "$final_path/embedded/cookbooks/package/resources/sysctl.rb"
|
||||
dpkg --configure gitlab-ce
|
||||
if ! ynh_exec_warn_less dpkg -i $tempdir/$gitlab_filename ; then # This command will fail in lxc env
|
||||
ynh_replace_string --match_string="command \"cat \/etc\/sysctl.conf \/etc\/sysctl.d\/\*.conf | sysctl -e -p -\"" --replace_string="command \"cat \/etc\/sysctl.conf\"" --target_file="$final_path/embedded/cookbooks/package/resources/sysctl.rb"
|
||||
ynh_exec_warn_less dpkg --configure gitlab-ce
|
||||
fi
|
||||
else
|
||||
dpkg -i $tempdir/$gitlab_filename
|
||||
ynh_exec_warn_less dpkg -i $tempdir/$gitlab_filename
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
@ -132,9 +131,9 @@ fi
|
|||
#=================================================
|
||||
# RESTORE GITLAB DATABASE
|
||||
#=================================================
|
||||
ynh_print_info "Restoring Gitlab..."
|
||||
ynh_script_progression --message="Restoring Gitlab..." --weight=55
|
||||
|
||||
ynh_restore_file "/var/opt/$app/backups/last_gitlab_backup.tar"
|
||||
ynh_restore_file --origin_path="/var/opt/$app/backups/last_gitlab_backup.tar"
|
||||
|
||||
last_backup="last"
|
||||
|
||||
|
@ -157,14 +156,14 @@ yunohost service add "gitlab-runsvdir" --log "/var/log/$app/gitlab-rails/applica
|
|||
#=================================================
|
||||
# WAITING GITLAB
|
||||
#=================================================
|
||||
ynh_print_info "Waiting for gitlab..."
|
||||
ynh_script_progression --message="Waiting for gitlab..." --weight=14
|
||||
|
||||
ynh_systemd_action --action=restart --service_name="gitlab-runsvdir" --log_path="/var/log/$app/unicorn/current" --line_match="adopted" --timeout=3600
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_print_info "Reloading nginx web server..."
|
||||
ynh_script_progression --message="Reloading nginx web server..." --weight=1
|
||||
|
||||
ynh_systemd_action --action=reload --service_name=nginx
|
||||
|
||||
|
@ -172,4 +171,4 @@ ynh_systemd_action --action=reload --service_name=nginx
|
|||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Restoration completed for $app"
|
||||
ynh_script_progression --message="Restoration completed for $app" --last
|
||||
|
|
136
scripts/upgrade
136
scripts/upgrade
|
@ -19,19 +19,25 @@ source ./_common.sh
|
|||
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)
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
config_path=$(ynh_app_setting_get $app config_path)
|
||||
port=$(ynh_app_setting_get "$app" web_port)
|
||||
portUnicorn=$(ynh_app_setting_get "$app" unicorn_port)
|
||||
portSidekiq=$(ynh_app_setting_get "$app" sidekiq_port)
|
||||
architecture=$(ynh_app_setting_get "$app" architecture)
|
||||
unicorn_worker_processes=$(ynh_app_setting_get "$app" unicorn_worker_processes)
|
||||
client_max_body_size=$(ynh_app_setting_get "$app" client_max_body_size)
|
||||
overwrite_nginx=$(ynh_app_setting_get "$app" overwrite_nginx)
|
||||
domain=$(ynh_app_setting_get --app="$app" --key=domain)
|
||||
path_url=$(ynh_app_setting_get --app="$app" --key=path_url)
|
||||
admin=$(ynh_app_setting_get --app="$app" --key=admin)
|
||||
is_public=$(ynh_app_setting_get --app="$app" --key=is_public)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
config_path=$(ynh_app_setting_get --app=$app --key=config_path)
|
||||
port=$(ynh_app_setting_get --app="$app" --key=web_port)
|
||||
portUnicorn=$(ynh_app_setting_get --app="$app" --key=unicorn_port)
|
||||
portSidekiq=$(ynh_app_setting_get --app="$app" --key=sidekiq_port)
|
||||
architecture=$(ynh_app_setting_get --app="$app" --key=architecture)
|
||||
unicorn_worker_processes=$(ynh_app_setting_get --app="$app" --key=unicorn_worker_processes)
|
||||
client_max_body_size=$(ynh_app_setting_get --app="$app" --key=client_max_body_size)
|
||||
overwrite_nginx=$(ynh_app_setting_get --app="$app" --key=overwrite_nginx)
|
||||
|
||||
#=================================================
|
||||
# CHECK VERSION
|
||||
#=================================================
|
||||
|
||||
upgrade_type=$(ynh_check_app_version_changed)
|
||||
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
|
@ -39,23 +45,23 @@ overwrite_nginx=$(ynh_app_setting_get "$app" overwrite_nginx)
|
|||
|
||||
# Fix is_public as a boolean value
|
||||
if [ "$is_public" = "Yes" ]; then
|
||||
ynh_app_setting_set $app is_public 1
|
||||
ynh_app_setting_set --app=$app --key=is_public --value=1
|
||||
is_public=1
|
||||
elif [ "$is_public" = "No" ]; then
|
||||
ynh_app_setting_set $app is_public 0
|
||||
ynh_app_setting_set --app=$app --key=is_public --value=0
|
||||
is_public=0
|
||||
fi
|
||||
|
||||
# If final_path doesn't exist, create it
|
||||
if [ -z "$final_path" ]; then
|
||||
final_path=/opt/$app
|
||||
ynh_app_setting_set $app final_path $final_path
|
||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||
fi
|
||||
|
||||
# If config_path doesn't exist, create it
|
||||
if [ -z "$config_path" ]; then
|
||||
config_path=/etc/$app
|
||||
ynh_app_setting_set $app config_path $config_path
|
||||
ynh_app_setting_set --app=$app --key=config_path --value=$config_path
|
||||
fi
|
||||
|
||||
if [ -z "$unicorn_worker_processes" ]; then
|
||||
|
@ -70,13 +76,13 @@ if [ -z "$unicorn_worker_processes" ]; then
|
|||
# 2 worker processes
|
||||
unicorn_worker_processes=2
|
||||
fi
|
||||
ynh_app_setting_set $app unicorn_worker_processes $unicorn_worker_processes
|
||||
ynh_app_setting_set --app=$app --key=unicorn_worker_processes --value=$unicorn_worker_processes
|
||||
fi
|
||||
|
||||
if [ -z "$portSidekiq" ]; then
|
||||
portSidekiq=$(ynh_find_port $(($portUnicorn + 1)))
|
||||
|
||||
ynh_app_setting_set $app sidekiq_port $portSidekiq
|
||||
ynh_app_setting_set --app=$app --key=sidekiq_port --value=$portSidekiq
|
||||
fi
|
||||
|
||||
# If architecture doesn't exist, create it
|
||||
|
@ -89,10 +95,10 @@ if [ -z "$architecture" ]; then
|
|||
elif [ -n "$(uname -m | grep arm)" ]; then
|
||||
architecture="arm"
|
||||
else
|
||||
ynh_die "Unable to detect your achitecture, please open a bug describing \
|
||||
ynh_die --message="Unable to detect your achitecture, please open a bug describing \
|
||||
your hardware and the result of the command \"uname -m\"." 1
|
||||
fi
|
||||
ynh_app_setting_set $app architecture $architecture
|
||||
ynh_app_setting_set --app=$app --key=architecture --value=$architecture
|
||||
fi
|
||||
|
||||
# If client_max_body_size doesn't exist, create it
|
||||
|
@ -103,7 +109,7 @@ fi
|
|||
# If overwrite_nginx doesn't exist, create it
|
||||
if [ -z "$overwrite_nginx" ]; then
|
||||
overwrite_nginx=1
|
||||
ynh_app_setting_set $app overwrite_nginx $overwrite_nginx
|
||||
ynh_app_setting_set --app=$app --key=overwrite_nginx --value=$overwrite_nginx
|
||||
fi
|
||||
|
||||
# If domain doesn't exist, retrieve it
|
||||
|
@ -112,42 +118,42 @@ if [ -z "$domain" ]; then
|
|||
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
|
||||
ynh_app_setting_set --app=$app --key=domain --value=$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
|
||||
ynh_app_setting_set --app=$app --key=path_url --value=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
|
||||
ynh_app_setting_set --app=$app --key=web_port --value=$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
|
||||
ynh_app_setting_set --app=$app --key=unicorn_port --value=$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"
|
||||
ynh_secure_remove --file="/etc/apt/sources.list.d/gitlab-ce.list"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
ynh_print_info "Backing up the app before upgrading (may take a while)..."
|
||||
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=10
|
||||
|
||||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
ynh_clean_setup () {
|
||||
ynh_secure_remove "$tempdir" 2>&1
|
||||
ynh_exec_warn_less ynh_secure_remove --file="$tempdir"
|
||||
|
||||
ynh_clean_check_starting
|
||||
|
||||
|
@ -169,14 +175,13 @@ path_url=$(ynh_normalize_url_path $path_url)
|
|||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_print_info "Installing dependencies..."
|
||||
ynh_script_progression --message="Installing dependencies..." --weight=5
|
||||
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
#=================================================
|
||||
# ADD SWAP IF NEEDED
|
||||
#=================================================
|
||||
ynh_print_info "Adding swap..."
|
||||
|
||||
total_memory=$(ynh_check_ram)
|
||||
total_swap=$(ynh_check_ram --only_swap)
|
||||
|
@ -193,31 +198,31 @@ if [ $(($total_swap + $swap_needed)) -lt 2048 ]; then
|
|||
swap_needed=$((2048 - $total_swap))
|
||||
fi
|
||||
|
||||
ynh_print_info "Adding $swap_needed to swap..."
|
||||
ynh_add_swap $swap_needed
|
||||
ynh_script_progression --message="Adding $swap_needed Mo to swap..." --weight=1
|
||||
ynh_add_swap --size=$swap_needed
|
||||
|
||||
#=================================================
|
||||
# PRECONFIGURE GITLAB
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Preconfigure gitlab..."
|
||||
ynh_script_progression --message="Preconfigure gitlab..." --weight=1
|
||||
|
||||
ynh_backup_if_checksum_is_different "$config_path/gitlab.rb"
|
||||
ynh_backup_if_checksum_is_different --file="$config_path/gitlab.rb"
|
||||
|
||||
mkdir -p $config_path
|
||||
|
||||
cp -f ../conf/gitlab.rb "$config_path/gitlab.rb"
|
||||
ssh_port=$(grep -P "Port\s+\d+" /etc/ssh/sshd_config | grep -P -o "\d+")
|
||||
|
||||
ynh_replace_string "__GENERATED_EXTERNAL_URL__" "https://$domain${path_url%/}" "$config_path/gitlab.rb"
|
||||
ynh_replace_string "__PORT__" "$port" "$config_path/gitlab.rb"
|
||||
ynh_replace_string "__UNICORN_PORT__" "$portUnicorn" "$config_path/gitlab.rb"
|
||||
ynh_replace_string "__UNICORN_WORKER_PROCESSES__" "$unicorn_worker_processes" "$config_path/gitlab.rb"
|
||||
ynh_replace_string "__CLIENT_MAX_BODY_SIZE__" "$client_max_body_size" "$config_path/gitlab.rb"
|
||||
ynh_replace_string "__SSH_PORT__" "$ssh_port" "$config_path/gitlab.rb"
|
||||
ynh_replace_string "__SIDEKIQ_PORT__" "$portSidekiq" "$config_path/gitlab.rb"
|
||||
ynh_replace_string --match_string="__GENERATED_EXTERNAL_URL__" --replace_string="https://$domain${path_url%/}" --target_file="$config_path/gitlab.rb"
|
||||
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$config_path/gitlab.rb"
|
||||
ynh_replace_string --match_string="__UNICORN_PORT__" --replace_string="$portUnicorn" --target_file="$config_path/gitlab.rb"
|
||||
ynh_replace_string --match_string="__UNICORN_WORKER_PROCESSES__" --replace_string="$unicorn_worker_processes" --target_file="$config_path/gitlab.rb"
|
||||
ynh_replace_string --match_string="__CLIENT_MAX_BODY_SIZE__" --replace_string="$client_max_body_size" --target_file="$config_path/gitlab.rb"
|
||||
ynh_replace_string --match_string="__SSH_PORT__" --replace_string="$ssh_port" --target_file="$config_path/gitlab.rb"
|
||||
ynh_replace_string --match_string="__SIDEKIQ_PORT__" --replace_string="$portSidekiq" --target_file="$config_path/gitlab.rb"
|
||||
|
||||
ynh_store_file_checksum "$config_path/gitlab.rb"
|
||||
ynh_store_file_checksum --file="$config_path/gitlab.rb"
|
||||
|
||||
touch "$config_path/gitlab-persistent.rb"
|
||||
chown admin: "$config_path/gitlab-persistent.rb"
|
||||
|
@ -225,34 +230,40 @@ chown admin: "$config_path/gitlab-persistent.rb"
|
|||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_print_info "Setting up source files..."
|
||||
|
||||
update_src_version() {
|
||||
source ./upgrade.d/upgrade.last.sh
|
||||
cp ../conf/$architecture.src.default ../conf/$architecture.src
|
||||
ynh_replace_string "__VERSION__" "$gitlab_version" "../conf/$architecture.src"
|
||||
ynh_replace_string "__SOURCE_FILENAME__" "$gitlab_filename" "../conf/$architecture.src"
|
||||
ynh_replace_string --match_string="__VERSION__" --replace_string="$gitlab_version" --target_file="../conf/$architecture.src"
|
||||
ynh_replace_string --match_string="__SOURCE_FILENAME__" --replace_string="$gitlab_filename" --target_file="../conf/$architecture.src"
|
||||
|
||||
if [ $architecture = "x86-64" ]; then
|
||||
ynh_replace_string "__SHA256_SUM__" "$gitlab_x86_64_source_sha256" "../conf/$architecture.src"
|
||||
ynh_replace_string --match_string="__SHA256_SUM__" --replace_string="$gitlab_x86_64_source_sha256" --target_file="../conf/$architecture.src"
|
||||
elif [ $architecture = "arm" ]; then
|
||||
ynh_replace_string "__SHA256_SUM__" "$gitlab_arm_source_sha256" "../conf/$architecture.src"
|
||||
ynh_replace_string --match_string="__SHA256_SUM__" --replace_string="$gitlab_arm_source_sha256" --target_file="../conf/$architecture.src"
|
||||
fi
|
||||
}
|
||||
|
||||
update_src_version
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
ynh_script_progression --message="Setting up source files..." --weight=200
|
||||
|
||||
tempdir="$(mktemp -d)"
|
||||
update_src_version
|
||||
|
||||
ynh_setup_source $tempdir $architecture
|
||||
tempdir="$(mktemp -d)"
|
||||
|
||||
if IS_PACKAGE_CHECK; then
|
||||
if ! dpkg -i $tempdir/$gitlab_filename ; then # This command will fail in lxc env
|
||||
ynh_replace_string "command \"cat \/etc\/sysctl.conf \/etc\/sysctl.d\/\*.conf | sysctl -e -p -\"" "command \"cat \/etc\/sysctl.conf\"" "$final_path/embedded/cookbooks/package/resources/sysctl.rb"
|
||||
dpkg --configure gitlab-ce
|
||||
ynh_setup_source --dest_dir=$tempdir --source_id=$architecture
|
||||
|
||||
if IS_PACKAGE_CHECK; then
|
||||
if ! ynh_exec_warn_less dpkg -i $tempdir/$gitlab_filename ; then # This command will fail in lxc env
|
||||
ynh_replace_string --match_string="command \"cat \/etc\/sysctl.conf \/etc\/sysctl.d\/\*.conf | sysctl -e -p -\"" --replace_string="command \"cat \/etc\/sysctl.conf\"" --target_file="$final_path/embedded/cookbooks/package/resources/sysctl.rb"
|
||||
ynh_exec_warn_less dpkg --configure gitlab-ce
|
||||
fi
|
||||
else
|
||||
dpkg -i $tempdir/$gitlab_filename
|
||||
else
|
||||
ynh_exec_warn_less dpkg -i $tempdir/$gitlab_filename
|
||||
fi
|
||||
|
||||
ynh_exec_warn_less ynh_secure_remove --file="$tempdir"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
@ -262,7 +273,7 @@ fi
|
|||
# Overwrite the nginx configuration only if it's allowed
|
||||
if [ $overwrite_nginx -eq 1 ]
|
||||
then
|
||||
ynh_print_info "Configuring nginx web server..."
|
||||
ynh_script_progression --message="Configuring nginx web server..." --weight=2
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config client_max_body_size
|
||||
fi
|
||||
|
@ -282,13 +293,13 @@ yunohost service add "gitlab-runsvdir" --log "/var/log/$app/gitlab-rails/applica
|
|||
# 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 "/"
|
||||
ynh_app_setting_set --app="$app" --key=unprotected_uris --value="/"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# WAITING GITLAB
|
||||
#=================================================
|
||||
ynh_print_info "Waiting for gitlab..."
|
||||
ynh_script_progression --message="Waiting for gitlab..." --weight=15
|
||||
|
||||
# Action status to just wait the service
|
||||
ynh_systemd_action --action=status --service_name="gitlab-runsvdir" --log_path="/var/log/$app/unicorn/current" --line_match="adopted" --timeout=3600
|
||||
|
@ -296,7 +307,7 @@ ynh_systemd_action --action=status --service_name="gitlab-runsvdir" --log_path="
|
|||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_print_info "Reloading nginx web server..."
|
||||
ynh_script_progression --message="Reloading nginx web server..." --weight=1
|
||||
|
||||
ynh_systemd_action --action=reload --service_name=nginx
|
||||
|
||||
|
@ -304,5 +315,4 @@ ynh_systemd_action --action=reload --service_name=nginx
|
|||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Upgrade of $app completed"
|
||||
|
||||
ynh_script_progression --message="Upgrade of $app completed"--last
|
||||
|
|
Loading…
Reference in a new issue