mirror of
https://github.com/YunoHost-Apps/gitlab_ynh.git
synced 2024-09-03 18:36:35 +02:00
Normalization from example_ynh
This commit is contained in:
parent
f925a143b9
commit
a9904228e5
10 changed files with 215 additions and 227 deletions
|
@ -14,7 +14,7 @@
|
|||
"email": "pierre@kayou.io"
|
||||
},
|
||||
"requirements": {
|
||||
"yunohost": ">> 3.3.0"
|
||||
"yunohost": ">= 3.5.0"
|
||||
},
|
||||
"multi_instance": false,
|
||||
"services": [
|
||||
|
|
|
@ -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..." --time
|
||||
|
||||
# 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..." --time
|
||||
# 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..." --time
|
||||
|
||||
ynh_systemd_action --action=reload --service_name=nginx
|
||||
|
||||
|
|
|
@ -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,12 +43,12 @@ 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..." --time
|
||||
|
||||
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
|
||||
|
|
|
@ -24,48 +24,48 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_print_info "Loading installation settings..."
|
||||
ynh_script_progression --message="Loading installation settings..." --time
|
||||
|
||||
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..." --time
|
||||
|
||||
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..." --time
|
||||
|
||||
# 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..." --time
|
||||
|
||||
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)." --time --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..." --time
|
||||
|
||||
# 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..." --time
|
||||
|
||||
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..." --time
|
||||
|
||||
#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..." --time
|
||||
|
||||
# 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..." --time
|
||||
|
||||
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..." --time
|
||||
|
||||
# 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..." --time
|
||||
|
||||
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" --time --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"
|
||||
}
|
||||
|
||||
#=================================================
|
||||
|
|
106
scripts/install
106
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..." --time
|
||||
|
||||
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,55 +69,53 @@ 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..." --time
|
||||
|
||||
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..." --time
|
||||
|
||||
# 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..." --time
|
||||
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
#=================================================
|
||||
# PRECONFIGURE GITLAB
|
||||
#=================================================
|
||||
ynh_print_info "Preconfigure gitlab..."
|
||||
ynh_script_progression --message="Preconfigure gitlab..." --time
|
||||
|
||||
mkdir -p $config_path
|
||||
|
||||
|
@ -127,35 +125,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..." --time
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -163,21 +161,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..." --time
|
||||
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config client_max_body_size
|
||||
|
@ -187,10 +185,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..." --time
|
||||
|
||||
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
|
||||
|
@ -202,7 +200,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..." --time
|
||||
|
||||
gitlab-ctl reconfigure
|
||||
|
||||
|
@ -217,18 +215,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..." --time
|
||||
|
||||
# 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..." --time
|
||||
|
||||
ynh_systemd_action --action=reload --service_name=nginx
|
||||
|
||||
|
@ -236,4 +234,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" --time --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..." --time
|
||||
|
||||
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" --time
|
||||
yunohost service remove "gitlab-runsvdir"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# STOP GITLAB
|
||||
#=================================================
|
||||
ynh_print_info "Stopping gitlab"
|
||||
ynh_script_progression --message="Stopping gitlab" --time
|
||||
|
||||
gitlab-ctl stop
|
||||
|
||||
#=================================================
|
||||
# REMOVE GITLAB
|
||||
#=================================================
|
||||
ynh_print_info "Removing Gitlab"
|
||||
ynh_script_progression --message="Removing Gitlab" --time
|
||||
|
||||
dpkg --remove gitlab-ce
|
||||
|
||||
#=================================================
|
||||
# REMOVE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_print_info "Removing dependencies"
|
||||
ynh_script_progression --message="Removing dependencies" --time
|
||||
|
||||
# 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" --time
|
||||
|
||||
# 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" --time
|
||||
|
||||
# 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" --time
|
||||
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" --time
|
||||
ynh_exec_warn_less yunohost firewall disallow TCP $portUnicorn
|
||||
fi
|
||||
|
||||
|
@ -94,13 +94,13 @@ 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"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Removal of $app completed"
|
||||
ynh_script_progression --message="Removal of $app completed" --time --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..." --time
|
||||
|
||||
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..." --time
|
||||
|
||||
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..." --time
|
||||
|
||||
# Define and install dependencies
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
|
@ -64,28 +64,28 @@ ynh_install_app_dependencies $pkg_dependencies
|
|||
#=================================================
|
||||
# RESTORE CONF FILES
|
||||
#=================================================
|
||||
ynh_print_info "Restoring configuration files of Gitlab..."
|
||||
ynh_script_progression --message="Restoring configuration files of Gitlab..." --time
|
||||
|
||||
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..." --time
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -93,15 +93,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
|
||||
|
||||
#=================================================
|
||||
|
@ -109,9 +109,9 @@ fi
|
|||
#=================================================
|
||||
# RESTORE GITLAB DATABASE
|
||||
#=================================================
|
||||
ynh_print_info "Restoring Gitlab..."
|
||||
ynh_script_progression --message="Restoring Gitlab..." --time
|
||||
|
||||
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"
|
||||
|
||||
|
@ -134,14 +134,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..." --time
|
||||
|
||||
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..." --time
|
||||
|
||||
ynh_systemd_action --action=reload --service_name=nginx
|
||||
|
||||
|
@ -149,4 +149,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" --time --last
|
||||
|
|
111
scripts/upgrade
111
scripts/upgrade
|
@ -19,19 +19,19 @@ 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)
|
||||
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
|
@ -39,23 +39,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 +70,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 +89,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 +103,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 +112,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)..." --time
|
||||
|
||||
# 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,7 +169,7 @@ path_url=$(ynh_normalize_url_path $path_url)
|
|||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_print_info "Installing dependencies..."
|
||||
ynh_script_progression --message="Installing dependencies..." --time
|
||||
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
|
@ -177,24 +177,24 @@ ynh_install_app_dependencies $pkg_dependencies
|
|||
# PRECONFIGURE GITLAB
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Preconfigure gitlab..."
|
||||
ynh_script_progression --message="Preconfigure gitlab..." --time
|
||||
|
||||
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"
|
||||
|
@ -202,18 +202,18 @@ chown admin: "$config_path/gitlab-persistent.rb"
|
|||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_print_info "Setting up source files..."
|
||||
ynh_script_progression --message="Setting up source files..." --time
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -221,15 +221,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
|
||||
|
||||
#=================================================
|
||||
|
@ -239,7 +239,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..." --time
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config client_max_body_size
|
||||
fi
|
||||
|
@ -259,13 +259,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..." --time
|
||||
|
||||
# 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
|
||||
|
@ -273,7 +273,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..." --time
|
||||
|
||||
ynh_systemd_action --action=reload --service_name=nginx
|
||||
|
||||
|
@ -281,5 +281,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" --time --last
|
||||
|
|
Loading…
Reference in a new issue