yunohost-gitea_ynh/scripts/upgrade

121 lines
3.4 KiB
Plaintext
Raw Normal View History

2018-02-25 21:45:24 +01:00
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
source /usr/share/yunohost/helpers
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
# Load common variables and helpers
source ./experimental_helper.sh
source ./_common.sh
# Retrieve app settings
domain=$(ynh_app_setting_get "$app" domain)
path_url=$(ynh_normalize_url_path $(ynh_app_setting_get "$app" path))
dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
admin=$(ynh_app_setting_get "$app" adminusername)
key=$(ynh_app_setting_get "$app" secret_key)
is_public=$(ynh_app_setting_get "$app" is_public)
port=$(ynh_app_setting_get "$app" web_port)
# Backup the current version of the app
2019-02-22 21:48:50 +01:00
# Inform the backup/restore process that it should not save the data directory
ynh_app_setting_set $app backup_core_only 1
2018-02-25 21:45:24 +01:00
ynh_backup_before_upgrade
ynh_clean_setup () {
ynh_restore_upgradebackup
}
# Stop service
systemctl stop "$app".service
#=================================================
# MIGRATION FROM OLD VERSION
#=================================================
# Update settings is_public to new standard
if [ "$is_public" = "Yes" ]; then
ynh_app_setting_set $app is_public 1 # Fixe is_public en booléen
is_public=1
elif [ "$is_public" = "No" ]; then
ynh_app_setting_set $app is_public 0
is_public=0
fi
if [[ $port == "" ]]
then
port=$(ynh_find_port 6000)
ynh_app_setting_set $app web_port $port
fi
# handle upgrade from old package installation
2018-06-15 22:08:34 +02:00
# this test that /etc/gitea exist since this was used in the old package
2018-02-25 21:45:24 +01:00
# but not in the new
# this code will be removed in the future
2018-06-15 22:08:34 +02:00
if [ -d "/etc/gitea" ]
2018-02-25 21:45:24 +01:00
then
# create needed directories if not already created
create_dir
# move repositories to new dir
old_repo_path=$(ynh_app_setting_get "$app" repopath)
2018-06-15 22:08:34 +02:00
mv "${old_repo_path:-/home/yunohost.app/gitea}"/* "$REPO_PATH" || true # Avoid if the directory is empty
2018-02-25 21:45:24 +01:00
# cleanup old dir and conf
2018-06-15 22:08:34 +02:00
ynh_secure_remove /opt/gitea
ynh_secure_remove /etc/gitea
ynh_secure_remove /opt/gitea_src
2018-02-25 21:45:24 +01:00
# create needed directories if not already created
create_dir
fi
# end of old package upgrade
2018-06-15 22:08:34 +02:00
# test if user gitea is locked because of an old installation of the package.
2018-02-25 21:45:24 +01:00
# if it's blocked, unlock it to allow ssh usage with git
if [[ $(grep "$app" /etc/shadow | cut -d: -f2) == '!' ]]
then
usermod -p '*' "$app"
fi
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# Clean template to fix issue : https://github.com/gogits/gogs/issues/4585
2019-02-15 15:42:55 +01:00
ynh_secure_remove "/opt/$app/templates"
2018-02-25 21:45:24 +01:00
2018-06-15 22:08:34 +02:00
# Install gitea
2018-02-25 21:45:24 +01:00
ynh_setup_source $final_path $architecture
2018-06-15 22:08:34 +02:00
# Configure gitea with app.ini file
config_gitea
2018-02-25 21:45:24 +01:00
# Configure init script
ynh_add_systemd_config
# Modify Nginx configuration file and copy it to Nginx conf directory
config_nginx
#=================================================
# GENERIC FINALIZATION
#=================================================
# Set permissions
set_permission
# Unprotect root from SSO if public
set_access_settings
2018-02-25 21:45:24 +01:00
# Reload services
ynh_systemd_action -l "Serving \[::\]:$port with pid" -p "systemd"
2019-02-16 13:43:04 +01:00
sleep 1
# Store the checksum with the 'INTERNAL_TOKEN' value.
# Should be removed when the issue https://github.com/go-gitea/gitea/issues/3246 is fixed
ynh_store_file_checksum "$final_path/custom/conf/app.ini"