mirror of
https://github.com/YunoHost-Apps/pleroma_ynh.git
synced 2024-09-03 20:15:59 +02:00
Merge 5a59dcaccb
into 0ac519991e
This commit is contained in:
commit
063d2fd1af
8 changed files with 133 additions and 189 deletions
|
@ -21,6 +21,7 @@ fund = "https://liberapay.com/Pleroma-euro/"
|
|||
|
||||
[integration]
|
||||
yunohost = ">=11.2"
|
||||
helpers_version = "2.1"
|
||||
architectures = ["amd64", "armhf", "arm64"]
|
||||
multi_instance = false
|
||||
ldap = true
|
||||
|
|
|
@ -1,22 +1,10 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# COMMON VARIABLES
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# PERSONAL HELPERS
|
||||
# COMMON VARIABLES AND CUSTOM HELPERS
|
||||
#=================================================
|
||||
|
||||
boolstr() {
|
||||
bool=("false" "true")
|
||||
echo "${bool[$1]}"
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# EXPERIMENTAL HELPERS
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# FUTURE OFFICIAL HELPERS
|
||||
#=================================================
|
||||
|
|
|
@ -1,52 +1,43 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||
source ../settings/scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||
#=================================================
|
||||
ynh_print_info --message="Declaring files to be backed up..."
|
||||
ynh_print_info "Declaring files to be backed up..."
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE APP MAIN DIR
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="$install_dir"
|
||||
ynh_backup "$install_dir"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE DATA DIR
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="$data_dir" --is_big
|
||||
ynh_backup "$data_dir"
|
||||
|
||||
#=================================================
|
||||
# SYSTEM CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
ynh_backup --src_path="/etc/nginx/conf.d/$app-cache.conf" --not_mandatory
|
||||
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
ynh_backup "/etc/nginx/conf.d/$app-cache.conf" || true
|
||||
|
||||
ynh_backup --src_path="/etc/systemd/system/$app.service"
|
||||
ynh_backup "/etc/systemd/system/$app.service"
|
||||
|
||||
ynh_backup --src_path="/etc/$app/"
|
||||
ynh_backup "/etc/$app/"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE POSTGRESQL DATABASE
|
||||
#=================================================
|
||||
ynh_print_info --message="Backing up the PostgreSQL database..."
|
||||
ynh_print_info "Backing up the PostgreSQL database..."
|
||||
|
||||
ynh_psql_dump_db --database="$db_name" > db.sql
|
||||
ynh_psql_dump_db > db.sql
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
||||
ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
||||
|
|
|
@ -1,55 +1,45 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC STARTING
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
# STOP SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping a systemd service..." --weight=1
|
||||
ynh_script_progression "Stopping $app's systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd --line_match="Stopped $app"
|
||||
ynh_systemctl --service=$app --action="stop" --log_path=systemd --wait_until="Stopped $app"
|
||||
|
||||
pkill -u "$app" || true
|
||||
|
||||
#=================================================
|
||||
# MODIFY URL IN NGINX CONF
|
||||
#=================================================
|
||||
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1
|
||||
ynh_script_progression "Updating NGINX web server configuration..."
|
||||
|
||||
ynh_change_url_nginx_config
|
||||
ynh_config_change_url_nginx
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC MODIFICATIONS
|
||||
#=================================================
|
||||
# MODIFY A CONFIG FILE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Modifying a config file..." --weight=1
|
||||
ynh_script_progression "Updating configuration..."
|
||||
|
||||
config="/etc/$app/config.exs"
|
||||
ynh_backup_if_checksum_is_different --file="$config"
|
||||
ynh_replace_string --match_string="$old_domain" --replace_string="$new_domain" --target_file="$config"
|
||||
ynh_store_file_checksum --file="$config"
|
||||
ynh_backup_if_checksum_is_different "$config"
|
||||
ynh_replace --match="$old_domain" --replace="$new_domain" --file="$config"
|
||||
ynh_store_file_checksum "$config"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALISATION
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||
ynh_script_progression "Starting $app's systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name="$app" --action="start" --log_path=systemd --line_match="Access Pleroma.Web.Endpoint"
|
||||
ynh_systemctl --service="$app" --action="start" --log_path=systemd --wait_until="Access Pleroma.Web.Endpoint"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Change of URL completed for $app" --last
|
||||
ynh_script_progression "Change of URL completed for $app"
|
||||
|
|
|
@ -1,11 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
|
@ -15,14 +9,14 @@ source /usr/share/yunohost/helpers
|
|||
|
||||
path="/"
|
||||
random_key=$(ynh_string_random --length=64)
|
||||
ynh_app_setting_set --app="$app" --key=random_key --value="$random_key"
|
||||
ynh_app_setting_set --key=random_key --value="$random_key"
|
||||
signing_salt=$(ynh_string_random --length=8)
|
||||
ynh_app_setting_set --app="$app" --key=signing_salt --value="$signing_salt"
|
||||
ynh_app_setting_set --key=signing_salt --value="$signing_salt"
|
||||
admin_email=$(ynh_user_get_info --username="$admin" --key="mail")
|
||||
ynh_app_setting_set --app="$app" --key=admin_email --value="$admin_email"
|
||||
ynh_app_setting_set --key=admin_email --value="$admin_email"
|
||||
|
||||
## Bypass package_checker name not compatible with pleroma
|
||||
if [ "${PACKAGE_CHECK_EXEC:-0}" -eq 1 ]; then
|
||||
if ynh_in_ci_tests; then
|
||||
admin="test"
|
||||
fi
|
||||
|
||||
|
@ -31,50 +25,52 @@ fi
|
|||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setting up source files..." --weight=1
|
||||
ynh_script_progression "Setting up source files..."
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from manifest.toml
|
||||
ynh_setup_source --dest_dir="$install_dir/live"
|
||||
|
||||
chown -R "$app:www-data" "$install_dir"
|
||||
|
||||
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:www-data" "$install_dir"
|
||||
#=================================================
|
||||
# UPDATE THE POSTGRESQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring the PostgreSQL database..." --weight=1
|
||||
ynh_script_progression "Configuring the PostgreSQL database..."
|
||||
|
||||
ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS unaccent;" --database="$db_name"
|
||||
ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pg_trgm;" --database="$db_name"
|
||||
ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS citext;" --database="$db_name"
|
||||
ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\";" --database="$db_name"
|
||||
ynh_psql_db_shell <<< "CREATE EXTENSION IF NOT EXISTS unaccent;"
|
||||
|
||||
ynh_psql_db_shell <<< "CREATE EXTENSION IF NOT EXISTS pg_trgm;"
|
||||
|
||||
ynh_psql_db_shell <<< "CREATE EXTENSION IF NOT EXISTS citext;"
|
||||
|
||||
ynh_psql_db_shell <<< "CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\";"
|
||||
|
||||
#=================================================
|
||||
# SYSTEM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
|
||||
ynh_script_progression "Adding system configurations related to $app..."
|
||||
|
||||
if [ "$cache" -eq 1 ]; then
|
||||
ynh_add_config --template="../conf/cache.conf" --destination="/etc/nginx/conf.d/$app-cache.conf"
|
||||
ynh_config_add --template="cache.conf" --destination="/etc/nginx/conf.d/$app-cache.conf"
|
||||
cat ../conf/media.conf >> ../conf/nginx.conf
|
||||
fi
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
ynh_config_add_nginx
|
||||
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config
|
||||
ynh_config_add_systemd
|
||||
yunohost service add "$app" --description="$app daemon for Pleroma"
|
||||
|
||||
#=================================================
|
||||
# MAKE SETUP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Making setup..." --weight=1
|
||||
ynh_script_progression "Making setup..."
|
||||
|
||||
config="/etc/$app/config.exs"
|
||||
mkdir -p "/etc/$app"
|
||||
chown "$app:$app" "/etc/$app"
|
||||
|
||||
# Generate instance
|
||||
ynh_exec_warn_less ynh_exec_as "$app" -i \
|
||||
ynh_hide_warnings ynh_exec_as_app -i \
|
||||
"$install_dir/live/bin/pleroma_ctl" instance gen \
|
||||
--force \
|
||||
--output "$config" \
|
||||
|
@ -101,34 +97,34 @@ ynh_exec_warn_less ynh_exec_as "$app" -i \
|
|||
|
||||
cat "../conf/ldap.exs" >> "$config"
|
||||
|
||||
ynh_replace_string --target_file="$config" \
|
||||
--match_string="config :pleroma, configurable_from_database: false" \
|
||||
--replace_string="config :pleroma, configurable_from_database: true"
|
||||
ynh_replace --file="$config" \
|
||||
--match="config :pleroma, configurable_from_database: false" \
|
||||
--replace="config :pleroma, configurable_from_database: true"
|
||||
|
||||
ynh_replace_string --target_file="$config" \
|
||||
--match_string="registrations_open: true" \
|
||||
--replace_string="registrations_open: $(boolstr "$registration")"
|
||||
ynh_replace --file="$config" \
|
||||
--match="registrations_open: true" \
|
||||
--replace="registrations_open: $(boolstr "$registration")"
|
||||
|
||||
ynh_exec_warn_less ynh_exec_as "$app" -i "$install_dir/live/bin/pleroma_ctl" migrate
|
||||
ynh_systemd_action --service_name="$app" --action="start" --log_path=systemd --line_match="Access Pleroma.Web.Endpoint"
|
||||
ynh_hide_warnings ynh_exec_as_app -i "$install_dir/live/bin/pleroma_ctl" migrate
|
||||
ynh_systemctl --service="$app" --action="start" --log_path=systemd --wait_until="Access Pleroma.Web.Endpoint"
|
||||
|
||||
# Add user
|
||||
ynh_exec_warn_less ynh_exec_as "$app" -i "$install_dir/live/bin/pleroma_ctl" user new "$admin" "$admin_email" --password "$password" --moderator --admin -y
|
||||
ynh_systemd_action --service_name="$app" --action="stop" --log_path=systemd
|
||||
ynh_hide_warnings ynh_exec_as_app -i "$install_dir/live/bin/pleroma_ctl" user new "$admin" "$admin_email" --password "$password" --moderator --admin -y
|
||||
ynh_systemctl --service="$app" --action="stop" --log_path=systemd
|
||||
|
||||
# Calculate and store the config file checksum into the app settings
|
||||
ynh_store_file_checksum --file="$config"
|
||||
ynh_store_file_checksum "$config"
|
||||
|
||||
chmod 400 "$config"
|
||||
chown "$app:$app" "$config"
|
||||
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 400 "$config"
|
||||
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown "$app:$app" "$config"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||
ynh_script_progression "Starting $app's systemd service..."
|
||||
|
||||
# Start a systemd service
|
||||
ynh_systemd_action --service_name="$app" --action="start" --log_path=systemd --line_match="Access Pleroma.Web.Endpoint"
|
||||
ynh_systemctl --service="$app" --action="start" --log_path=systemd --wait_until="Access Pleroma.Web.Endpoint"
|
||||
|
||||
#=================================================
|
||||
# POST INSTALL
|
||||
|
@ -136,10 +132,10 @@ ynh_systemd_action --service_name="$app" --action="start" --log_path=systemd --l
|
|||
|
||||
# Correct path to 'static dir' in DB
|
||||
# This must be done when Pleroma is running (i.e. after install and start)
|
||||
ynh_exec_warn_less ynh_exec_as "$app" -i "$install_dir/live/bin/pleroma_ctl" config migrate_to_db
|
||||
ynh_hide_warnings ynh_exec_as_app -i "$install_dir/live/bin/pleroma_ctl" config migrate_to_db
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Installation of $app completed" --last
|
||||
ynh_script_progression "Installation of $app completed"
|
||||
|
|
|
@ -1,38 +1,32 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# REMOVE SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
|
||||
ynh_script_progression "Removing system configurations related to $app..."
|
||||
|
||||
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
|
||||
if ynh_exec_warn_less yunohost service status "$app" >/dev/null; then
|
||||
ynh_script_progression --message="Removing $app service integration..." --weight=1
|
||||
if ynh_hide_warnings yunohost service status "$app" >/dev/null; then
|
||||
ynh_script_progression "Removing $app service integration..."
|
||||
yunohost service remove "$app"
|
||||
fi
|
||||
|
||||
# Remove the dedicated systemd config
|
||||
ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd --line_match="Stopped $app"
|
||||
ynh_systemctl --service=$app --action="stop" --log_path=systemd --wait_until="Stopped $app"
|
||||
pkill -u "$app" || true
|
||||
ynh_remove_systemd_config
|
||||
ynh_config_remove_systemd
|
||||
|
||||
# Remove the dedicated NGINX config
|
||||
ynh_remove_nginx_config
|
||||
ynh_secure_remove --file="/etc/nginx/conf.d/$app-cache.conf"
|
||||
ynh_config_remove_nginx
|
||||
ynh_safe_rm "/etc/nginx/conf.d/$app-cache.conf"
|
||||
|
||||
ynh_secure_remove --file="/etc/$app"
|
||||
ynh_safe_rm "/etc/$app"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Removal of $app completed" --last
|
||||
ynh_script_progression "Removal of $app completed"
|
||||
|
|
|
@ -1,11 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||
source ../settings/scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
@ -13,66 +7,67 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the app main directory..." --weight=1
|
||||
ynh_script_progression "Restoring the app main directory..."
|
||||
|
||||
ynh_restore_file --origin_path="$install_dir"
|
||||
|
||||
chown -R "$app:$app" "$install_dir"
|
||||
ynh_restore "$install_dir"
|
||||
|
||||
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:$app" "$install_dir"
|
||||
#=================================================
|
||||
# RESTORE THE DATA DIRECTORY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the data directory..." --weight=1
|
||||
ynh_script_progression "Restoring the data directory..."
|
||||
|
||||
ynh_restore_file --origin_path="$data_dir" --not_mandatory
|
||||
ynh_restore "$data_dir"
|
||||
|
||||
chown -R "$app:$app" "$data_dir"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE POSTGRESQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1
|
||||
ynh_script_progression "Restoring the PostgreSQL database..."
|
||||
|
||||
ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS unaccent;" --database="$db_name"
|
||||
ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pg_trgm;" --database="$db_name"
|
||||
ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS citext;" --database="$db_name"
|
||||
ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\";" --database="$db_name"
|
||||
ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name"
|
||||
ynh_psql_db_shell <<< "CREATE EXTENSION IF NOT EXISTS unaccent;"
|
||||
|
||||
ynh_psql_db_shell <<< "CREATE EXTENSION IF NOT EXISTS pg_trgm;"
|
||||
|
||||
ynh_psql_db_shell <<< "CREATE EXTENSION IF NOT EXISTS citext;"
|
||||
|
||||
ynh_psql_db_shell <<< "CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\";"
|
||||
|
||||
ynh_psql_db_shell " < "./db.sql""
|
||||
|
||||
#=================================================
|
||||
# RESTORE SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
|
||||
ynh_script_progression "Restoring system configurations related to $app..."
|
||||
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$app-cache.conf" --not_mandatory
|
||||
ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
ynh_restore "/etc/nginx/conf.d/$app-cache.conf" || true
|
||||
|
||||
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
||||
ynh_restore "/etc/systemd/system/$app.service"
|
||||
systemctl enable "$app.service" --quiet
|
||||
yunohost service add "$app" --description="$app daemon for Pleroma"
|
||||
|
||||
#=================================================
|
||||
# RESTORE VARIOUS FILES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring various files..." --weight=1
|
||||
ynh_script_progression "Restoring various files..."
|
||||
|
||||
ynh_restore_file --origin_path="/etc/$app/"
|
||||
chmod 400 "/etc/$app/config.exs"
|
||||
chown "$app:$app" "/etc/$app/config.exs"
|
||||
ynh_restore "/etc/$app/"
|
||||
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 400 "/etc/$app/config.exs"
|
||||
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown "$app:$app" "/etc/$app/config.exs"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1
|
||||
ynh_script_progression "Reloading NGINX web server and $app's service..."
|
||||
|
||||
ynh_systemd_action --service_name="$app" --action="start" --log_path=systemd --line_match="Access Pleroma.Web.Endpoint"
|
||||
ynh_systemctl --service="$app" --action="start" --log_path=systemd --wait_until="Access Pleroma.Web.Endpoint"
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
ynh_systemctl --service=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Restoration completed for $app" --last
|
||||
ynh_script_progression "Restoration completed for $app"
|
||||
|
|
|
@ -1,22 +1,14 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
#=================================================
|
||||
# STOP SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping a systemd service..." --weight=1
|
||||
ynh_script_progression "Stopping $app's systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd --line_match="Stopped $app"
|
||||
ynh_systemctl --service=$app --action="stop" --log_path=systemd --wait_until="Stopped $app"
|
||||
|
||||
if ynh_compare_current_package_version --comparison gt --version "1.1.1~ynh1"; then
|
||||
pkill -u "$app" || true
|
||||
|
@ -25,20 +17,20 @@ fi
|
|||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
||||
ynh_script_progression "Ensuring downward compatibility..."
|
||||
|
||||
if [ -n "${psql_db:-}" ]; then
|
||||
ynh_app_setting_delete --app="$app" --key=psql_db
|
||||
ynh_app_setting_delete --key=psql_db
|
||||
fi
|
||||
|
||||
# Close a port
|
||||
if yunohost firewall list | grep -q "\- $port$"; then
|
||||
ynh_script_progression --message="Closing port $port..."
|
||||
ynh_exec_warn_less yunohost firewall disallow TCP "$port"
|
||||
ynh_script_progression "Closing port $port..."
|
||||
ynh_hide_warnings yunohost firewall disallow TCP "$port"
|
||||
fi
|
||||
|
||||
# Remove old repository
|
||||
ynh_secure_remove --file="/etc/apt/sources.list.d/erlang-solutions.list"
|
||||
ynh_safe_rm "/etc/apt/sources.list.d/erlang-solutions.list"
|
||||
apt-key del A14F4FCA
|
||||
|
||||
# Switch to $install_dir/live
|
||||
|
@ -48,8 +40,8 @@ fi
|
|||
|
||||
config="/etc/$app/config.exs"
|
||||
|
||||
if ynh_compare_current_package_version --comparison le --version "1.1.1~ynh1"; then
|
||||
ynh_script_progression --message="Upgrading to OTP release..." --weight=1
|
||||
if ynh_app_upgrading_from_version_before_or_equal_to 1.1.1~ynh1; then
|
||||
ynh_script_progression "Upgrading to OTP release..."
|
||||
|
||||
# Give permission to the data_dir
|
||||
chown -R "$app":"$app" "$data_dir"
|
||||
|
@ -63,88 +55,85 @@ if ynh_compare_current_package_version --comparison le --version "1.1.1~ynh1"; t
|
|||
mkdir -p "/etc/$app"
|
||||
chown -R "$app" "/etc/$app"
|
||||
mv "$install_dir/live/config/prod.secret.exs" "$config"
|
||||
ynh_replace_string --target_file="$config" \
|
||||
--match_string="use Mix.Config" \
|
||||
--replace_string="import Config"
|
||||
ynh_replace --file="$config" \
|
||||
--match="use Mix.Config" \
|
||||
--replace="import Config"
|
||||
echo "config :pleroma, :instance, static_dir: \"/home/yunohost.app/$app/static\"" >> "$config"
|
||||
echo "config :pleroma, Pleroma.Uploaders.Local, uploads: \"/home/yunohost.app/$app/uploads\"" >> "$config"
|
||||
|
||||
ynh_backup_if_checksum_is_different --file="$config"
|
||||
ynh_backup_if_checksum_is_different "$config"
|
||||
fi
|
||||
|
||||
if ynh_compare_current_package_version --comparison le --version "2.0.5~ynh1"; then
|
||||
if ynh_app_upgrading_from_version_before_or_equal_to 2.0.5~ynh1; then
|
||||
cat "../conf/ldap.exs" >> "$config"
|
||||
fi
|
||||
|
||||
if ynh_compare_current_package_version --comparison lt --version "2.5.5~ynh2"; then
|
||||
if ynh_app_upgrading_from_version_before 2.5.5~ynh2; then
|
||||
# packaging v1 did not set a shell
|
||||
usermod -s /bin/sh "$app"
|
||||
fi
|
||||
|
||||
ynh_replace_string --target_file="$config" \
|
||||
--match_string="config :pleroma, configurable_from_database: false" \
|
||||
--replace_string="config :pleroma, configurable_from_database: true"
|
||||
ynh_replace --file="$config" \
|
||||
--match="config :pleroma, configurable_from_database: false" \
|
||||
--replace="config :pleroma, configurable_from_database: true"
|
||||
|
||||
ynh_replace_string --target_file="$config" \
|
||||
--match_string='registrations_open: true' \
|
||||
--replace_string="registrations_open: $(boolstr "$registration")"
|
||||
ynh_replace --file="$config" \
|
||||
--match='registrations_open: true' \
|
||||
--replace="registrations_open: $(boolstr "$registration")"
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading source files..." --weight=1
|
||||
ynh_script_progression "Upgrading source files..."
|
||||
|
||||
ynh_setup_source --dest_dir="$install_dir/live" --full_replace=1
|
||||
|
||||
chown -R "$app:$app" "$install_dir"
|
||||
ynh_setup_source --dest_dir="$install_dir/live" --full_replace
|
||||
|
||||
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:$app" "$install_dir"
|
||||
#=================================================
|
||||
# REAPPLY SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
|
||||
ynh_script_progression "Upgrading system configurations related to $app..."
|
||||
|
||||
if [ "$cache" -eq 1 ]; then
|
||||
ynh_add_config --template="../conf/cache.conf" --destination="/etc/nginx/conf.d/$app-cache.conf"
|
||||
ynh_config_add --template="cache.conf" --destination="/etc/nginx/conf.d/$app-cache.conf"
|
||||
cat ../conf/media.conf >> ../conf/nginx.conf
|
||||
fi
|
||||
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
ynh_config_add_nginx
|
||||
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config
|
||||
ynh_config_add_systemd
|
||||
yunohost service add "$app" --description="$app daemon for Pleroma"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC UPGRADE
|
||||
#=================================================
|
||||
# MAKE UPGRADE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Making upgrade..." --weight=1
|
||||
ynh_script_progression "Making upgrade..."
|
||||
|
||||
ynh_exec_warn_less ynh_exec_as "$app" -i "$install_dir/live/bin/pleroma_ctl" migrate
|
||||
ynh_hide_warnings ynh_exec_as_app -i "$install_dir/live/bin/pleroma_ctl" migrate
|
||||
|
||||
#=================================================
|
||||
# UPDATE A CONFIG FILE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Updating a configuration file..." --weight=1
|
||||
ynh_script_progression "Updating configuration..."
|
||||
|
||||
config="/etc/$app/config.exs"
|
||||
|
||||
ynh_backup_if_checksum_is_different --file="$config"
|
||||
ynh_backup_if_checksum_is_different "$config"
|
||||
|
||||
chmod 400 "$config"
|
||||
chown "$app:$app" "$config"
|
||||
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 400 "$config"
|
||||
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown "$app:$app" "$config"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||
ynh_script_progression "Starting $app's systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name="$app" --action="start" --log_path=systemd --line_match="Access Pleroma.Web.Endpoint"
|
||||
ynh_systemctl --service="$app" --action="start" --log_path=systemd --wait_until="Access Pleroma.Web.Endpoint"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Upgrade of $app completed" --last
|
||||
ynh_script_progression "Upgrade of $app completed"
|
||||
|
|
Loading…
Add table
Reference in a new issue