1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/mobilizon_ynh.git synced 2024-09-03 19:46:19 +02:00

Apply example_ynh

This commit is contained in:
yalh76 2020-01-10 21:07:59 +01:00
parent 4d51ffe2d7
commit a9eadfcf80
7 changed files with 60 additions and 24 deletions

View file

@ -48,7 +48,6 @@ exit
* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/mobilizon%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/mobilizon/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/mobilizon%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/mobilizon/)
* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/mobilizon%20%28Apps%29.svg)](https://ci-stretch.nohost.me/ci/apps/mobilizon/)
## Links

View file

@ -39,7 +39,7 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name)
#=================================================
ynh_print_info --message="Stopping a systemd service..."
ynh_systemd_action --service_name=$app --action="stop"
ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd
#=================================================
# BACKUP THE APP MAIN DIR
@ -76,7 +76,7 @@ ynh_backup --src_path="/etc/systemd/system/$app.service"
#=================================================
ynh_print_info --message="Starting a systemd service..."
ynh_systemd_action --service_name=$app --action="start"
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Access MobilizonWeb.Endpoint at"
#=================================================
# END OF SCRIPT

View file

@ -34,6 +34,23 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#db_user=$db_name
#db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_print_info --message="Backing up the app before changing its url (may take a while)..."
# Backup the current version of the app
ynh_backup_before_upgrade
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
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# CHECK WHICH PARTS SHOULD BE CHANGED
#=================================================
@ -57,7 +74,7 @@ fi
#=================================================
ynh_print_info --message="Stopping a systemd service..."
ynh_systemd_action --action=stop --service_name=$app
ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd --line_match="Stopped"
#=================================================
# MODIFY URL IN NGINX CONF
@ -93,6 +110,7 @@ fi
#=================================================
# MODIFY A CONFIG FILE
#=================================================
ynh_print_info --message="Modifying a config file..."
ynh_replace_string --match_string="$old_domain" --replace_string="$new_domain" --target_file="$final_path/$app/.env"
ynh_replace_string --match_string="$old_domain" --replace_string="$new_domain" --target_file="$final_path/$app/config/prod.secret.exs"
@ -100,6 +118,7 @@ ynh_replace_string --match_string="$old_domain" --replace_string="$new_domain" -
#=================================================
# STORE THE CONFIG FILE CHECKSUM
#=================================================
ynh_print_info --message="Storing the config file checksum..."
ynh_backup_if_checksum_is_different --file="$final_path/$app/.env"
# Recalculate and store the checksum of the file for the next upgrade.
@ -110,8 +129,9 @@ ynh_store_file_checksum --file="$final_path/$app/.env"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_print_info --message="Starting a systemd service..."
ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="Access MobilizonWeb.Endpoint at"
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Access MobilizonWeb.Endpoint at"
#=================================================
# RELOAD NGINX

View file

