mirror of
https://github.com/YunoHost-Apps/matrix-puppet-discord_ynh.git
synced 2024-09-03 19:36:25 +02:00
Apply last example_ynh
This commit is contained in:
parent
e200bd869d
commit
7037884e9d
8 changed files with 40 additions and 25 deletions
|
@ -2,7 +2,6 @@
|
||||||
; pre-install
|
; pre-install
|
||||||
sudo yunohost tools update apps
|
sudo yunohost tools update apps
|
||||||
sudo yunohost app install https://github.com/YunoHost-Apps/synapse_ynh/ -a "domain=$domain&server_name=$server_name&is_free_registration=$is_free_registration&jitsi_server=$jitsi_server" --force
|
sudo yunohost app install https://github.com/YunoHost-Apps/synapse_ynh/ -a "domain=$domain&server_name=$server_name&is_free_registration=$is_free_registration&jitsi_server=$jitsi_server" --force
|
||||||
|
|
||||||
; Manifest
|
; Manifest
|
||||||
domain="domain.tld"
|
domain="domain.tld"
|
||||||
port="8343"
|
port="8343"
|
||||||
|
|
|
@ -3,13 +3,13 @@
|
||||||
"id": "matrix-puppet-discord",
|
"id": "matrix-puppet-discord",
|
||||||
"packaging_format": 1,
|
"packaging_format": 1,
|
||||||
"description": {
|
"description": {
|
||||||
"en": "A Discord puppeting bridge for Matrix/Synapse.",
|
"en": "Discord puppeting bridge for Matrix/Synapse.",
|
||||||
"fr": "Passerelle Discord pour Matrix/Synapse."
|
"fr": "Passerelle Discord pour Matrix/Synapse."
|
||||||
},
|
},
|
||||||
"version": "0.1.7~ynh2",
|
"version": "0.1.7~ynh2",
|
||||||
"url": "https://gitlab.com/mx-puppet/discord/mx-puppet-discord",
|
"url": "https://gitlab.com/mx-puppet/discord/mx-puppet-discord",
|
||||||
"upstream": {
|
"upstream": {
|
||||||
"license": " Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"website": "https://gitlab.com/mx-puppet/discord/mx-puppet-discord",
|
"website": "https://gitlab.com/mx-puppet/discord/mx-puppet-discord",
|
||||||
"admindoc": "https://gitlab.com/mx-puppet/discord/mx-puppet-discord",
|
"admindoc": "https://gitlab.com/mx-puppet/discord/mx-puppet-discord",
|
||||||
"code": "https://gitlab.com/mx-puppet/discord/mx-puppet-discord"
|
"code": "https://gitlab.com/mx-puppet/discord/mx-puppet-discord"
|
||||||
|
|
|
@ -4,11 +4,20 @@
|
||||||
# COMMON VARIABLES
|
# COMMON VARIABLES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# dependencies used by the app
|
|
||||||
pkg_dependencies="postgresql"
|
|
||||||
# Node version
|
# Node version
|
||||||
NODEJS_VERSION=16
|
NODEJS_VERSION=16
|
||||||
|
|
||||||
|
# dependencies used by the app (must be on a single line)
|
||||||
|
pkg_dependencies="postgresql"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# PERSONAL HELPERS
|
# PERSONAL HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# EXPERIMENTAL HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# FUTURE OFFICIAL HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
|
@ -14,6 +14,9 @@ source /usr/share/yunohost/helpers
|
||||||
# MANAGE SCRIPT FAILURE
|
# MANAGE SCRIPT FAILURE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
ynh_clean_setup () {
|
||||||
|
true
|
||||||
|
}
|
||||||
# Exit if an error occurs during the execution of the script
|
# Exit if an error occurs during the execution of the script
|
||||||
ynh_abort_if_errors
|
ynh_abort_if_errors
|
||||||
|
|
||||||
|
@ -57,7 +60,7 @@ ynh_backup --src_path="$etc_path"
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE POSTGRESQL DATABASE
|
# BACKUP THE POSTGRESQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info --message="Backing up the PostgreSql database..."
|
ynh_print_info --message="Backing up the PostgreSQL database..."
|
||||||
|
|
||||||
ynh_psql_dump_db --database="$db_name" > db.sql
|
ynh_psql_dump_db --database="$db_name" > db.sql
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_clean_setup () {
|
ynh_clean_setup () {
|
||||||
ynh_clean_check_starting
|
true
|
||||||
}
|
}
|
||||||
# Exit if an error occurs during the execution of the script
|
# Exit if an error occurs during the execution of the script
|
||||||
ynh_abort_if_errors
|
ynh_abort_if_errors
|
||||||
|
@ -97,12 +97,14 @@ ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE A POSTGRESQL DATABASE
|
# CREATE A POSTGRESQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Creating a PostgresSql database..." --weight=10
|
ynh_script_progression --message="Creating a PostgreSQL database..." --weight=10
|
||||||
|
|
||||||
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
||||||
db_user=$db_name
|
db_user=$db_name
|
||||||
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
||||||
|
ynh_psql_test_if_first_run
|
||||||
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name
|
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name
|
||||||
|
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
|
@ -117,6 +119,8 @@ chmod 750 "$final_path"
|
||||||
chmod -R o-rwx "$final_path"
|
chmod -R o-rwx "$final_path"
|
||||||
chown -R $app:$app "$final_path"
|
chown -R $app:$app "$final_path"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SPECIFIC SETUP
|
||||||
#=================================================
|
#=================================================
|
||||||
# INSTALL NODE DEPENDENCIES
|
# INSTALL NODE DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -201,7 +205,7 @@ ynh_store_file_checksum --file="$app_service_registration_path/$app.yaml"
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
||||||
|
|
||||||
yunohost service add $app --description "$app daemon for bridging Discord and Matrix messages"
|
yunohost service add $app --description="$app daemon for bridging Discord and Matrix messages"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# START SYSTEMD SERVICE
|
||||||
|
|
|
@ -48,7 +48,7 @@ ynh_remove_systemd_config
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE THE POSTGRESQL DATABASE
|
# REMOVE THE POSTGRESQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing the PostgresSql database..." --weight=1
|
ynh_script_progression --message="Removing the PostgreSQL database..." --weight=1
|
||||||
|
|
||||||
# Remove a database if it exists, along with the associated user
|
# Remove a database if it exists, along with the associated user
|
||||||
ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
|
ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
|
||||||
|
|
|
@ -15,7 +15,7 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_clean_setup () {
|
ynh_clean_setup () {
|
||||||
ynh_clean_check_starting
|
true
|
||||||
}
|
}
|
||||||
# Exit if an error occurs during the execution of the script
|
# Exit if an error occurs during the execution of the script
|
||||||
ynh_abort_if_errors
|
ynh_abort_if_errors
|
||||||
|
@ -80,13 +80,12 @@ ynh_use_nodejs
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE POSTGRESQL DATABASE
|
# RESTORE THE POSTGRESQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the PostgresSql database..." --weight=20
|
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=20
|
||||||
|
|
||||||
ynh_psql_test_if_first_run
|
ynh_psql_test_if_first_run
|
||||||
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
||||||
# TODO: should I let these operation be logged?
|
|
||||||
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
|
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
|
||||||
ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
|
ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE VARIOUS FILES
|
# RESTORE VARIOUS FILES
|
||||||
|
@ -106,9 +105,10 @@ chown $app:$app "$etc_path/user.config.yaml"
|
||||||
#=================================================
|
#=================================================
|
||||||
# REGISTER SYNAPSE APP-SERVICE
|
# REGISTER SYNAPSE APP-SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Registering Synapse app-service" --weight=1
|
||||||
|
|
||||||
cp "$final_path/$app.yaml" $app_service_registration_path/$app.yaml
|
cp "$final_path/$app.yaml" $app_service_registration_path/$app.yaml
|
||||||
/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh \
|
/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh || ynh_die --message="Synapse can't restart with the appservice configuration"
|
||||||
|| ynh_die --message="Synapse can't restart with the appservice configuration"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE SYSTEMD
|
# RESTORE SYSTEMD
|
||||||
|
@ -126,7 +126,7 @@ chown "$app:$app" "$final_path/run.sh"
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
||||||
|
|
||||||
yunohost service add $app --description "$app daemon for bridging Discord and Matrix messages"
|
yunohost service add $app --description="$app daemon for bridging Discord and Matrix messages"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# START SYSTEMD SERVICE
|
||||||
|
|
|
@ -35,7 +35,7 @@ app_service_registration_path=$(ynh_app_setting_get --app=$app --key=app_service
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK VERSION
|
# CHECK VERSION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Checking version..."
|
ynh_script_progression --message="Checking version..." --weight=1
|
||||||
|
|
||||||
upgrade_type=$(ynh_check_app_version_changed)
|
upgrade_type=$(ynh_check_app_version_changed)
|
||||||
|
|
||||||
|
@ -47,7 +47,6 @@ ynh_script_progression --message="Backing up the app before upgrading (may take
|
||||||
# Backup the current version of the app
|
# Backup the current version of the app
|
||||||
ynh_backup_before_upgrade
|
ynh_backup_before_upgrade
|
||||||
ynh_clean_setup () {
|
ynh_clean_setup () {
|
||||||
ynh_clean_check_starting
|
|
||||||
# Restore it if the upgrade fails
|
# Restore it if the upgrade fails
|
||||||
ynh_restore_upgradebackup
|
ynh_restore_upgradebackup
|
||||||
}
|
}
|
||||||
|
@ -100,6 +99,8 @@ ynh_script_progression --message="Upgrading dependencies..." --weight=9
|
||||||
ynh_install_app_dependencies $pkg_dependencies
|
ynh_install_app_dependencies $pkg_dependencies
|
||||||
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
|
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SPECIFIC UPGRADE
|
||||||
#=================================================
|
#=================================================
|
||||||
# INSTALL NODE DEPENDENCIES
|
# INSTALL NODE DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -110,8 +111,6 @@ pushd "$final_path"
|
||||||
ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH GIT_SSH_COMMAND='ssh -o StrictHostKeyChecking=accept-new' npm install
|
ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH GIT_SSH_COMMAND='ssh -o StrictHostKeyChecking=accept-new' npm install
|
||||||
popd
|
popd
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SPECIFIC UPGRADE
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# UPDATE A CONFIG FILE
|
# UPDATE A CONFIG FILE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -123,16 +122,16 @@ chmod 400 "$base_config_path"
|
||||||
chown $app:$app "$base_config_path"
|
chown $app:$app "$base_config_path"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REGISTER MODULE IN SYNAPSE
|
# REGISTER SYNAPSE APP-SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Registering Synapse app-service" --weight=1
|
||||||
|
|
||||||
pushd "$final_path"
|
pushd "$final_path"
|
||||||
ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH NODE_ENV=production $final_path/run.sh -r -f "$app.yaml"
|
ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH NODE_ENV=production $final_path/run.sh -r -f "$app.yaml"
|
||||||
popd
|
popd
|
||||||
|
|
||||||
cp "$final_path/$app.yaml" $app_service_registration_path/$app.yaml
|
cp "$final_path/$app.yaml" $app_service_registration_path/$app.yaml
|
||||||
/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh \
|
/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh || ynh_die --message="Synapse can't restart with the appservice configuration"
|
||||||
|| ynh_die --message="Synapse can't restart with the appservice configuration"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SYSTEMD
|
# SETUP SYSTEMD
|
||||||
|
@ -155,13 +154,14 @@ ynh_add_config --template="../conf/run.sh" --destination="$final_path/run.sh"
|
||||||
chmod 750 "$final_path/run.sh"
|
chmod 750 "$final_path/run.sh"
|
||||||
chown "$app:$app" "$final_path/run.sh"
|
chown "$app:$app" "$final_path/run.sh"
|
||||||
|
|
||||||
yunohost service add $app --description "$app daemon for bridging Discord and Matrix messages"
|
yunohost service add $app --description="$app daemon for bridging Discord and Matrix messages"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# START SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||||
|
|
||||||
|
# Start a systemd service
|
||||||
ynh_systemd_action --service_name=$app --action="start"
|
ynh_systemd_action --service_name=$app --action="start"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
Loading…
Reference in a new issue