mirror of
https://github.com/YunoHost-Apps/mobilizon_ynh.git
synced 2024-09-03 19:46:19 +02:00
[autopatch] Automatic patch attempt for helpers 2.1
This commit is contained in:
parent
fc369dfabe
commit
b31b0d4a4a
8 changed files with 122 additions and 180 deletions
|
@ -20,7 +20,8 @@ code = "https://framagit.org/framasoft/mobilizon/"
|
|||
fund = "https://soutenir.framasoft.org/"
|
||||
|
||||
[integration]
|
||||
yunohost = ">= 11.2"
|
||||
yunohost = ">= 11.2.18"
|
||||
helpers_version = "2.1"
|
||||
architectures = ["amd64", "arm64"]
|
||||
multi_instance = false
|
||||
ldap = true
|
||||
|
@ -61,6 +62,7 @@ ram.runtime = "400M"
|
|||
[resources.system_user]
|
||||
|
||||
[resources.install_dir]
|
||||
group = "www-data:r-x"
|
||||
|
||||
[resources.data_dir]
|
||||
subdirs = ["uploads"]
|
||||
|
|
|
@ -1,21 +1,9 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# COMMON VARIABLES
|
||||
# COMMON VARIABLES AND CUSTOM HELPERS
|
||||
#=================================================
|
||||
|
||||
ynh_user="${app}_notifs"
|
||||
|
||||
MOBILIZON_CONFIG_PATH="$install_dir/config.exs"
|
||||
|
||||
#=================================================
|
||||
# PERSONAL HELPERS
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# EXPERIMENTAL HELPERS
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# FUTURE OFFICIAL HELPERS
|
||||
#=================================================
|
||||
|
|
|
@ -1,55 +1,46 @@
|
|||
#!/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 "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
ynh_backup --src_path="/etc/systemd/system/$app.service"
|
||||
ynh_backup "/etc/systemd/system/$app.service"
|
||||
|
||||
#=================================================
|
||||
# BACKUP VARIOUS FILES
|
||||
#=================================================
|
||||
|
||||
# ynh_backup --src_path="/var/log/$app/"
|
||||
# ynh_backup "/var/log/$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,60 +1,50 @@
|
|||
#!/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..."
|
||||
ynh_script_progression "Stopping $app's systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd
|
||||
ynh_systemctl --service=$app --action="stop" --log_path=systemd
|
||||
|
||||
#=================================================
|
||||
# MODIFY URL IN NGINX CONF
|
||||
#=================================================
|
||||
ynh_script_progression --message="Updating NGINX web server configuration..."
|
||||
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..."
|
||||
ynh_script_progression "Updating configuration..."
|
||||
|
||||
if [ $change_domain -eq 1 ]; then
|
||||
yunohost user update "$ynh_user" --mail "$ynh_user@$domain" --add-mailalias "$app@$domain"
|
||||
fi
|
||||
|
||||
ynh_backup_if_checksum_is_different --file="$install_dir/config.exs"
|
||||
ynh_replace_string --match_string="$old_domain" --replace_string="$new_domain" --target_file="$install_dir/config.exs"
|
||||
ynh_store_file_checksum --file="$install_dir/config.exs"
|
||||
ynh_backup_if_checksum_is_different "$install_dir/config.exs"
|
||||
ynh_replace --match="$old_domain" --replace="$new_domain" --file="$install_dir/config.exs"
|
||||
ynh_store_file_checksum "$install_dir/config.exs"
|
||||
|
||||
chmod 400 "$install_dir/config.exs"
|
||||
chown "$app:$app" "$install_dir/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 | chmod 400 "$install_dir/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" "$install_dir/config.exs"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALISATION
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..."
|
||||
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 Mobilizon.Web.Endpoint at"
|
||||
ynh_systemctl --service="$app" --action="start" --log_path=systemd --wait_until="Access Mobilizon.Web.Endpoint at"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Change of URL completed for $app"
|
||||
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
|
||||
|
||||
|
@ -14,15 +8,15 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
|
||||
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"
|
||||
|
||||
ynh_user_password=$(ynh_string_random --length=30)
|
||||
ynh_app_setting_set --app="$app" --key="ynh_user_password" --value="$ynh_user_password"
|
||||
ynh_app_setting_set --key="ynh_user_password" --value="$ynh_user_password"
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring yunohost users..."
|
||||
ynh_script_progression "Configuring yunohost users..."
|
||||
|
||||
yunohost user create "$ynh_user" -F "Mobilizon Notifications" --domain "$domain" --password "$ynh_user_password" -q 0
|
||||
yunohost user update "$ynh_user" --add-mailalias "$app@$domain" --add-mailforward "$admin_email"
|
||||
|
@ -30,32 +24,31 @@ yunohost user update "$ynh_user" --add-mailalias "$app@$domain" --add-mailforwar
|
|||
#=================================================
|
||||
# CREATE A POSTGRESQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring the PostgreSQL database..."
|
||||
ynh_script_progression "Configuring the PostgreSQL database..."
|
||||
|
||||
# FIXME: Really superuser ??
|
||||
ynh_psql_execute_as_root --database="$db_name" --sql="ALTER USER $db_user WITH SUPERUSER;"
|
||||
ynh_psql_execute_as_root --database="$db_name" --sql="CREATE EXTENSION IF NOT EXISTS postgis;"
|
||||
ynh_psql_execute_as_root --database="$db_name" --sql="CREATE EXTENSION IF NOT EXISTS pg_trgm;"
|
||||
ynh_psql_execute_as_root --database="$db_name" --sql="CREATE EXTENSION IF NOT EXISTS unaccent;"
|
||||
ynh_psql_db_shell <<< "ALTER USER $db_user WITH SUPERUSER;"
|
||||
ynh_psql_db_shell <<< "CREATE EXTENSION IF NOT EXISTS postgis;"
|
||||
ynh_psql_db_shell <<< "CREATE EXTENSION IF NOT EXISTS pg_trgm;"
|
||||
ynh_psql_db_shell <<< "CREATE EXTENSION IF NOT EXISTS unaccent;"
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setting up source files..."
|
||||
ynh_script_progression "Setting up source files..."
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$install_dir/live"
|
||||
|
||||
chmod -R o-rwx "$install_dir"
|
||||
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 | chmod -R o-rwx "$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"
|
||||
#=================================================
|
||||
# MAKE SETUP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Making setup..."
|
||||
ynh_script_progression "Making setup..."
|
||||
|
||||
pushd "$install_dir/live"
|
||||
ynh_exec_as "$app" MOBILIZON_CONFIG_PATH="$MOBILIZON_CONFIG_PATH" MIX_ENV=prod \
|
||||
ynh_exec_as_app MOBILIZON_CONFIG_PATH="$MOBILIZON_CONFIG_PATH" MIX_ENV=prod \
|
||||
./bin/mobilizon_ctl instance gen --force \
|
||||
--output "$MOBILIZON_CONFIG_PATH" \
|
||||
--output-psql "$install_dir/setub_db.psql" \
|
||||
|
@ -67,60 +60,60 @@ pushd "$install_dir/live"
|
|||
--dbuser "$db_user" \
|
||||
--dbpass "$db_pwd" \
|
||||
--listen-port "$port"
|
||||
ynh_secure_remove --file="$install_dir/setup_db.psql"
|
||||
ynh_safe_rm "$install_dir/setup_db.psql"
|
||||
popd
|
||||
|
||||
ynh_add_config --template="ldap.exs" --destination="$install_dir/ldap.exs"
|
||||
ynh_add_config --template="mail.exs" --destination="$install_dir/mail.exs"
|
||||
ynh_add_config --template="uploads.exs" --destination="$install_dir/uploads.exs"
|
||||
ynh_config_add --template="ldap.exs" --destination="$install_dir/ldap.exs"
|
||||
ynh_config_add --template="mail.exs" --destination="$install_dir/mail.exs"
|
||||
ynh_config_add --template="uploads.exs" --destination="$install_dir/uploads.exs"
|
||||
|
||||
cat "$install_dir/ldap.exs" "$install_dir/mail.exs" "$install_dir/uploads.exs" >> "$MOBILIZON_CONFIG_PATH"
|
||||
ynh_store_file_checksum --file="$MOBILIZON_CONFIG_PATH"
|
||||
ynh_store_file_checksum "$MOBILIZON_CONFIG_PATH"
|
||||
|
||||
ynh_secure_remove --file="$install_dir/ldap.exs"
|
||||
ynh_secure_remove --file="$install_dir/mail.exs"
|
||||
ynh_secure_remove --file="$install_dir/uploads.exs"
|
||||
ynh_safe_rm "$install_dir/ldap.exs"
|
||||
ynh_safe_rm "$install_dir/mail.exs"
|
||||
ynh_safe_rm "$install_dir/uploads.exs"
|
||||
|
||||
chmod 400 "$MOBILIZON_CONFIG_PATH"
|
||||
chown "$app:$app" "$MOBILIZON_CONFIG_PATH"
|
||||
|
||||
ynh_exec_as "$app" MOBILIZON_CONFIG_PATH="$MOBILIZON_CONFIG_PATH" "$install_dir/live/bin/mobilizon_ctl" migrate
|
||||
ynh_exec_as_app MOBILIZON_CONFIG_PATH="$MOBILIZON_CONFIG_PATH" "$install_dir/live/bin/mobilizon_ctl" migrate
|
||||
|
||||
#=================================================
|
||||
# SYSTEM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
|
||||
ynh_script_progression "Adding system configurations related to $app..."
|
||||
|
||||
# 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 Mobilizon"
|
||||
|
||||
#=================================================
|
||||
# SETUP APPLICATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Finalizing installation..." --weight=1
|
||||
ynh_script_progression "Finalizing installation..."
|
||||
|
||||
ynh_systemd_action --service_name="$app" --action="start" --log_path=systemd --line_match="Access Mobilizon.Web.Endpoint at"
|
||||
ynh_systemctl --service="$app" --action="start" --log_path=systemd --wait_until="Access Mobilizon.Web.Endpoint at"
|
||||
|
||||
# We generate a dummy password ... this will actually *not* be used because the admin is supposed to connect via the ldap
|
||||
ynh_exec_as "$app" MOBILIZON_CONFIG_PATH="$MOBILIZON_CONFIG_PATH" "$install_dir/live/bin/mobilizon_ctl" \
|
||||
ynh_exec_as_app MOBILIZON_CONFIG_PATH="$MOBILIZON_CONFIG_PATH" "$install_dir/live/bin/mobilizon_ctl" \
|
||||
users.new "$admin_email" --admin --password "$(ynh_string_random --length=30)"
|
||||
|
||||
ynh_systemd_action --service_name="$app" --action="stop" --log_path=systemd
|
||||
ynh_systemctl --service="$app" --action="stop" --log_path=systemd
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..."
|
||||
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 Mobilizon.Web.Endpoint at"
|
||||
ynh_systemctl --service="$app" --action="start" --log_path=systemd --wait_until="Access Mobilizon.Web.Endpoint at"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Installation of $app completed"
|
||||
ynh_script_progression "Installation of $app completed"
|
||||
|
|
|
@ -1,36 +1,30 @@
|
|||
#!/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
|
||||
if ynh_hide_warnings yunohost service status "$app" >/dev/null; then
|
||||
yunohost service remove "$app"
|
||||
fi
|
||||
|
||||
# Properly kill the service processes
|
||||
ynh_systemd_action --service_name="$app" --action="stop" --log_path=systemd
|
||||
ynh_systemctl --service="$app" --action="stop" --log_path=systemd
|
||||
pkill -u "$app" || true
|
||||
|
||||
# Remove the dedicated systemd config
|
||||
ynh_remove_systemd_config
|
||||
ynh_config_remove_systemd
|
||||
|
||||
# Remove the dedicated NGINX config
|
||||
ynh_remove_nginx_config
|
||||
ynh_config_remove_nginx
|
||||
|
||||
# Remove the log files
|
||||
ynh_secure_remove --file="/var/log/$app"
|
||||
#REMOVEME? (Apps should not remove their log dir during remove ... this should only happen if --purge is used, and be handled by the core...) ynh_safe_rm "/var/log/$app"
|
||||
|
||||
# Remove the notifications user
|
||||
yunohost user delete "$ynh_user"
|
||||
|
@ -39,4 +33,4 @@ yunohost user delete "$ynh_user"
|
|||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Removal of $app completed"
|
||||
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,27 +7,26 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring yunohost users..."
|
||||
ynh_script_progression "Configuring yunohost users..."
|
||||
|
||||
yunohost user create "$ynh_user" --firstname "Mobilizon" --lastname "Notifications" --domain "$domain" --password "$ynh_user_password" -q 0
|
||||
yunohost user create "$ynh_user" --firstname "Mobilizon" name "Notifications" --domain "$domain" --password "$ynh_user_password" -q 0
|
||||
yunohost user update "$ynh_user" --add-mailalias "$app@$domain" --add-mailforward "$admin_email"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the app main directory..."
|
||||
ynh_script_progression "Restoring the app main directory..."
|
||||
|
||||
ynh_restore_file --origin_path="$install_dir"
|
||||
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R "$app:www-data" "$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 | chmod -R o-rwx "$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"
|
||||
#=================================================
|
||||
# RESTORE THE DATA DIRECTORY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the data directory..."
|
||||
ynh_script_progression "Restoring the data directory..."
|
||||
|
||||
ynh_restore_file --origin_path="$data_dir" --not_mandatory
|
||||
ynh_restore "$data_dir"
|
||||
|
||||
chmod -R o-rwx "$data_dir"
|
||||
chown -R "$app:$app" "$data_dir"
|
||||
|
@ -41,38 +34,38 @@ chown -R "$app:$app" "$data_dir"
|
|||
#=================================================
|
||||
# RESTORE THE POSTGRESQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the PostgreSQL database..."
|
||||
ynh_script_progression "Restoring the PostgreSQL database..."
|
||||
|
||||
ynh_psql_execute_as_root --database="$db_name" --sql="ALTER USER $db_user WITH SUPERUSER;"
|
||||
ynh_psql_execute_as_root --database="$db_name" --sql="CREATE EXTENSION IF NOT EXISTS postgis;"
|
||||
ynh_psql_execute_as_root --database="$db_name" --sql="CREATE EXTENSION IF NOT EXISTS pg_trgm;"
|
||||
ynh_psql_execute_as_root --database="$db_name" --sql="CREATE EXTENSION IF NOT EXISTS unaccent;"
|
||||
ynh_psql_execute_as_root --database="$db_name" --sql="ALTER USER $db_user WITH NOSUPERUSER;"
|
||||
ynh_psql_db_shell <<< "ALTER USER $db_user WITH SUPERUSER;"
|
||||
ynh_psql_db_shell <<< "CREATE EXTENSION IF NOT EXISTS postgis;"
|
||||
ynh_psql_db_shell <<< "CREATE EXTENSION IF NOT EXISTS pg_trgm;"
|
||||
ynh_psql_db_shell <<< "CREATE EXTENSION IF NOT EXISTS unaccent;"
|
||||
ynh_psql_db_shell <<< "ALTER USER $db_user WITH NOSUPERUSER;"
|
||||
|
||||
ynh_psql_execute_file_as_root --database="$db_name" --file="./db.sql"
|
||||
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 "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
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 Mobilizon"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD 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 Mobilizon.Web.Endpoint at"
|
||||
ynh_systemctl --service="$app" --action="start" --log_path=systemd --wait_until="Access Mobilizon.Web.Endpoint at"
|
||||
|
||||
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"
|
||||
ynh_script_progression "Restoration completed for $app"
|
||||
|
|
|
@ -1,93 +1,84 @@
|
|||
#!/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..."
|
||||
ynh_script_progression "Stopping $app's systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd
|
||||
ynh_systemctl --service=$app --action="stop" --log_path=systemd
|
||||
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Ensuring downward compatibility..."
|
||||
ynh_script_progression "Ensuring downward compatibility..."
|
||||
|
||||
# Cleanup
|
||||
ynh_secure_remove --file="$install_dir/$app/priv/data/GeoLite2-City.mmdb"
|
||||
ynh_secure_remove --file="/usr/share/GeoIP"
|
||||
ynh_safe_rm "$install_dir/$app/priv/data/GeoLite2-City.mmdb"
|
||||
ynh_safe_rm "/usr/share/GeoIP"
|
||||
|
||||
# Move legacy configuration files
|
||||
if [ ! -f "$install_dir/config.exs" ]; then
|
||||
if [ -f "$install_dir/live/config/prod.secret.exs" ]; then
|
||||
ynh_delete_file_checksum --file="$install_dir/live/config/prod.secret.exs"
|
||||
ynh_delete_file_checksum "$install_dir/live/config/prod.secret.exs"
|
||||
mv -f "$install_dir/live/config/prod.secret.exs" "$install_dir/config.exs"
|
||||
fi
|
||||
if [ -f "$install_dir/live/config/runtime.exs" ]; then
|
||||
ynh_delete_file_checksum --file="$install_dir/live/config/runtime.exs"
|
||||
ynh_delete_file_checksum "$install_dir/live/config/runtime.exs"
|
||||
mv -f "$install_dir/live/config/runtime.exs" "$install_dir/config.exs"
|
||||
fi
|
||||
if [ -f "/etc/$app/config.exs" ]; then
|
||||
ynh_delete_file_checksum --file="/etc/$app/config.exs"
|
||||
ynh_delete_file_checksum "/etc/$app/config.exs"
|
||||
mv -f "/etc/$app/config.exs" "$install_dir/config.exs"
|
||||
ynh_secure_remove --file="/etc/$app"
|
||||
ynh_safe_rm "/etc/$app"
|
||||
fi
|
||||
chown -R "$app:$app" "$install_dir/config.exs"
|
||||
ynh_store_file_checksum --file="$install_dir/config.exs"
|
||||
ynh_store_file_checksum "$install_dir/config.exs"
|
||||
fi
|
||||
# Check if previous "if block" did the job
|
||||
if [ ! -f "$install_dir/config.exs" ]; then
|
||||
ynh_die --message="Could not find a previous configuration file. Please contact maintainers on the forum."
|
||||
ynh_die "Could not find a previous configuration file. Please contact maintainers on the forum."
|
||||
fi
|
||||
|
||||
# Migrate data to data_dir
|
||||
# FIXME: could be old, might be nice to remove
|
||||
if [ -e "$install_dir/$app/uploads/" ] && [ -n "$(ls -A "$install_dir/$app/uploads/")" ]; then
|
||||
ynh_script_progression --message="Moving data directory..."
|
||||
ynh_script_progression "Moving data directory..."
|
||||
rsync -a "$install_dir/$app/uploads/" "$data_dir/uploads/"
|
||||
ynh_secure_remove "$install_dir/$app/uploads"
|
||||
ynh_safe_rm "$install_dir/$app/uploads"
|
||||
|
||||
if grep "Mobilizon.Web.Upload.Uploader.Local" "$MOBILIZON_CONFIG_PATH" >/dev/null; then
|
||||
ynh_replace_string --target_file="$MOBILIZON_CONFIG_PATH" \
|
||||
--match_string="uploads: \".*/uploads\"" \
|
||||
--replace_string="$data_dir/uploads"
|
||||
ynh_replace --file="$MOBILIZON_CONFIG_PATH" \
|
||||
--match="uploads: \".*/uploads\"" \
|
||||
--replace="$data_dir/uploads"
|
||||
else
|
||||
ynh_add_config --template="uploads.exs" --destination="$install_dir/uploads.exs"
|
||||
ynh_config_add --template="uploads.exs" --destination="$install_dir/uploads.exs"
|
||||
cat "$install_dir/uploads.exs" >> "$MOBILIZON_CONFIG_PATH"
|
||||
ynh_secure_remove --file="$install_dir/uploads.exs"
|
||||
ynh_safe_rm "$install_dir/uploads.exs"
|
||||
fi
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading source files..."
|
||||
ynh_script_progression "Upgrading source files..."
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$install_dir/live" --full_replace=1
|
||||
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R "$app:www-data" "$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 | chmod -R o-rwx "$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 A CONFIG FILE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Updating a configuration file..."
|
||||
ynh_script_progression "Updating configuration..."
|
||||
|
||||
ynh_backup_if_checksum_is_different --file="$MOBILIZON_CONFIG_PATH"
|
||||
ynh_replace_string --match_string="adapter: Bamboo.SMTPAdapter," --replace_string="adapter: Swoosh.Adapters.SMTP," --target_file="$MOBILIZON_CONFIG_PATH"
|
||||
ynh_replace_string --match_string="server: \"127.0.0.1\"," --replace_string="relay: \"127.0.0.1\"," --target_file="$MOBILIZON_CONFIG_PATH"
|
||||
ynh_store_file_checksum --file="$MOBILIZON_CONFIG_PATH"
|
||||
ynh_backup_if_checksum_is_different "$MOBILIZON_CONFIG_PATH"
|
||||
ynh_replace --match="adapter: Bamboo.SMTPAdapter," --replace="adapter: Swoosh.Adapters.SMTP," --file="$MOBILIZON_CONFIG_PATH"
|
||||
ynh_replace --match="server: \"127.0.0.1\"," --replace="relay: \"127.0.0.1\"," --file="$MOBILIZON_CONFIG_PATH"
|
||||
ynh_store_file_checksum "$MOBILIZON_CONFIG_PATH"
|
||||
|
||||
chmod 400 "$MOBILIZON_CONFIG_PATH"
|
||||
chown "$app:$app" "$MOBILIZON_CONFIG_PATH"
|
||||
|
@ -95,31 +86,31 @@ chown "$app:$app" "$MOBILIZON_CONFIG_PATH"
|
|||
#=================================================
|
||||
# MAKE SETUP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Migrating app..."
|
||||
ynh_script_progression "Migrating app..."
|
||||
|
||||
ynh_exec_as "$app" MOBILIZON_CONFIG_PATH="$MOBILIZON_CONFIG_PATH" "$install_dir/live/bin/mobilizon_ctl" migrate
|
||||
ynh_exec_as_app MOBILIZON_CONFIG_PATH="$MOBILIZON_CONFIG_PATH" "$install_dir/live/bin/mobilizon_ctl" migrate
|
||||
|
||||
#=================================================
|
||||
# REAPPLY SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
|
||||
ynh_script_progression "Upgrading system configurations related to $app..."
|
||||
|
||||
# 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 Mobilizon"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..."
|
||||
ynh_script_progression "Starting $app's systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name="$app" --action="start" --log_path=systemd --line_match="Access Mobilizon.Web.Endpoint at"
|
||||
ynh_systemctl --service="$app" --action="start" --log_path=systemd --wait_until="Access Mobilizon.Web.Endpoint at"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Upgrade of $app completed"
|
||||
ynh_script_progression "Upgrade of $app completed"
|
||||
|
|
Loading…
Add table
Reference in a new issue