@ -13,6 +13,7 @@ source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_print_info --message="Managing script failure..."
ynh_clean_setup () {
ynh_clean_check_starting
@ -23,6 +24,7 @@ ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
ynh_print_info --message="Retrieving arguments from the manifest..."
domain=$YNH_APP_ARG_DOMAIN
path_url="/"
@ -69,7 +71,7 @@ ynh_app_setting_set --app=$app --key=admin_email --value=$admin_email
#=================================================
ynh_print_info --message="Configuring firewall..."
# Find a free port
# Find an available port
port=$(ynh_find_port --port=8095)
ynh_app_setting_set --app=$app --key=port --value=$port
@ -141,6 +143,7 @@ ynh_system_user_create --username=$app --home_dir=$final_path
#=================================================
# MODIFY A CONFIG FILE
#=================================================
ynh_print_info --message="Modifying a config file..."
config="$final_path/$app/.env"
cp ../conf/.env "$config"
@ -157,6 +160,7 @@ ynh_replace_string --match_string="__ADMIN_EMAIL__" --replace_string="$admin_ema
#=================================================
# MAKE SETUP
#=================================================
ynh_print_info --message="Making setup..."
# Temporarly bypass error : WARNING ** (ArgumentError) argument error and System.get_env doesn't load environment variables
@ -211,21 +215,24 @@ ynh_store_file_checksum --file="$config"
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
ynh_print_info --message="Securing files and directories..."
# Set permissions to app files
chown -R "$app":"$app" "$final_path"
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_print_info --message="Integrating service in YunoHost..."
# if using yunohost version 3.2 or more in the 'manifest.json', a description can be added
yunohost service add $app --description "$app daemon for Mobilizon"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_print_info --message="Starting a systemd service..."
# Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Access MobilizonWeb.Endpoint at"
#=================================================

View file

@ -25,11 +25,12 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# STANDARD REMOVE
#=================================================
# REMOVE SERVICE FROM ADMIN PANEL
# REMOVE SERVICE INTEGRATION IN YUNOHOST
#=================================================
ynh_print_info --message="Removing service integration in YunoHost..."
# Remove a service from the admin panel, added by `yunohost service add`
if yunohost service status $app >/dev/null 2>&1
# 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_print_info --message="Removing $app service..."
yunohost service remove $app
@ -38,7 +39,7 @@ fi
#=================================================
# STOP AND REMOVE SERVICE
#=================================================
ynh_print_info --message="Stopping and removing the systemd service"
ynh_print_info --message="Stopping and removing the systemd service..."
# Remove the dedicated systemd config
ynh_remove_systemd_config
@ -46,7 +47,7 @@ ynh_remove_systemd_config
#=================================================
# REMOVE THE POSTGRESQL DATABASE
#=================================================
ynh_print_info --message="Removing the PostgreSQL database"
ynh_print_info --message="Removing the PostgreSQL database..."
# Remove a database if it exists, along with the associated user
ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
@ -54,7 +55,7 @@ ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_print_info --message="Removing dependencies"
ynh_print_info --message="Removing dependencies..."
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
@ -64,7 +65,7 @@ ynh_remove_nodejs
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_print_info --message="Removing app main directory"
ynh_print_info --message="Removing app main directory..."
# Remove the app directory securely
ynh_secure_remove --file="$final_path"
@ -72,7 +73,7 @@ ynh_secure_remove --file="$final_path"
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_print_info --message="Removing nginx web server configuration"
ynh_print_info --message="Removing nginx web server configuration..."
# Remove the dedicated nginx config
ynh_remove_nginx_config
@ -84,15 +85,16 @@ ynh_print_info --message="Closing a port..."
if yunohost firewall list | grep -q "\- $port$"
then
ynh_script_progression --message="Closing port $port..."
ynh_print_info --message="Closing port $port..."
ynh_exec_warn_less yunohost firewall disallow TCP $port
fi
#=================================================
# SPECIFIC REMOVE
#=================================================
# REMOVE THE CRON FILE
# REMOVE THE LOG FILE
#=================================================
ynh_print_info --message="Removing the log files..."
# Remove the log files
ynh_secure_remove --file="/var/log/$app/"
@ -102,7 +104,7 @@ ynh_secure_remove --file="/var/log/$app/"
#=================================================
# REMOVE DEDICATED USER
#=================================================
ynh_print_info --message="Removing the dedicated system user"
ynh_print_info --message="Removing the dedicated system user..."
# Delete a system user
ynh_system_user_delete --username=$app

View file

@ -14,6 +14,7 @@ source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_print_info --message="Managing script failure..."
ynh_clean_setup () {
ynh_clean_check_starting
@ -72,6 +73,7 @@ ynh_system_user_create --username=$app --home_dir=$final_path
#=================================================
# RESTORE USER RIGHTS
#=================================================
ynh_print_info --message="Restoring user rights..."
# Restore permissions on app files
chown -R "$app":"$app" "$final_path"
@ -114,14 +116,16 @@ ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_print_info --message="Integrating service in YunoHost..."
yunohost service add $app --description "$app daemon for Mobilizon"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_print_info --message="Starting a systemd service..."
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Access MobilizonWeb.Endpoint at"

View file

@ -85,7 +85,7 @@ ynh_abort_if_errors
#=================================================
ynh_print_info --message="Stopping a systemd service..."
ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd
ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd --line_match="Stopped"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
@ -93,7 +93,7 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading source files..." --time --weight=1
ynh_print_info --message="Upgrading source files..."
# Create a temporary directory
tmpdir="$(mktemp -d)"
@ -149,6 +149,7 @@ ynh_system_user_create --username=$app --home_dir=$final_path
#=================================================
# MODIFY A CONFIG FILE
#=================================================
ynh_print_info --message="Modifying a config file..."
config="$final_path/$app/.env"
ynh_backup_if_checksum_is_different --file="$config"
@ -166,6 +167,7 @@ ynh_replace_string --match_string="__ADMIN_EMAIL__" --replace_string="$admin_ema
#=================================================
# MAKE SETUP
#=================================================
ynh_print_info --message="Making setup..."
# Temporarly bypass error : WARNING ** (ArgumentError) argument error and System.get_env doesn't load environment variables
@ -199,7 +201,8 @@ popd
#=================================================
# STORE THE CONFIG FILE CHECKSUM
#=================================================
#=ynh_print_info --message="Storing the config file checksum..."
================================================
# Recalculate and store the checksum of the file for the next upgrade.
ynh_store_file_checksum --file="$config"
@ -217,6 +220,7 @@ ynh_add_systemd_config
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
ynh_print_info --message="Securing files and directories..."
# Set permissions on app files
chown -R "$app":"$app" "$final_path"
@ -234,7 +238,7 @@ then
fi
#=================================================
# START SERVICE
# START SYSTEMD SERVICE
#=================================================
ynh_print_info --message="Starting a systemd service..."