2021-08-15 21:48:06 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# LOAD SETTINGS
|
|
|
|
#=================================================
|
2022-03-14 20:35:57 +01:00
|
|
|
ynh_script_progression --message="Loading installation settings..."
|
2021-08-15 21:48:06 +02:00
|
|
|
|
2022-03-28 20:00:13 +02:00
|
|
|
app="$YNH_APP_INSTANCE_NAME"
|
2021-08-15 21:48:06 +02:00
|
|
|
|
2022-03-28 20:00:13 +02:00
|
|
|
final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
|
2022-03-14 23:21:15 +01:00
|
|
|
|
2022-12-17 22:03:18 +01:00
|
|
|
landing_page_user=$(ynh_app_setting_get --app="$app" --key=landing_page_user)
|
|
|
|
|
2022-03-28 20:00:13 +02:00
|
|
|
domain=$(ynh_app_setting_get --app="$app" --key=domain)
|
|
|
|
port=$(ynh_app_setting_get --app="$app" --key=port)
|
|
|
|
path_url=$(ynh_app_setting_get --app="$app" --key=path_url)
|
2022-03-14 23:21:15 +01:00
|
|
|
|
2022-03-28 20:00:13 +02:00
|
|
|
client_max_body_size=$(ynh_app_setting_get --app="$app" --key=client_max_body_size)
|
2022-03-26 00:21:52 +01:00
|
|
|
|
2022-03-28 20:00:13 +02:00
|
|
|
db_name=$(ynh_app_setting_get --app="$app" --key=db_name)
|
|
|
|
db_user=$(ynh_app_setting_get --app="$app" --key=db_user)
|
|
|
|
db_pwd=$(ynh_app_setting_get --app="$app" --key=db_pwd)
|
2022-03-14 23:21:15 +01:00
|
|
|
|
2022-03-28 20:00:13 +02:00
|
|
|
datadir=$(ynh_app_setting_get --app="$app" --key=datadir)
|
2022-03-26 00:43:51 +01:00
|
|
|
|
2023-08-15 21:19:26 +02:00
|
|
|
cache_memory_target=$(ynh_app_setting_get --app="$app" --key=cache_memory_target)
|
|
|
|
|
2022-07-04 21:00:07 +02:00
|
|
|
instance_expose_peers=$(ynh_app_setting_get --app="$app" --key=instance_expose_peers)
|
|
|
|
instance_expose_suspended=$(ynh_app_setting_get --app="$app" --key=instance_expose_suspended)
|
2023-02-21 16:09:29 +01:00
|
|
|
instance_expose_suspended_web=$(ynh_app_setting_get --app="$app" --key=instance_expose_suspended_web)
|
2022-12-17 22:03:18 +01:00
|
|
|
instance_expose_public_timeline=$(ynh_app_setting_get --app="$app" --key=instance_expose_public_timeline)
|
2022-09-28 17:27:53 +02:00
|
|
|
instance_deliver_to_shared_inboxes=$(ynh_app_setting_get --app="$app" --key=instance_deliver_to_shared_inboxes)
|
2023-08-15 21:19:26 +02:00
|
|
|
instance_inject_mastodon_version=$(ynh_app_setting_get --app="$app" --key=instance_inject_mastodon_version)
|
2022-07-04 21:00:07 +02:00
|
|
|
|
|
|
|
accounts_registration_open=$(ynh_app_setting_get --app="$app" --key=accounts_registration_open)
|
|
|
|
accounts_approval_required=$(ynh_app_setting_get --app="$app" --key=accounts_approval_required)
|
|
|
|
accounts_reason_required=$(ynh_app_setting_get --app="$app" --key=accounts_reason_required)
|
2022-09-28 17:27:53 +02:00
|
|
|
accounts_allow_custom_css=$(ynh_app_setting_get --app="$app" --key=accounts_allow_custom_css)
|
2023-07-14 18:10:35 +02:00
|
|
|
accounts_custom_css_length=$(ynh_app_setting_get --app="$app" --key=accounts_custom_css_length)
|
2022-03-14 23:21:15 +01:00
|
|
|
|
2022-03-28 20:00:13 +02:00
|
|
|
media_image_max_size=$(ynh_app_setting_get --app="$app" --key=media_image_max_size)
|
|
|
|
media_video_max_size=$(ynh_app_setting_get --app="$app" --key=media_video_max_size)
|
|
|
|
media_description_min_chars=$(ynh_app_setting_get --app="$app" --key=media_description_min_chars)
|
|
|
|
media_description_max_chars=$(ynh_app_setting_get --app="$app" --key=media_description_max_chars)
|
|
|
|
media_remote_cache_days=$(ynh_app_setting_get --app="$app" --key=media_remote_cache_days)
|
2022-09-28 17:27:53 +02:00
|
|
|
media_emoji_local_max_size=$(ynh_app_setting_get --app="$app" --key=media_emoji_local_max_size)
|
|
|
|
media_emoji_remote_max_size=$(ynh_app_setting_get --app="$app" --key=media_emoji_remote_max_size)
|
2022-03-26 00:43:51 +01:00
|
|
|
|
2022-12-17 22:03:18 +01:00
|
|
|
storage_backend=$(ynh_app_setting_get --app="$app" --key=storage_backend)
|
|
|
|
storage_s3_endpoint=$(ynh_app_setting_get --app="$app" --key=storage_s3_endpoint)
|
|
|
|
storage_s3_proxy=$(ynh_app_setting_get --app="$app" --key=storage_s3_proxy)
|
|
|
|
storage_s3_access_key=$(ynh_app_setting_get --app="$app" --key=storage_s3_access_key)
|
|
|
|
storage_s3_secret_key=$(ynh_app_setting_get --app="$app" --key=storage_s3_secret_key)
|
|
|
|
storage_s3_bucket=$(ynh_app_setting_get --app="$app" --key=storage_s3_bucket)
|
|
|
|
|
2022-03-28 20:00:13 +02:00
|
|
|
statuses_max_chars=$(ynh_app_setting_get --app="$app" --key=statuses_max_chars)
|
|
|
|
statuses_cw_max_chars=$(ynh_app_setting_get --app="$app" --key=statuses_cw_max_chars)
|
|
|
|
statuses_poll_max_options=$(ynh_app_setting_get --app="$app" --key=statuses_poll_max_options)
|
|
|
|
statuses_poll_option_max_chars=$(ynh_app_setting_get --app="$app" --key=statuses_poll_option_max_chars)
|
|
|
|
statuses_media_max_files=$(ynh_app_setting_get --app="$app" --key=statuses_media_max_files)
|
2021-08-15 21:48:06 +02:00
|
|
|
|
2023-04-10 21:06:14 +02:00
|
|
|
smtp_host=$(ynh_app_setting_get --app="$app" --key=smtp_host)
|
|
|
|
smtp_port=$(ynh_app_setting_get --app="$app" --key=smtp_port)
|
|
|
|
smtp_username=$(ynh_app_setting_get --app="$app" --key=smtp_username)
|
|
|
|
smtp_password=$(ynh_app_setting_get --app="$app" --key=smtp_password)
|
|
|
|
smtp_from=$(ynh_app_setting_get --app="$app" --key=smtp_from)
|
|
|
|
smtp_disclose_recipients=$(ynh_app_setting_get --app="$app" --key=smtp_disclose_recipients)
|
|
|
|
|
2022-12-17 22:03:18 +01:00
|
|
|
advanced_cookies_samesite=$(ynh_app_setting_get --app="$app" --key=advanced_cookies_samesite)
|
|
|
|
advanced_rate_limit_requests=$(ynh_app_setting_get --app="$app" --key=advanced_rate_limit_requests)
|
|
|
|
|
2021-08-15 21:48:06 +02:00
|
|
|
#=================================================
|
|
|
|
# CHECK VERSION
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
### This helper will compare the version of the currently installed app and the version of the upstream package.
|
|
|
|
### $upgrade_type can have 2 different values
|
|
|
|
### - UPGRADE_APP if the upstream app version has changed
|
|
|
|
### - UPGRADE_PACKAGE if only the YunoHost package has changed
|
|
|
|
### ynh_check_app_version_changed will stop the upgrade if the app is up to date.
|
|
|
|
### UPGRADE_APP should be used to upgrade the core app only if there's an upgrade to do.
|
|
|
|
upgrade_type=$(ynh_check_app_version_changed)
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
|
|
|
#=================================================
|
2022-03-14 20:35:57 +01:00
|
|
|
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
|
2021-08-15 21:48:06 +02:00
|
|
|
|
|
|
|
# Backup the current version of the app
|
|
|
|
ynh_backup_before_upgrade
|
|
|
|
ynh_clean_setup () {
|
|
|
|
# Restore it if the upgrade fails
|
|
|
|
ynh_restore_upgradebackup
|
|
|
|
}
|
|
|
|
# Exit if an error occurs during the execution of the script
|
|
|
|
ynh_abort_if_errors
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STANDARD UPGRADE STEPS
|
|
|
|
#=================================================
|
|
|
|
# STOP SYSTEMD SERVICE
|
|
|
|
#=================================================
|
2022-03-14 20:35:57 +01:00
|
|
|
ynh_script_progression --message="Stopping a systemd service..."
|
2021-08-15 21:48:06 +02:00
|
|
|
|
2022-03-28 20:00:13 +02:00
|
|
|
ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log"
|
2021-08-15 21:48:06 +02:00
|
|
|
|
2022-03-26 00:21:52 +01:00
|
|
|
#=================================================
|
|
|
|
# ENSURE DOWNWARD COMPATIBILITY
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Ensuring downward compatibility..."
|
|
|
|
|
|
|
|
# Upgrade from <0.2.1~ynh4:
|
2022-05-14 20:48:11 +02:00
|
|
|
if ynh_compare_current_package_version --comparison lt --version 0.2.1~ynh4 || [ -z "$db_user" ]
|
2022-03-26 03:39:36 +01:00
|
|
|
then
|
2022-07-04 21:00:07 +02:00
|
|
|
# import old parameters
|
|
|
|
registration_open=$(ynh_app_setting_get --app="$app" --key=registration_open)
|
|
|
|
registration_approval=$(ynh_app_setting_get --app="$app" --key=registration_approval)
|
|
|
|
registration_reason=$(ynh_app_setting_get --app="$app" --key=registration_reason)
|
2022-03-26 03:39:36 +01:00
|
|
|
# declaration of new parameters
|
2022-03-27 22:46:21 +02:00
|
|
|
client_max_body_size="100M"
|
2022-03-26 04:56:16 +01:00
|
|
|
media_image_max_size="2097152"
|
|
|
|
media_video_max_size="10485760"
|
|
|
|
media_description_min_chars="0"
|
|
|
|
media_description_max_chars="500"
|
|
|
|
media_remote_cache_days="30"
|
|
|
|
statuses_max_chars="5000"
|
|
|
|
statuses_cw_max_chars="100"
|
|
|
|
statuses_poll_max_options="6"
|
|
|
|
statuses_poll_option_max_chars="50"
|
|
|
|
statuses_media_max_files="6"
|
2022-03-27 21:58:43 +02:00
|
|
|
# conversion of old parameters
|
2022-03-26 04:56:16 +01:00
|
|
|
registration_open=$(convert_bool "$registration_open")
|
|
|
|
registration_approval=$(convert_bool "$registration_approval")
|
|
|
|
registration_reason=$(convert_bool "$registration_reason")
|
2022-03-28 19:50:19 +02:00
|
|
|
# fix db_user existence
|
|
|
|
db_user=$db_name
|
2022-05-14 20:48:11 +02:00
|
|
|
ynh_app_setting_set --app="$app" --key=db_user --value="$db_user"
|
2022-03-26 03:39:36 +01:00
|
|
|
# registration of new parameters
|
2022-03-28 20:00:13 +02:00
|
|
|
ynh_app_setting_set --app="$app" --key=client_max_body_size --value="$client_max_body_size"
|
|
|
|
ynh_app_setting_set --app="$app" --key=media_image_max_size --value="$media_image_max_size"
|
|
|
|
ynh_app_setting_set --app="$app" --key=media_video_max_size --value="$media_video_max_size"
|
|
|
|
ynh_app_setting_set --app="$app" --key=media_description_min_chars --value="$media_description_min_chars"
|
|
|
|
ynh_app_setting_set --app="$app" --key=media_description_max_chars --value="$media_description_max_chars"
|
|
|
|
ynh_app_setting_set --app="$app" --key=media_remote_cache_days --value="$media_remote_cache_days"
|
|
|
|
ynh_app_setting_set --app="$app" --key=statuses_max_chars --value="$statuses_max_chars"
|
|
|
|
ynh_app_setting_set --app="$app" --key=statuses_cw_max_chars --value="$statuses_cw_max_chars"
|
|
|
|
ynh_app_setting_set --app="$app" --key=statuses_poll_max_options --value="$statuses_poll_max_options"
|
|
|
|
ynh_app_setting_set --app="$app" --key=statuses_poll_option_max_chars --value="$statuses_poll_option_max_chars"
|
|
|
|
ynh_app_setting_set --app="$app" --key=statuses_media_max_files --value="$statuses_media_max_files"
|
2022-03-26 04:56:16 +01:00
|
|
|
# registration of converted parameters
|
2022-07-04 21:00:07 +02:00
|
|
|
ynh_app_setting_set --app="$app" --key=registration_open --value="$registration_open"
|
|
|
|
ynh_app_setting_set --app="$app" --key=registration_approval --value="$registration_approval"
|
|
|
|
ynh_app_setting_set --app="$app" --key=registration_reason --value="$registration_reason"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Upgrade from <0.3.7~ynh1:
|
|
|
|
if ynh_compare_current_package_version --comparison lt --version 0.3.7~ynh1 || [ -z "$instance_expose_peers" ]
|
|
|
|
then
|
|
|
|
# import old parameters
|
|
|
|
registration_open=$(ynh_app_setting_get --app="$app" --key=registration_open)
|
|
|
|
registration_approval=$(ynh_app_setting_get --app="$app" --key=registration_approval)
|
|
|
|
registration_reason=$(ynh_app_setting_get --app="$app" --key=registration_reason)
|
|
|
|
# declaration of new parameters
|
|
|
|
instance_expose_peers="false"
|
|
|
|
instance_expose_suspended="false"
|
|
|
|
# conversion of old parameters
|
|
|
|
if [ "$registration_open" = "true" ] || [ "$registration_open" = "false" ]; then
|
|
|
|
accounts_registration_open=$registration_open
|
|
|
|
accounts_approval_required=$registration_approval
|
|
|
|
accounts_reason_required=$registration_reason
|
|
|
|
else
|
|
|
|
accounts_registration_open="false"
|
|
|
|
accounts_approval_required="true"
|
|
|
|
accounts_reason_required="false"
|
|
|
|
fi
|
|
|
|
# registration of new parameters
|
|
|
|
ynh_app_setting_set --app="$app" --key=instance_expose_peers --value="$instance_expose_peers"
|
|
|
|
ynh_app_setting_set --app="$app" --key=instance_expose_suspended --value="$instance_expose_suspended"
|
|
|
|
# registration of converted parameters
|
|
|
|
ynh_app_setting_set --app="$app" --key=accounts_registration_open --value="$accounts_registration_open"
|
|
|
|
ynh_app_setting_set --app="$app" --key=accounts_approval_required --value="$accounts_approval_required"
|
|
|
|
ynh_app_setting_set --app="$app" --key=accounts_reason_required --value="$accounts_reason_required"
|
|
|
|
# deletion of old parameters
|
|
|
|
ynh_app_setting_delete --app="$app" --key=registration_open
|
|
|
|
ynh_app_setting_delete --app="$app" --key=registration_approval
|
|
|
|
ynh_app_setting_delete --app="$app" --key=registration_reason
|
2022-03-26 00:43:51 +01:00
|
|
|
fi
|
2022-09-28 16:39:10 +02:00
|
|
|
|
|
|
|
# Upgrade from <0.5.0~ynh1:
|
|
|
|
if ynh_compare_current_package_version --comparison lt --version 0.5.0~ynh1 || [ -z "$accounts_allow_custom_css" ]
|
|
|
|
then
|
|
|
|
# declaration of new parameters
|
|
|
|
accounts_allow_custom_css="false"
|
|
|
|
instance_deliver_to_shared_inboxes="true"
|
|
|
|
media_emoji_local_max_size="51200"
|
|
|
|
media_emoji_remote_max_size="102400"
|
|
|
|
# registration of new parameters
|
|
|
|
ynh_app_setting_set --app="$app" --key=accounts_allow_custom_css --value="$accounts_allow_custom_css"
|
|
|
|
ynh_app_setting_set --app="$app" --key=instance_deliver_to_shared_inboxes --value="$instance_deliver_to_shared_inboxes"
|
|
|
|
ynh_app_setting_set --app="$app" --key=media_emoji_local_max_size --value="$media_emoji_local_max_size"
|
|
|
|
ynh_app_setting_set --app="$app" --key=media_emoji_remote_max_size --value="$media_emoji_remote_max_size"
|
|
|
|
fi
|
2022-12-17 22:03:18 +01:00
|
|
|
|
|
|
|
# Upgrade from <0.6.0~ynh1:
|
|
|
|
if ynh_compare_current_package_version --comparison lt --version 0.6.0~ynh1 || [ -z "$instance_expose_public_timeline" ]
|
|
|
|
then
|
|
|
|
# declaration of new parameters
|
|
|
|
landing_page_user=""
|
|
|
|
instance_expose_public_timeline="false"
|
|
|
|
storage_backend="local"
|
|
|
|
storage_s3_endpoint=""
|
|
|
|
storage_s3_proxy="false"
|
|
|
|
storage_s3_access_key=""
|
|
|
|
storage_s3_secret_key=""
|
|
|
|
storage_s3_bucket=""
|
|
|
|
advanced_cookies_samesite="lax"
|
|
|
|
advanced_rate_limit_requests="1000"
|
|
|
|
# registration of new parameters
|
|
|
|
ynh_app_setting_set --app="$app" --key=landing_page_user --value="$landing_page_user"
|
|
|
|
ynh_app_setting_set --app="$app" --key=instance_expose_public_timeline --value="$instance_expose_public_timeline"
|
|
|
|
ynh_app_setting_set --app="$app" --key=storage_backend --value="$storage_backend"
|
|
|
|
ynh_app_setting_set --app="$app" --key=storage_s3_endpoint --value="$storage_s3_endpoint"
|
|
|
|
ynh_app_setting_set --app="$app" --key=storage_s3_proxy --value="$storage_s3_proxy"
|
|
|
|
ynh_app_setting_set --app="$app" --key=storage_s3_access_key --value="$storage_s3_access_key"
|
|
|
|
ynh_app_setting_set --app="$app" --key=storage_s3_secret_key --value="$storage_s3_secret_key"
|
|
|
|
ynh_app_setting_set --app="$app" --key=storage_s3_bucket --value="$storage_s3_bucket"
|
|
|
|
ynh_app_setting_set --app="$app" --key=advanced_cookies_samesite --value="$advanced_cookies_samesite"
|
|
|
|
ynh_app_setting_set --app="$app" --key=advanced_rate_limit_requests --value="$advanced_rate_limit_requests"
|
|
|
|
fi
|
2023-02-18 18:35:16 +01:00
|
|
|
|
|
|
|
# Upgrade from <0.7.1~ynh1:
|
|
|
|
if ynh_compare_current_package_version --comparison lt --version 0.7.1~ynh1 || [ -z "$instance_expose_suspended_web" ]
|
|
|
|
then
|
|
|
|
# updating parameters
|
|
|
|
advanced_rate_limit_requests="300"
|
|
|
|
# declaration of new parameter
|
|
|
|
instance_expose_suspended_web="false"
|
|
|
|
# registration of parameters
|
|
|
|
ynh_app_setting_set --app="$app" --key=advanced_rate_limit_requests --value="$advanced_rate_limit_requests"
|
|
|
|
ynh_app_setting_set --app="$app" --key=instance_expose_suspended_web --value="$instance_expose_suspended_web"
|
|
|
|
fi
|
2022-03-26 00:21:52 +01:00
|
|
|
|
2023-04-10 21:06:14 +02:00
|
|
|
# Upgrade from <0.8.0~ynh2:
|
|
|
|
if ynh_compare_current_package_version --comparison lt --version 0.8.0~ynh2 || [ -z "$smtp_host" ]
|
|
|
|
then
|
|
|
|
# declaration of new parameter
|
|
|
|
smtp_host="localhost"
|
|
|
|
smtp_port="25"
|
|
|
|
smtp_username=""
|
|
|
|
smtp_password=""
|
2023-04-10 21:19:04 +02:00
|
|
|
smtp_from="noreply@$domain"
|
2023-04-10 21:06:14 +02:00
|
|
|
smtp_disclose_recipients="false"
|
|
|
|
# registration of parameters
|
|
|
|
ynh_app_setting_set --app="$app" --key=smtp_host --value="$smtp_host"
|
|
|
|
ynh_app_setting_set --app="$app" --key=smtp_port --value="$smtp_port"
|
|
|
|
ynh_app_setting_set --app="$app" --key=smtp_username --value="$smtp_username"
|
|
|
|
ynh_app_setting_set --app="$app" --key=smtp_password --value="$smtp_password"
|
|
|
|
ynh_app_setting_set --app="$app" --key=smtp_from --value="$smtp_from"
|
|
|
|
ynh_app_setting_set --app="$app" --key=smtp_disclose_recipients --value="$smtp_disclose_recipients"
|
|
|
|
fi
|
|
|
|
|
2023-04-11 15:33:58 +02:00
|
|
|
# Upgrade from <0.8.0~ynh3:
|
|
|
|
if ynh_compare_current_package_version --comparison lt --version 0.8.0~ynh3
|
|
|
|
then
|
2023-04-12 16:56:11 +02:00
|
|
|
# get settings from problem key
|
|
|
|
allow_custom_css=$(ynh_app_setting_get --app="$app" --key=allow_custom_css)
|
|
|
|
approval_required=$(ynh_app_setting_get --app="$app" --key=approval_required)
|
|
|
|
reason_required=$(ynh_app_setting_get --app="$app" --key=reason_required)
|
|
|
|
registration_open=$(ynh_app_setting_get --app="$app" --key=registration_open)
|
|
|
|
# apply setting to correct key if set on old key
|
|
|
|
if [ -n "$allow_custom_css" ]
|
|
|
|
then
|
|
|
|
ynh_app_setting_set --app="$app" --key=accounts_allow_custom_css --value="$allow_custom_css"
|
|
|
|
ynh_app_setting_delete --app="$app" --key=allow_custom_css
|
|
|
|
fi
|
|
|
|
if [ -n "$approval_required" ]
|
|
|
|
then
|
|
|
|
ynh_app_setting_set --app="$app" --key=accounts_approval_required --value="$approval_required"
|
|
|
|
ynh_app_setting_delete --app="$app" --key=approval_required
|
|
|
|
fi
|
|
|
|
if [ -n "$reason_required" ]
|
|
|
|
then
|
|
|
|
ynh_app_setting_set --app="$app" --key=accounts_reason_required --value="$reason_required"
|
|
|
|
ynh_app_setting_delete --app="$app" --key=reason_required
|
|
|
|
fi
|
|
|
|
if [ -n "$registration_open" ]
|
|
|
|
then
|
|
|
|
ynh_app_setting_set --app="$app" --key=accounts_registration_open --value="$registration_open"
|
|
|
|
ynh_app_setting_delete --app="$app" --key=registration_open
|
|
|
|
fi
|
2023-04-11 17:29:22 +02:00
|
|
|
fi
|
2023-04-11 15:33:58 +02:00
|
|
|
|
2023-07-14 18:10:35 +02:00
|
|
|
# Upgrade from <0.10.0~ynh1:
|
|
|
|
if ynh_compare_current_package_version --comparison lt --version 0.10.0~ynh1 || [ -z "$accounts_custom_css_length" ]
|
|
|
|
then
|
|
|
|
# declaration of new parameter
|
|
|
|
accounts_custom_css_length="10000"
|
|
|
|
# registration of parameter
|
|
|
|
ynh_app_setting_set --app="$app" --key=accounts_custom_css_length --value="$accounts_custom_css_length"
|
|
|
|
fi
|
|
|
|
|
2023-08-15 20:29:04 +02:00
|
|
|
# Upgrade from <0.11.0~ynh1:
|
|
|
|
if ynh_compare_current_package_version --comparison lt --version 0.11.0~ynh1 || [ -z "$cache_memory_target" ]
|
|
|
|
then
|
|
|
|
# declaration of new parameter
|
|
|
|
cache_memory_target="100MiB"
|
|
|
|
instance_inject_mastodon_version="false"
|
|
|
|
# update default config
|
|
|
|
if [ "$media_remote_cache_days" == "30" ]; then
|
2023-08-15 20:32:46 +02:00
|
|
|
# "30" is the old default value, "7" the new one
|
|
|
|
# updating to the new default only if the old default value is used (to not overwrite an user modified value)
|
2023-08-15 20:29:04 +02:00
|
|
|
media_remote_cache_days="7"
|
|
|
|
ynh_app_setting_set --app="$app" --key=media_remote_cache_days --value="$media_remote_cache_days"
|
|
|
|
fi
|
|
|
|
# registration of parameter
|
|
|
|
ynh_app_setting_set --app="$app" --key=cache_memory_target --value="$cache_memory_target"
|
|
|
|
ynh_app_setting_set --app="$app" --key=instance_inject_mastodon_version --value="$instance_inject_mastodon_version"
|
|
|
|
fi
|
|
|
|
|
2021-08-15 21:48:06 +02:00
|
|
|
#=================================================
|
|
|
|
# CREATE DEDICATED USER
|
|
|
|
#=================================================
|
2022-03-14 20:35:57 +01:00
|
|
|
ynh_script_progression --message="Making sure dedicated system user exists..."
|
2021-08-15 21:48:06 +02:00
|
|
|
|
|
|
|
# Create a dedicated user (if not existing)
|
2022-03-28 20:00:13 +02:00
|
|
|
ynh_system_user_create --username="$app" --home_dir="$final_path"
|
2021-08-15 21:48:06 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
|
|
|
|
2023-09-02 19:41:15 +02:00
|
|
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
2021-08-15 21:48:06 +02:00
|
|
|
then
|
2023-09-02 19:41:15 +02:00
|
|
|
ynh_script_progression --message="Upgrading source files..."
|
2021-08-15 21:48:06 +02:00
|
|
|
|
2023-09-02 19:41:15 +02:00
|
|
|
# detect_arch comes from _common.sh / personnal helpers
|
|
|
|
architecture=$(detect_arch)
|
|
|
|
|
2021-08-15 21:48:06 +02:00
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
2022-03-28 20:00:13 +02:00
|
|
|
ynh_setup_source --dest_dir="$final_path" --source_id="$architecture" --keep="config.yaml"
|
2021-08-15 21:48:06 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# FIXME: this should be managed by the core in the future
|
|
|
|
# Here, as a packager, you may have to tweak the ownerhsip/permissions
|
|
|
|
# such that the appropriate users (e.g. maybe www-data) can access
|
|
|
|
# files in some cases.
|
|
|
|
# But FOR THE LOVE OF GOD, do not allow r/x for "others" on the entire folder -
|
|
|
|
# this will be treated as a security issue.
|
|
|
|
chmod 750 "$final_path"
|
|
|
|
chmod -R o-rwx "$final_path"
|
2022-03-28 20:00:13 +02:00
|
|
|
chown -R "$app:www-data" "$final_path"
|
2021-08-15 21:48:06 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# NGINX CONFIGURATION
|
|
|
|
#=================================================
|
2022-03-14 20:35:57 +01:00
|
|
|
ynh_script_progression --message="Upgrading NGINX web server configuration..."
|
2021-08-15 21:48:06 +02:00
|
|
|
|
2023-02-18 22:26:39 +01:00
|
|
|
# Create a dedicated NGINX config for the main domain
|
2021-08-15 21:48:06 +02:00
|
|
|
ynh_add_nginx_config
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# UPGRADE DEPENDENCIES
|
|
|
|
#=================================================
|
2022-03-14 20:35:57 +01:00
|
|
|
ynh_script_progression --message="Upgrading dependencies..."
|
2021-08-15 21:48:06 +02:00
|
|
|
|
2022-05-13 16:23:01 +02:00
|
|
|
ynh_exec_warn_less ynh_install_app_dependencies "$pkg_dependencies"
|
2021-08-15 21:48:06 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# UPDATE A CONFIG FILE
|
|
|
|
#=================================================
|
2022-03-14 20:35:57 +01:00
|
|
|
ynh_script_progression --message="Updating a configuration file..."
|
2021-08-15 21:48:06 +02:00
|
|
|
|
|
|
|
### Same as during install
|
|
|
|
###
|
|
|
|
### The file will automatically be backed-up if it's found to be manually modified (because
|
|
|
|
### ynh_add_config keeps track of the file's checksum)
|
|
|
|
|
2022-03-14 19:54:17 +01:00
|
|
|
ynh_add_config --template="config.yaml" --destination="$final_path/config.yaml"
|
2021-08-15 21:48:06 +02:00
|
|
|
|
|
|
|
# FIXME: this should be handled by the core in the future
|
|
|
|
# You may need to use chmod 600 instead of 400,
|
|
|
|
# for example if the app is expected to be able to modify its own config
|
2022-03-14 19:54:17 +01:00
|
|
|
chmod 400 "$final_path/config.yaml"
|
2022-03-28 20:00:13 +02:00
|
|
|
chown "$app:$app" "$final_path/config.yaml"
|
2021-08-15 21:48:06 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SETUP SYSTEMD
|
|
|
|
#=================================================
|
2022-03-14 20:35:57 +01:00
|
|
|
ynh_script_progression --message="Upgrading systemd configuration..."
|
2021-08-15 21:48:06 +02:00
|
|
|
|
|
|
|
# Create a dedicated systemd config
|
|
|
|
ynh_add_systemd_config
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALIZATION
|
|
|
|
#=================================================
|
|
|
|
# SETUP LOGROTATE
|
|
|
|
#=================================================
|
2022-03-14 20:35:57 +01:00
|
|
|
ynh_script_progression --message="Upgrading logrotate configuration..."
|
2021-08-15 21:48:06 +02:00
|
|
|
|
|
|
|
# Use logrotate to manage app-specific logfile(s)
|
|
|
|
ynh_use_logrotate --non-append
|
|
|
|
|
2023-09-10 22:07:43 +02:00
|
|
|
#=================================================
|
|
|
|
# SETUP FAIL2BAN
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Create a dedicated Fail2Ban config
|
|
|
|
ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login"
|
|
|
|
|
2021-08-15 21:48:06 +02:00
|
|
|
#=================================================
|
|
|
|
# INTEGRATE SERVICE IN YUNOHOST
|
|
|
|
#=================================================
|
2022-03-14 20:35:57 +01:00
|
|
|
ynh_script_progression --message="Integrating service in YunoHost..."
|
2021-08-15 21:48:06 +02:00
|
|
|
|
2022-03-28 20:00:13 +02:00
|
|
|
yunohost service add "$app" --description="Gotosocial server" --log="/var/log/$app/$app.log"
|
2021-08-15 21:48:06 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# START SYSTEMD SERVICE
|
|
|
|
#=================================================
|
2022-03-14 20:35:57 +01:00
|
|
|
ynh_script_progression --message="Starting a systemd service..."
|
2021-08-15 21:48:06 +02:00
|
|
|
|
2022-03-28 20:00:13 +02:00
|
|
|
ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log"
|
2021-08-15 21:48:06 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RELOAD NGINX
|
|
|
|
#=================================================
|
2022-03-14 20:35:57 +01:00
|
|
|
ynh_script_progression --message="Reloading NGINX web server..."
|
2021-08-15 21:48:06 +02:00
|
|
|
|
|
|
|
ynh_systemd_action --service_name=nginx --action=reload
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2022-03-14 20:35:57 +01:00
|
|
|
ynh_script_progression --message="Upgrade of $app completed"
|