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:
parent
a0b7ac12da
commit
e2eff559ba
7 changed files with 95 additions and 79 deletions
|
@ -46,15 +46,15 @@ exit
|
|||
|
||||
#### Supported architectures
|
||||
|
||||
* x86-64b - [](https://ci-apps.yunohost.org/ci/apps/mobilizon/)
|
||||
* ARMv8-A - [](https://ci-apps-arm.yunohost.org/ci/apps/mobilizon/)
|
||||
* Jessie x86-64b - [](https://ci-stretch.nohost.me/ci/apps/mobilizon/)
|
||||
* x86-64b - [](https://ci-apps.yunohost.org/ci/apps/mobilizon/)
|
||||
* ARMv8-A - [](https://ci-apps-arm.yunohost.org/ci/apps/mobilizon/)
|
||||
* Jessie x86-64b - [](https://ci-stretch.nohost.me/ci/apps/mobilizon/)
|
||||
|
||||
## Links
|
||||
|
||||
* Report a bug: https://github.com/YunoHost-Apps/mobilizon_ynh/issues
|
||||
* App website: https://joinmobilizon.org/
|
||||
* Git website: https://framagit.org/framasoft/mobilizon/
|
||||
* Upstream app repository: https://framagit.org/framasoft/mobilizon/
|
||||
* YunoHost website: https://yunohost.org/
|
||||
|
||||
---
|
||||
|
|
|
@ -33,6 +33,13 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
|||
|
||||
#=================================================
|
||||
# STANDARD BACKUP STEPS
|
||||
#=================================================
|
||||
# STOP SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_print_info --message="Stopping a systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="stop"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE APP MAIN DIR
|
||||
#=================================================
|
||||
|
@ -63,6 +70,13 @@ ynh_print_info --message="Backing up systemd configuration..."
|
|||
|
||||
ynh_backup --src_path="/etc/systemd/system/$app.service"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_print_info --message="Starting a systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="start"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
|
|
@ -29,6 +29,11 @@ ynh_print_info --message="Loading installation settings..."
|
|||
# Needed for helper "ynh_add_nginx_config"
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
|
||||
# Add settings here as needed by your application
|
||||
#db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
#db_user=$db_name
|
||||
#db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
|
||||
|
||||
#=================================================
|
||||
# CHECK WHICH PARTS SHOULD BE CHANGED
|
||||
#=================================================
|
||||
|
@ -47,6 +52,13 @@ fi
|
|||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
# STOP SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_print_info --message="Stopping a systemd service..."
|
||||
|
||||
ynh_systemd_action --action=stop --service_name=$app
|
||||
|
||||
#=================================================
|
||||
# MODIFY URL IN NGINX CONF
|
||||
#=================================================
|
||||
|
@ -78,12 +90,6 @@ fi
|
|||
|
||||
#=================================================
|
||||
# SPECIFIC MODIFICATIONS
|
||||
#=================================================
|
||||
# STOP SERVICE
|
||||
#=================================================
|
||||
|
||||
ynh_systemd_action --action=stop --service_name=$app
|
||||
|
||||
#=================================================
|
||||
# MODIFY A CONFIG FILE
|
||||
#=================================================
|
||||
|
@ -91,12 +97,6 @@ ynh_systemd_action --action=stop --service_name=$app
|
|||
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"
|
||||
|
||||
#=================================================
|
||||
# START SERVICE
|
||||
#=================================================
|
||||
|
||||
ynh_systemd_action --action=start --service_name=$app --log_path=systemd --line_match="Access MobilizonWeb.Endpoint at"
|
||||
|
||||
#=================================================
|
||||
# STORE THE CONFIG FILE CHECKSUM
|
||||
#=================================================
|
||||
|
@ -107,12 +107,18 @@ ynh_store_file_checksum --file="$final_path/$app/.env"
|
|||
|
||||
#=================================================
|
||||
# GENERIC FINALISATION
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
|
||||
ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="Access MobilizonWeb.Endpoint at"
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_print_info --message="Reloading nginx web server..."
|
||||
|
||||
systemctl reload nginx
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
|
|
|
@ -43,7 +43,7 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
ynh_print_info --message="Validating installation parameters..."
|
||||
|
||||
final_path=/var/www/$app
|
||||
test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
||||
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
||||
|
||||
# Register (book) web path
|
||||
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
||||
|
@ -70,7 +70,7 @@ ynh_app_setting_set --app=$app --key=admin_email --value=$admin_email
|
|||
ynh_print_info --message="Configuring firewall..."
|
||||
|
||||
# Find a free port
|
||||
port=$(ynh_find_port 8095)
|
||||
port=$(ynh_find_port --port=8095)
|
||||
ynh_app_setting_set --app=$app --key=port --value=$port
|
||||
|
||||
#=================================================
|
||||
|
@ -80,7 +80,7 @@ ynh_print_info --message="Installing dependencies..."
|
|||
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
ynh_install_nodejs 10
|
||||
ynh_install_nodejs --nodejs_version="10"
|
||||
|
||||
ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key='https://dl.yarnpkg.com/debian/pubkey.gpg'
|
||||
|
||||
|
@ -221,6 +221,12 @@ chown -R "$app":"$app" "$final_path"
|
|||
# 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_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Access MobilizonWeb.Endpoint at"
|
||||
|
||||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
|
@ -238,13 +244,7 @@ fi
|
|||
#=================================================
|
||||
ynh_print_info --message="Reloading nginx web server..."
|
||||
|
||||
systemctl reload nginx
|
||||
|
||||
#=================================================
|
||||
# START SERVICE
|
||||
#=================================================
|
||||
|
||||
ynh_systemd_action --action=start --service_name=$app --log_path=systemd --line_match="Access MobilizonWeb.Endpoint at"
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
|
|
|
@ -31,16 +31,10 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
|||
# Remove a service from the admin panel, added by `yunohost service add`
|
||||
if yunohost service status $app >/dev/null 2>&1
|
||||
then
|
||||
ynh_print_info --message="Removing $app service"
|
||||
ynh_print_info --message="Removing $app service..."
|
||||
yunohost service remove $app
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# STOP SERVICE
|
||||
#=================================================
|
||||
|
||||
ynh_systemd_action --action=stop --service_name=$app
|
||||
|
||||
#=================================================
|
||||
# STOP AND REMOVE SERVICE
|
||||
#=================================================
|
||||
|
@ -54,8 +48,6 @@ ynh_remove_systemd_config
|
|||
#=================================================
|
||||
ynh_print_info --message="Removing the PostgreSQL database"
|
||||
|
||||
ynh_psql_execute_as_root --sql="SELECT pg_terminate_backend (pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = '$db_name';" --database=$db_name
|
||||
|
||||
# Remove a database if it exists, along with the associated user
|
||||
ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
|
||||
|
||||
|
@ -92,7 +84,7 @@ ynh_print_info --message="Closing a port..."
|
|||
|
||||
if yunohost firewall list | grep -q "\- $port$"
|
||||
then
|
||||
ynh_print_info --message="Closing port $port"
|
||||
ynh_script_progression --message="Closing port $port..."
|
||||
ynh_exec_warn_less yunohost firewall disallow TCP $port
|
||||
fi
|
||||
|
||||
|
|
|
@ -86,15 +86,10 @@ ynh_print_info --message="Reinstalling dependencies..."
|
|||
# Define and install dependencies
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
ynh_install_nodejs 10
|
||||
ynh_install_nodejs --nodejs_version="10"
|
||||
|
||||
ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key='https://dl.yarnpkg.com/debian/pubkey.gpg'
|
||||
|
||||
#=================================================
|
||||
# REINSTALL EXTRA DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_print_info --message="Reinstalling extra dependencies ..."
|
||||
|
||||
lsb_name="$(lsb_release --codename --short)"
|
||||
ynh_install_extra_app_dependencies --repo="deb http://packages.erlang-solutions.com/debian $lsb_name contrib" --package="$extra_pkg_dependencies" --key='https://packages.erlang-solutions.com/debian/erlang_solutions.asc'
|
||||
|
||||
|
@ -105,10 +100,10 @@ ynh_print_info --message="Restoring the PostgreSQL database..."
|
|||
|
||||
ynh_psql_test_if_first_run
|
||||
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
|
||||
ynh_psql_execute_as_root --sql="create extension if not exists postgis;" --database=$db_name
|
||||
ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS postgis;" --database=$db_name
|
||||
ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pg_trgm;" --database=$db_name
|
||||
ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS unaccent;" --database=$db_name
|
||||
ynh_psql_execute_file_as_root --file=./db.sql --database=$db_name
|
||||
ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name
|
||||
|
||||
#=================================================
|
||||
# RESTORE SYSTEMD
|
||||
|
@ -117,7 +112,6 @@ ynh_print_info --message="Restoring the systemd configuration..."
|
|||
|
||||
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
||||
systemctl enable $app.service
|
||||
systemctl daemon-reload
|
||||
|
||||
#=================================================
|
||||
# ADVERTISE SERVICE IN ADMIN PANEL
|
||||
|
@ -125,6 +119,12 @@ systemctl daemon-reload
|
|||
|
||||
yunohost service add $app --description "$app daemon for Mobilizon"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Access MobilizonWeb.Endpoint at"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
|
@ -132,13 +132,7 @@ yunohost service add $app --description "$app daemon for Mobilizon"
|
|||
#=================================================
|
||||
ynh_print_info --message="Reloading nginx web server..."
|
||||
|
||||
systemctl reload nginx
|
||||
|
||||
#=================================================
|
||||
# START SERVICE
|
||||
#=================================================
|
||||
|
||||
ynh_systemd_action --action=start --service_name=$app --log_path=systemd --line_match="Access MobilizonWeb.Endpoint at"
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
|
|
|
@ -31,6 +31,12 @@ secret=$(ynh_app_setting_get --app=$app --key=secret)
|
|||
name=$(ynh_app_setting_get --app=$app --key=name)
|
||||
admin_email=$(ynh_app_setting_get --app=$app --key=admin_email)
|
||||
|
||||
#=================================================
|
||||
# CHECK VERSION
|
||||
#=================================================
|
||||
|
||||
upgrade_type=$(ynh_check_app_version_changed)
|
||||
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
|
@ -46,13 +52,13 @@ elif [ "$is_public" = "No" ]; then
|
|||
fi
|
||||
|
||||
# If db_name doesn't exist, create it
|
||||
if [ -z $db_name ]; then
|
||||
if [ -z "$db_name" ]; then
|
||||
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
||||
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
||||
fi
|
||||
|
||||
# If final_path doesn't exist, create it
|
||||
if [ -z $final_path ]; then
|
||||
if [ -z "$final_path" ]; then
|
||||
final_path=/var/www/$app
|
||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||
fi
|
||||
|
@ -72,21 +78,26 @@ ynh_clean_setup () {
|
|||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# STOP SERVICE
|
||||
#=================================================
|
||||
|
||||
ynh_systemd_action --action=stop --service_name=$app --log_path=systemd
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
#=================================================
|
||||
# STOP SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_print_info --message="Stopping a systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_print_info --message="Upgrading source files..."
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$final_path/$app"
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
ynh_script_progression --message="Upgrading source files..." --time --weight=1
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$final_path/$app"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
|
@ -103,12 +114,7 @@ ynh_print_info --message="Upgrading dependencies..."
|
|||
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
ynh_install_nodejs 10
|
||||
|
||||
#=================================================
|
||||
# INSTALL EXTRA DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_print_info --message="Installing extra dependencies ..."
|
||||
ynh_install_nodejs --nodejs_version="10"
|
||||
|
||||
lsb_name="$(lsb_release --codename --short)"
|
||||
ynh_install_extra_app_dependencies --repo="deb http://packages.erlang-solutions.com/debian $lsb_name contrib" --package="$extra_pkg_dependencies" --key='https://packages.erlang-solutions.com/debian/erlang_solutions.asc'
|
||||
|
@ -173,7 +179,11 @@ pushd $final_path/$app
|
|||
sudo -u "$app" MIX_ENV=prod mix phx.digest
|
||||
popd
|
||||
|
||||
ynh_backup_if_checksum_is_different "$config"
|
||||
#=================================================
|
||||
# STORE THE CONFIG FILE CHECKSUM
|
||||
#=================================================
|
||||
|
||||
ynh_backup_if_checksum_is_different --file="$config"
|
||||
# Recalculate and store the checksum of the file for the next upgrade.
|
||||
ynh_store_file_checksum --file="$config"
|
||||
|
||||
|
@ -206,19 +216,19 @@ then
|
|||
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# START 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"
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_print_info --message="Reloading nginx web server..."
|
||||
|
||||
systemctl reload nginx
|
||||
|
||||
#=================================================
|
||||
# START SERVICE
|
||||
#=================================================
|
||||
|
||||
ynh_systemd_action --action=start --service_name=$app --log_path=systemd --line_match="Access MobilizonWeb.Endpoint at"
|
||||
|
||||
systemctl reload nginxynh_systemd_action --service_name=nginx --action=reload
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
|
Loading…
Add table
Reference in a new issue