Skip to content

Commit

Permalink
Finalize manifestV2 port
Browse files Browse the repository at this point in the history
  • Loading branch information
Salamandar committed Sep 19, 2023
1 parent 3cfbcdd commit 992d6e3
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 316 deletions.
23 changes: 0 additions & 23 deletions scripts/backup
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,6 @@
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers

#=================================================
# MANAGE SCRIPT FAILURE
#=================================================

#REMOVEME? ynh_clean_setup () {
true
}
# Exit if an error occurs during the execution of the script
#REMOVEME? ynh_abort_if_errors

#=================================================
# LOAD SETTINGS
#=================================================
#REMOVEME? ynh_print_info --message="Loading installation settings..."

#REMOVEME? app=$YNH_APP_INSTANCE_NAME

#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
#REMOVEME? synapse_instance=$(ynh_app_setting_get --app=$app --key=synapse_instance)
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)

#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
Expand Down Expand Up @@ -61,8 +40,6 @@ ynh_backup --src_path="/etc/systemd/system/$app.service"
#=================================================
ynh_print_info --message="Backing up the PostgreSQL database..."

### (However, things like MySQL dumps *do* take some time to run, though the
### copy of the generated dump to the archive still happens later)
ynh_psql_dump_db --database="$db_name" > db.sql

#=================================================
Expand Down
136 changes: 0 additions & 136 deletions scripts/change_url

This file was deleted.

46 changes: 3 additions & 43 deletions scripts/remove
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,6 @@
source _common.sh
source /usr/share/yunohost/helpers

#=================================================
# LOAD SETTINGS
#=================================================
#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1

#REMOVEME? app=$YNH_APP_INSTANCE_NAME

#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
#REMOVEME? synapse_instance=$(ynh_app_setting_get --app=$app --key=synapse_instance)

#=================================================
# STANDARD REMOVE
#=================================================
Expand Down Expand Up @@ -49,29 +38,11 @@ ynh_script_progression --message="Removing logrotate configuration..." --weight=
# Remove the app-specific logrotate config
ynh_remove_logrotate

#=================================================
# REMOVE THE POSTGRESQL DATABASE
#=================================================
#REMOVEME? ynh_script_progression --message="Removing the PostgreSQL database..." --weight=1

# Remove a database if it exists, along with the associated user
#REMOVEME? ynh_psql_remove_db --db_user=$db_name --db_name=$db_name

#=================================================
# REMOVE APP MAIN DIR
#=================================================
#REMOVEME? ynh_script_progression --message="Removing app main directory..." --weight=1

# Remove the app directory securely
#REMOVEME? ynh_secure_remove --file="$install_dir"

#=================================================
# REMOVE DEPENDENCIES
#=================================================
#REMOVEME? ynh_script_progression --message="Removing dependencies..." --weight=1
ynh_script_progression --message="Removing dependencies..." --weight=1

# Remove metapackage and its dependencies
#REMOVEME? ynh_remove_app_dependencies
ynh_remove_nodejs

#=================================================
Expand All @@ -81,24 +52,13 @@ ynh_remove_nodejs
#=================================================
ynh_script_progression --message="Removing synapse app service..." --weight=6

# Remove a directory securely
ynh_secure_remove --file="/etc/matrix-$synapse_instance/app-service/$app.yaml"

/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh \
|| ynh_die "Synapse can't restart with the appservice configuration"
"/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh" || ynh_die --message="Synapse can't restart with the appservice configuration"

# Remove the log files
ynh_secure_remove --file="/var/log/$app"

#=================================================
# GENERIC FINALIZATION
#=================================================
# REMOVE DEDICATED USER
#=================================================
#REMOVEME? ynh_script_progression --message="Removing the dedicated system user..." --weight=1

# Delete a system user
#REMOVEME? ynh_system_user_delete --username=$app

#=================================================
# END OF SCRIPT
#=================================================
Expand Down
86 changes: 18 additions & 68 deletions scripts/restore
Original file line number Diff line number Diff line change
Expand Up @@ -10,44 +10,10 @@
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers

#=================================================
# MANAGE SCRIPT FAILURE
#=================================================

#REMOVEME? ynh_clean_setup () {
true
}
# Exit if an error occurs during the execution of the script
#REMOVEME? ynh_abort_if_errors

#=================================================
# LOAD SETTINGS
#=================================================
#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1

#REMOVEME? app=$YNH_APP_INSTANCE_NAME
server_name=$(ynh_app_setting_get --app=$app --key=server_name)

#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
#REMOVEME? synapse_instance=$(ynh_app_setting_get --app=$app --key=synapse_instance)
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)

#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
#REMOVEME? ynh_script_progression --message="Validating restoration parameters..." --weight=1

#REMOVEME? test ! -d $install_dir \
|| ynh_die --message="There is already a directory: $install_dir "

#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
#REMOVEME? ynh_script_progression --message="Recreating the dedicated system user..." --weight=1

# Create the dedicated user (if not existing)
#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir"
synapse_db_name="matrix_$synapse_instance"
bot_synapse_db_user="@$botname:$server_name"

#=================================================
# RESTORE THE APP MAIN DIR
Expand All @@ -57,59 +23,53 @@ ynh_script_progression --message="Restoring the app main directory..." --weight=
ynh_restore_file --origin_path="$install_dir"

chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
chmod -R 750 "$install_dir"
chown -R "$app:$app" "$install_dir"

#=================================================
# SPECIFIC RESTORATION
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." --weight=1

# Define and install dependencies
#REMOVEME? ynh_install_app_dependencies $pkg_dependencies

#=================================================
# RESTORE THE POSTGRESQL DATABASE
#=================================================
#REMOVEME? ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1

#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
#REMOVEME? ynh_psql_test_if_first_run
#REMOVEME? ynh_psql_setup_db --db_user=$db_name --db_name=$db_name --db_pwd=$db_pwd
ynh_psql_connect_as --user=$db_name --password=$db_pwd --database=$db_name < ./db.sql
ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name"

#=================================================
# RESTORE VARIOUS FILES
# REGISTER SYNAPSE APP-SERVICE
#=================================================
ynh_script_progression --message="Restoring various files..." --weight=1
ynh_script_progression --message="Registering Synapse app-service" --weight=1

ynh_restore_file --origin_path="/etc/cron.d/$app"
__ynh_register_matrix_app_service

ynh_restore_file --origin_path="/etc/$app/"
chmod 400 "$install_dir/config.yaml"
chown "$app:$app" "$install_dir/config.yaml"

#=================================================
# RESTORE SYSTEMD
#=================================================
ynh_script_progression --message="Restoring the systemd configuration..." --weight=1

ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service --quiet
systemctl enable "$app.service" --quiet

#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1

ynh_restore_file --origin_path="/etc/logrotate.d/$app"
mkdir --parents "/var/log/$app"
chmod -R 600 "/var/log/$app"
chmod 700 "/var/log/$app"
chown -R "$app:$app" "/var/log/$app"

#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1

yunohost service add $app --description="$app daemon for bridging IRC and Matrix." --log="/var/log/$app/$app.log"
yunohost service add $app --description="$app daemon for bridging IRC and Matrix messages." --log="/var/log/$app/$app.log"

#=================================================
# START SYSTEMD SERVICE
Expand All @@ -118,16 +78,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1

ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"

#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX AND PHP-FPM
#=================================================
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=1

ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
ynh_systemd_action --service_name=nginx --action=reload

#=================================================
# END OF SCRIPT
#=================================================
Expand Down
Loading

0 comments on commit 992d6e3

Please sign in to comment.