1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/codimd_ynh.git synced 2024-09-03 18:16:32 +02:00

Apply example_ynh (#72)

* Apply example_ynh
This commit is contained in:
yalh76 2022-02-05 08:22:52 +01:00 committed by GitHub
parent d4fd9f07d5
commit ec94539d2a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 50 additions and 45 deletions

View file

@ -19,7 +19,7 @@ CodiMD is the free software version of HackMD, developed and opened source by th
CodiMD is perfect for open communities, while HackMD emphasizes on permission and access controls for commercial use cases.
**Shipped version:** 2.4.1~ynh4
**Shipped version:** 2.4.1~ynh5

View file

@ -15,7 +15,7 @@ CodiMD est la version logicielle libre de HackMD, développée et ouverte par l'
CodiMD est parfait pour les communautés ouvertes, tandis que HackMD met l'accent sur les autorisations et les contrôles d'accès pour les cas d'utilisation commerciale.
**Version incluse :** 2.4.1~ynh4
**Version incluse :** 2.4.1~ynh5

View file

@ -23,4 +23,3 @@ Notification=none
; commit=0d58e34697338049d951c8373da3d363a121d439
name=Upgrade to version 2.4.1
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666&

View file

@ -6,7 +6,7 @@
"en": "Collaborative editor to work on notes written in Markdown",
"fr": "Éditeur collaboratif pour travailler sur des notes en Markdown"
},
"version": "2.4.1~ynh4",
"version": "2.4.1~ynh5",
"url": "https://github.com/hackmdio/codimd",
"upstream": {
"license": "AGPL-3.0-only",

View file

@ -6,6 +6,7 @@
# 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
@ -66,4 +67,4 @@ ynh_psql_dump_db --database="$db_name" > db.sql
# END OF SCRIPT
#=================================================
ynh_print_info --message="Backup script completed for CodiMD. (YunoHost will then actually copy those files to the archive)."
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -34,9 +34,9 @@ db_user=$db_name
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up CodiMD before changing its URL (may take a while)..." --weight=1
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1
# Backup the current version of the app
ynh_backup_before_upgrade
@ -44,7 +44,7 @@ ynh_clean_setup () {
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
# restore it if the upgrade fails
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
@ -76,7 +76,7 @@ ynh_script_progression --message="Updating NGINX web server configuration..." --
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
# Change the domain for nginx
# Change the domain for NGINX
if [ $change_domain -eq 1 ]
then
# Delete file checksum for the old conf file location
@ -117,4 +117,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Change of URL completed for CodiMD" --last
ynh_script_progression --message="Change of URL completed for $app" --last

View file

@ -123,9 +123,9 @@ pushd $final_path
popd
#=================================================
# MODIFY A CONFIG FILE
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Modifying a config file..."
ynh_script_progression --message="Adding a configuration file..."
path=${path_url:1}
ynh_add_config --template="../conf/config.json.example" --destination="$final_path/config.json"
@ -140,6 +140,7 @@ chmod +x $final_path/app.js
#=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=1
# Create a dedicated systemd config
ynh_add_systemd_config
#=================================================
@ -162,9 +163,11 @@ ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_
#=================================================
ynh_script_progression --message="Configuring permissions..." --weight=1
# Make app public if necessary or protect it
# Make app public if necessary
if [ $is_public -eq 1 ]
then
# Everyone can access the app.
# The "main" permission is automatically created before the install script.
ynh_permission_update --permission="main" --add="visitors"
fi
@ -179,4 +182,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of CodiMD completed" --last
ynh_script_progression --message="Installation of $app completed" --last

View file

@ -17,9 +17,9 @@ ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# STANDARD REMOVE
@ -27,7 +27,7 @@ db_user=$db_name
# REMOVE SERVICE INTEGRATION IN YUNOHOST
#=================================================
# Remove the service from the list of services known by Yunohost (added from `yunohost service add`)
# 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..." --weight=1
@ -50,19 +50,10 @@ ynh_script_progression --message="Removing the PostgreSQL database..." --weight=
# Remove a database if it exists, along with the associated user
ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=1
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
ynh_remove_nodejs
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_script_progression --message="Removing CodiMD main directory..." --weight=6
ynh_script_progression --message="Removing app main directory..." --weight=6
# Remove the app directory securely
ynh_secure_remove --file="$final_path"
@ -75,6 +66,15 @@ ynh_script_progression --message="Removing NGINX web server configuration..." --
# Remove the dedicated NGINX config
ynh_remove_nginx_config
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=1
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
ynh_remove_nodejs
#=================================================
# GENERIC FINALIZATION
#=================================================
@ -89,4 +89,4 @@ ynh_system_user_delete --username=$app
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Removal of CodiMD completed" --last
ynh_script_progression --message="Removal of $app completed" --last

View file

@ -6,6 +6,7 @@
# 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
@ -61,7 +62,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring CodiMD main directory..." --weight=60
ynh_script_progression --message="Restoring the app main directory..." --weight=60
ynh_restore_file --origin_path="$final_path"
@ -126,4 +127,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Restoration completed for CodiMD" --last
ynh_script_progression --message="Restoration completed for $app" --last

View file

@ -27,30 +27,19 @@ db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
#=================================================
# CHECK VERSION
#=================================================
ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# Cleaning legacy permissions
if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public
fi
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up CodiMD before upgrading (may take a while)..." --weight=20
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=20
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# restore it if the upgrade fails
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
@ -65,6 +54,18 @@ ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd"
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# Cleaning legacy permissions
if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public
fi
#=================================================
# CREATE DEDICATED USER
#=================================================
@ -143,7 +144,7 @@ fi
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=2
ynh_script_progression --message="Upgrading systemd configuration..." --weight=2
# Create a dedicated systemd config
ynh_add_systemd_config
@ -173,4 +174,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of CodiMD completed" --last
ynh_script_progression --message="Upgrade of $app completed" --last