diff --git a/conf/app.ini b/conf/app.ini index 542ab68..f7303e6 100644 --- a/conf/app.ini +++ b/conf/app.ini @@ -27,6 +27,8 @@ SSH_PORT = __SSH_PORT__ OFFLINE_MODE = false APP_DATA_PATH = __DATA_PATH__ LANDING_PAGE = explore +LFS_START_SERVER = true +LFS_JWT_SECRET = __LFS_KEY__ [mailer] ENABLED = true diff --git a/scripts/change_url b/scripts/change_url index ed4dfc4..46a03f3 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -25,6 +25,7 @@ app=$YNH_APP_INSTANCE_NAME db_password=$(ynh_app_setting_get --app $app --key mysqlpwd) admin=$(ynh_app_setting_get --app $app --key adminusername) key=$(ynh_app_setting_get --app $app --key secret_key) +lfs_key=$(ynh_app_setting_get --app $app --key lfs_key) port=$(ynh_app_setting_get --app $app --key web_port) upstream_version=$(ynh_app_setting_get $app upstream_version) diff --git a/scripts/install b/scripts/install index d748789..bc590ae 100644 --- a/scripts/install +++ b/scripts/install @@ -43,6 +43,7 @@ fi ynh_script_progression --message="Defining db password and key..." db_password=$(ynh_string_random) key=$(ynh_string_random) +lfs_key=$(ynh_string_random) # Find available ports port=$(ynh_find_port --port 6000) @@ -52,6 +53,7 @@ ynh_script_progression --message="Storing installation settings..." ynh_app_setting_set --app $app --key mysqlpwd --value $db_password ynh_app_setting_set --app $app --key adminusername --value $admin ynh_app_setting_set --app $app --key secret_key --value $key +ynh_app_setting_set --app $app --key lfs_key --value $lfs_key ynh_app_setting_set --app $app --key web_port --value $port #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 2e62897..0dd6f73 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -11,28 +11,33 @@ source ./_common.sh # IMPORT GENERIC HELPERS source /usr/share/yunohost/helpers -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -# Retrieve app settings +#================================================= +# LOAD SETTINGS +#================================================= ynh_script_progression --message="Loading installation settings..." -domain=$(ynh_app_setting_get --app $app --key domain) + +domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_normalize_url_path --path_url $(ynh_app_setting_get --app $app --key path)) -db_password=$(ynh_app_setting_get --app $app --key mysqlpwd) -admin=$(ynh_app_setting_get --app $app --key adminusername) -key=$(ynh_app_setting_get --app $app --key secret_key) -port=$(ynh_app_setting_get --app $app --key web_port) -upstream_version=$(ynh_app_setting_get --app $app --key upstream_version) +db_password=$(ynh_app_setting_get --app=$app --key=mysqlpwd) +admin=$(ynh_app_setting_get --app=$app --key=adminusername) +key=$(ynh_app_setting_get --app=$app --key=secret_key) +lfs_key=$(ynh_app_setting_get --app=$app --key=lfs_key) +port=$(ynh_app_setting_get --app=$app --key=web_port) +upstream_version=$(ynh_app_setting_get --app=$app --key=upstream_version) + +#================================================= +# STOP SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Stopping a systemd service..." --weight=1 + +# We stop the service before to set ynh_clean_setup +ynh_systemd_action --service_name=$app --action="stop" #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=10 +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." -# We stop the service before to set ynh_clean_setup -ynh_systemd_action --service_name=$app.service --action=stop - -# Backup the current version of the app if [ "0$(ynh_app_setting_get --app=$app --key=disable_backup_before_upgrade)" -ne 1 ] then ynh_backup_before_upgrade @@ -43,6 +48,20 @@ then } fi +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# ENSURE DOWNWARD COMPATIBILITY +#================================================= +ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 + +# If lfs_key doesn't exist, create it +if [ -z "$lfs_key" ]; then + lfs_key=$(ynh_string_random) + ynh_app_setting_set --app=$app --key=lfs_key --value=$lfs_key +fi + #================================================= # MIGRATION FROM GOGS #================================================= @@ -96,7 +115,6 @@ fi #================================================= # STANDARD UPGRADE STEPS #================================================= - ynh_script_progression --message="Configuring application..." # Clean template to fix issue : https://github.com/gogits/gogs/issues/4585