1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/funkwhale_ynh.git synced 2024-09-03 18:36:24 +02:00

Apply example_ynh

This commit is contained in:
yalh76 2019-05-14 22:55:26 +02:00
parent 8af39b9ceb
commit be85363dbb
8 changed files with 247 additions and 242 deletions

View file

@ -1,9 +1,9 @@
# Funkwhale # Funkwhale
[![Integration level](https://dash.yunohost.org/integration/funkwhale.svg)](https://dash.yunohost.org/appci/app/funkwhale) [![Integration level](https://dash.yunohost.org/integration/funkwhale.svg)](https://dash.yunohost.org/appci/app/funkwhale)
[![Install funkwhale with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=funkwhale) [![Install Funkwhale with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=funkwhale)
> *This package allow you to install funkwhale quickly and simply on a YunoHost server. > *This package allow you to install Funkwhale quickly and simply on a YunoHost server.
If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.* If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.*
## Overview ## Overview
@ -15,7 +15,7 @@ Installation requires a dedicated domain for now. I hope subpath installation wi
## Screenshots ## Screenshots
![](https://funkwhale.audio/assets/images/home-overlay.jpg) ![](https://funkwhale.audio/img/desktop.5e79eb16.jpg)
## Admin ## Admin
@ -40,20 +40,24 @@ The admin interface is accessible with the address: your.domain.fr/api/admin
* to be added: * to be added:
* [ ] Store files in HOME, see https://github.com/YunoHost-Apps/funkwhale_ynh/issues/15 * [ ] Store files in HOME, see https://github.com/YunoHost-Apps/funkwhale_ynh/issues/15
## Documentation
* Official documentation: https://docs.funkwhale.audio
## YunoHost specific features ## YunoHost specific features
#### Supported architectures #### Supported architectures
* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/funkwhale%20%28Community%29.svg)](https://ci-apps.yunohost.org/ci/apps/funkwhale/) * x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/funkwhale%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/funkwhale/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/funkwhale%20%28Community%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/funkwhale/) * ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/funkwhale%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/funkwhale/)
* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/funkwhale%20%28Community%29.svg)](https://ci-stretch.nohost.me/ci/apps/funkwhale/) * Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/funkwhale%20%28Apps%29.svg)](https://ci-stretch.nohost.me/ci/apps/funkwhale/)
## Links ## Links
* Report a bug about this package: https://github.com/YunoHost-Apps/funkwhale_ynh * Report a bug about this package: https://github.com/YunoHost-Apps/funkwhale_ynh
* Report a bug about Funkwhale itself: https://code.eliotberriot.com/funkwhale/funkwhale/ * Report a bug about Funkwhale itself: https://code.eliotberriot.com/funkwhale/funkwhale/
* Documentation: https://docs.funkwhale.audio * App website: https://docs.funkwhale.audio
* Funkwhale website: https://funkwhale.audio/ * Upstream app repository: https://dev.funkwhale.audio/funkwhale/funkwhale
* YunoHost website: https://yunohost.org/ * YunoHost website: https://yunohost.org/
--- ---

View file

@ -27,7 +27,6 @@
Level 3=auto Level 3=auto
# Level 4: https://github.com/YunoHost-Apps/funkwhale_ynh/issues/21 # Level 4: https://github.com/YunoHost-Apps/funkwhale_ynh/issues/21
Level 4=1 Level 4=1
# Level 5:
Level 5=auto Level 5=auto
Level 6=auto Level 6=auto
Level 7=auto Level 7=auto

View file

@ -84,7 +84,7 @@ ynh_redis_get_free_db() {
db=-1 db=-1
done done
test "$db" -eq -1 && ynh_die "No available Redis databases..." test "$db" -eq -1 && ynh_die --message="No available Redis databases..."
echo "$db" echo "$db"
} }
@ -183,8 +183,8 @@ ynh_add_fail2ban_config () {
max_retry=${3:-3} max_retry=${3:-3}
ports=${4:-http,https} ports=${4:-http,https}
test -n "$logpath" || ynh_die "ynh_add_fail2ban_config expects a logfile path as first argument and received nothing." test -n "$logpath" || ynh_die --message="ynh_add_fail2ban_config expects a logfile path as first argument and received nothing."
test -n "$failregex" || ynh_die "ynh_add_fail2ban_config expects a failure regex as second argument and received nothing." test -n "$failregex" || ynh_die --message="ynh_add_fail2ban_config expects a failure regex as second argument and received nothing."
finalfail2banjailconf="/etc/fail2ban/jail.d/$app.conf" finalfail2banjailconf="/etc/fail2ban/jail.d/$app.conf"
finalfail2banfilterconf="/etc/fail2ban/filter.d/$app.conf" finalfail2banfilterconf="/etc/fail2ban/filter.d/$app.conf"

View file

@ -23,60 +23,60 @@ ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_print_info "Loading installation settings..." ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get "$app" final_path) final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
domain=$(ynh_app_setting_get "$app" domain) domain=$(ynh_app_setting_get --app="$app" --key=domain)
db_name=$(ynh_app_setting_get "$app" db_name) db_name=$(ynh_app_setting_get --app="$app" --key=db_name)
#================================================= #=================================================
# STANDARD BACKUP STEPS # STANDARD BACKUP STEPS
#================================================= #=================================================
# BACKUP THE APP MAIN DIR # BACKUP THE APP MAIN DIR
#================================================= #=================================================
ynh_print_info "Backing up the main app directory..." ynh_print_info --message="Backing up the main app directory..."
backup_core_only=$(ynh_app_setting_get "$app" backup_core_only) backup_core_only=$(ynh_app_setting_get --app="$app" --key=backup_core_only)
# If backup_core_only have any value in the settings.yml file, do not backup the data directory # If backup_core_only have any value in the settings.yml file, do not backup the data directory
if [ -z "$backup_core_only" ] if [ -z "$backup_core_only" ]
then then
ynh_backup "$final_path" ynh_backup --src_path="$final_path"
else else
echo "Data dir will not be saved, because backup_core_only is set." >&2 echo "Data dir will not be saved, because backup_core_only is set." >&2
ynh_backup "$final_path/code" ynh_backup --src_path="$final_path/code"
fi fi
#================================================= #=================================================
# BACKUP THE NGINX CONFIGURATION # BACKUP THE NGINX CONFIGURATION
#================================================= #=================================================
ynh_print_info "Backing up nginx web server configuration..." ynh_print_info --message="Backing up nginx web server configuration..."
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup "/etc/nginx/conf.d/$domain.conf" ynh_backup --src_path="/etc/nginx/conf.d/$domain.conf"
#================================================= #=================================================
# BACKUP THE POSTGRESQL DATABASE # BACKUP THE POSTGRESQL DATABASE
#================================================= #=================================================
ynh_print_info "Backing up the PostgreSQL database..." ynh_print_info --message="Backing up the PostgreSQL database..."
ynh_psql_dump_db "$db_name" > db.sql ynh_psql_dump_db --database="$db_name" > db.sql
#================================================= #=================================================
# SPECIFIC BACKUP # SPECIFIC BACKUP
#================================================= #=================================================
# BACKUP SYSTEMD # BACKUP SYSTEMD
#================================================= #=================================================
ynh_print_info "Backing up systemd configuration..." ynh_print_info --message="Backing up systemd configuration..."
ynh_backup "/etc/systemd/system/$app-beat.service" ynh_backup --src_path="/etc/systemd/system/$app-beat.service"
ynh_backup "/etc/systemd/system/$app-server.service" ynh_backup --src_path="/etc/systemd/system/$app-server.service"
ynh_backup "/etc/systemd/system/$app-worker.service" ynh_backup --src_path="/etc/systemd/system/$app-worker.service"
ynh_backup "/etc/systemd/system/$app.target" ynh_backup --src_path="/etc/systemd/system/$app.target"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_print_info "Backup script completed for $app. (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

@ -33,55 +33,55 @@ app=$YNH_APP_INSTANCE_NAME
#================================================= #=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#================================================= #=================================================
ynh_print_info "Validating installation parameters..." ynh_print_info --message="Validating installation parameters..."
final_path="/var/www/$app" 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 # Register (book) web path
ynh_webpath_register "$app" "$domain" "$path_url" ynh_webpath_register --app="$app" --domain="$domain" --path_url="$path_url"
#================================================= #=================================================
# STORE SETTINGS FROM MANIFEST # STORE SETTINGS FROM MANIFEST
#================================================= #=================================================
ynh_print_info "Storing installation settings..." ynh_print_info --message="Storing installation settings..."
ynh_app_setting_set "$app" domain "$domain" ynh_app_setting_set --app="$app" --key=domain --value="$domain"
ynh_app_setting_set "$app" path "$path_url" ynh_app_setting_set --app="$app" --key=path --value="$path_url"
ynh_app_setting_set "$app" is_public "$is_public" ynh_app_setting_set --app="$app" --key=is_public --value="$is_public"
ynh_app_setting_set "$app" admin "$admin" ynh_app_setting_set --app="$app" --key=admin --value="$admin"
#================================================= #=================================================
# STANDARD MODIFICATIONS # STANDARD MODIFICATIONS
#================================================= #=================================================
# FIND AND OPEN A PORT # FIND AND OPEN A PORT
#================================================= #=================================================
ynh_print_info "Configuring firewall..." ynh_print_info --message="Configuring firewall..."
# Find a free port # Find a free port
port=$(ynh_find_port 5000) port=$(ynh_find_port --port=5000)
# Open this port # Open this port
ynh_app_setting_set "$app" port "$port" ynh_app_setting_set --app="$app" --key=port --value="$port"
#================================================= #=================================================
# INSTALL DEPENDENCIES # INSTALL DEPENDENCIES
#================================================= #=================================================
ynh_print_info "Installing dependencies..." ynh_print_info --message="Installing dependencies..."
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# CREATE A POSTGRESQL DATABASE # CREATE A POSTGRESQL DATABASE
#================================================= #=================================================
ynh_print_info "Creating a PostgreSQL database..." ynh_print_info --message="Creating a PostgreSQL database..."
ynh_psql_test_if_first_run ynh_psql_test_if_first_run
db_name=$(ynh_sanitize_dbid "$app") db_name=$(ynh_sanitize_dbid "$app")
db_user=$db_name db_user="$db_name"
db_pwd=$(ynh_string_random) db_pwd=$(ynh_string_random)
ynh_app_setting_set "$app" db_name "$db_name" ynh_app_setting_set --app="$app" --key=db_name --value="$db_name"
ynh_app_setting_set "$app" psqlpwd "$db_pwd" ynh_app_setting_set --app="$app" --key=psqlpwd --value="$db_pwd"
# Initialize database and store postgres password for upgrade # Initialize database and store postgres password for upgrade
ynh_psql_setup_db --db_name="$db_name" --db_user="$db_user" --db_pwd="$db_pwd" ynh_psql_setup_db --db_name="$db_name" --db_user="$db_user" --db_pwd="$db_pwd"
@ -89,12 +89,12 @@ ynh_psql_setup_db --db_name="$db_name" --db_user="$db_user" --db_pwd="$db_pwd"
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_print_info "Setting up source files..." ynh_print_info --message="Setting up source files..."
ynh_app_setting_set "$app" final_path "$final_path" ynh_app_setting_set --app="$app" --key=final_path --value="$final_path"
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source "$final_path/code" ynh_setup_source --dest_dir="$final_path/code"
ynh_setup_source "$final_path/code" "app-frontend" ynh_setup_source --dest_dir="$final_path/code" --source_id="app-frontend"
( (
cd "$final_path" cd "$final_path"
@ -104,7 +104,7 @@ ynh_setup_source "$final_path/code" "app-frontend"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
ynh_print_info "Configuring nginx web server..." ynh_print_info --message="Configuring nginx web server..."
# add funkwhale specifics at the beginning of the domain configuration # add funkwhale specifics at the beginning of the domain configuration
funkwhale_nginx_domain_configure funkwhale_nginx_domain_configure
@ -115,10 +115,10 @@ ynh_add_nginx_config
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
ynh_print_info "Configuring system user..." ynh_print_info --message="Configuring system user..."
# Create a system user # Create a system user
ynh_system_user_create "$app" "$final_path" ynh_system_user_create --username="$app" --home_dir="$final_path"
#================================================= #=================================================
# SPECIFIC SETUP # SPECIFIC SETUP
@ -148,17 +148,17 @@ cp ../conf/env.prod "$configfile"
key=$(ynh_string_random) key=$(ynh_string_random)
redis_db=$(ynh_redis_get_free_db) redis_db=$(ynh_redis_get_free_db)
ynh_app_setting_set "$app" key "$key" ynh_app_setting_set --app="$app" --key=key --value="$key"
ynh_app_setting_set "$app" redis_db "$redis_db" ynh_app_setting_set --app="$app" --key=redis_db --value="$redis_db"
ynh_replace_string "__REDIS_DB__" "$redis_db" "$configfile" ynh_replace_string --match_string="__REDIS_DB__" --replace_string="$redis_db" --target_file="$configfile"
ynh_replace_string "__PORT__" "$port" "$configfile" ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$configfile"
ynh_replace_string "__DOMAIN__" "$domain" "$configfile" ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$configfile"
ynh_replace_string "__DBUSER__" "$db_name" "$configfile" ynh_replace_string --match_string="__DBUSER__" --replace_string="$db_name" --target_file="$configfile"
ynh_replace_string "__DBPWD__" "$db_pwd" "$configfile" ynh_replace_string --match_string="__DBPWD__" --replace_string="$db_pwd" --target_file="$configfile"
ynh_replace_string "__DBNAME__" "$app" "$configfile" ynh_replace_string --match_string="__DBNAME__" --replace_string="$app" --target_file="$configfile"
ynh_replace_string "__FINALPATH__" "$final_path" "$configfile" ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$configfile"
ynh_replace_string "__KEY__" "$key" "$configfile" ynh_replace_string --match_string="__KEY__" --replace_string="$key" --target_file="$configfile"
loadfile="$final_path/code/load_env" loadfile="$final_path/code/load_env"
@ -169,13 +169,13 @@ EOL
chmod +x "$loadfile" chmod +x "$loadfile"
ynh_replace_string "__FINALPATH__" "$final_path" "$loadfile" ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$loadfile"
#================================================= #=================================================
# CONFIGURE ADMIN USER # CONFIGURE ADMIN USER
#================================================= #=================================================
admin_mail=$(ynh_user_get_info "$admin" "mail") admin_mail=$(ynh_user_get_info --username="$admin" --key="mail")
( (
set +o nounset set +o nounset
source "${final_path}/code/virtualenv/bin/activate" source "${final_path}/code/virtualenv/bin/activate"
@ -194,14 +194,15 @@ admin_mail=$(ynh_user_get_info "$admin" "mail")
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
#================================================= #=================================================
ynh_print_info "Configuring a systemd service..." ynh_print_info --message="Configuring a systemd service..."
cp ../conf/funkwhale.target "/etc/systemd/system/$app.target" cp ../conf/funkwhale.target "/etc/systemd/system/$app.target"
ynh_replace_string "__APP__" "$app" "/etc/systemd/system/$app.target" ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="/etc/systemd/system/$app.target"
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_add_systemd_config "$app-server" "funkwhale-server.service" ynh_add_systemd_config --service="$app-server" --template="funkwhale-server.service"
ynh_add_systemd_config "$app-worker" "funkwhale-worker.service" ynh_add_systemd_config --service="$app-worker" --template="funkwhale-worker.service"
ynh_add_systemd_config "$app-beat" "funkwhale-beat.service" ynh_add_systemd_config --service="$app-beat" --template="funkwhale-beat.service"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
@ -215,12 +216,6 @@ chmod -R 755 "$final_path/code/front/dist/"
mkdir -p "/var/log/$app" mkdir -p "/var/log/$app"
chown -R "$app": "/var/log/$app" chown -R "$app": "/var/log/$app"
#=================================================
# SETUP FAIL2BAN
#=================================================
ynh_add_fail2ban_config "/var/log/nginx/$domain-access.log" "<HOST>.* \"POST /api/v1/token/ HTTP/1.1\" 400 68.*$" 5
#================================================= #=================================================
# ADVERTISE SERVICE IN ADMIN PANEL # ADVERTISE SERVICE IN ADMIN PANEL
#================================================= #=================================================
@ -229,36 +224,44 @@ yunohost service add "$app-server" --log "/var/log/$app/server.log"
yunohost service add "$app-worker" --log "/var/log/$app/worker.log" yunohost service add "$app-worker" --log "/var/log/$app/worker.log"
yunohost service add "$app-beat" --log "/var/log/$app/beat.log" yunohost service add "$app-beat" --log "/var/log/$app/beat.log"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_print_info --message="Starting a systemd service..."
ynh_systemd_action --action="start" --service_name="${app}-beat" --log_path="systemd" --line_match="celery beat process"
ynh_systemd_action --action="start" --service_name="${app}-server" --log_path="systemd" --line_match="Listening on TCP address"
ynh_systemd_action --action="start" --service_name="${app}-worker" --log_path="systemd" --line_match="celery worker"
#=================================================
# SETUP FAIL2BAN
#=================================================
ynh_print_info --message="Configuring fail2ban..."
# Create a dedicated fail2ban config
ynh_add_fail2ban_config --logpath="/var/log/nginx/$domain-access.log" --failregex="<HOST>.* \"POST /api/v1/token/ HTTP/1.1\" 400 68.*$" --max_retry=5
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
#================================================= #=================================================
ynh_print_info "Configuring SSOwat..." ynh_print_info --message="Configuring SSOwat..."
# Make app public if necessary # Make app public if necessary
if [ "$is_public" -eq 1 ] if [ "$is_public" -eq 1 ]
then then
# makes sure no SSO credentials to be passed # makes sure no SSO credentials to be passed
ynh_app_setting_set "$app" skipped_uris "/" ynh_app_setting_set --app="$app" --key=skipped_uris --value="/"
fi fi
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_print_info "Reloading nginx web server..." ynh_print_info --message="Reloading nginx web server..."
systemctl reload nginx ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# START SERVICES
#=================================================
ynh_print_info "Start Services..."
ynh_systemd_action --action=start --service_name=${app}-beat --log_path=systemd --line_match="celery beat process"
ynh_systemd_action --action=start --service_name=${app}-server --log_path=systemd --line_match="Listening on TCP address"
ynh_systemd_action --action=start --service_name=${app}-worker --log_path=systemd --line_match="celery worker"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_print_info "Installation of $app completed" ynh_print_info --message="Installation of $app completed"

View file

@ -12,16 +12,16 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_print_info "Loading installation settings..." ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain) domain=$(ynh_app_setting_get --app="$app" --key=domain)
port=$(ynh_app_setting_get $app port) port=$(ynh_app_setting_get --app="$app" --key=port)
db_name=$(ynh_app_setting_get $app db_name) db_name=$(ynh_app_setting_get --app="$app" --key=db_name)
db_user=$db_name db_user="$db_name"
final_path=$(ynh_app_setting_get $app final_path) final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
redis_db=$(ynh_app_setting_get $app redis_db) redis_db=$(ynh_app_setting_get --app="$app" --key=redis_db)
#================================================= #=================================================
# STANDARD REMOVE # STANDARD REMOVE
@ -32,53 +32,50 @@ redis_db=$(ynh_app_setting_get $app redis_db)
# Remove a service from the admin panel, added by `yunohost service add` # Remove a service from the admin panel, added by `yunohost service add`
if yunohost service status "$app-server" >/dev/null 2>&1 if yunohost service status "$app-server" >/dev/null 2>&1
then then
echo "Remove $app-server service" ynh_print_info --message="Remove $app-server service"
yunohost service remove "$app-server" yunohost service remove "$app-server"
fi fi
if yunohost service status "$app-worker" >/dev/null 2>&1 if yunohost service status "$app-worker" >/dev/null 2>&1
then then
echo "Remove $app-worker service" ynh_print_info --message="Remove $app-worker service"
yunohost service remove "$app-worker" yunohost service remove "$app-worker"
fi fi
if yunohost service status "$app-beat" >/dev/null 2>&1 if yunohost service status "$app-beat" >/dev/null 2>&1
then then
echo "Remove $app-beat service" ynh_print_info --message="Remove $app-beat service"
yunohost service remove "$app-beat" yunohost service remove "$app-beat"
fi fi
#================================================= #=================================================
# STOP AND REMOVE SERVICE # STOP AND REMOVE SERVICE
#================================================= #=================================================
ynh_print_info "Stopping and removing the systemd service" ynh_print_info --message="Stopping and removing the systemd service"
ynh_systemd_action --action=stop --service_name=${app}-beat --log_path=systemd --line_match="Stopped Funkwhale" ynh_systemd_action --action="stop" --service_name="${app}-beat" --log_path="systemd" --line_match="Stopped Funkwhale"
ynh_systemd_action --action=stop --service_name=${app}-server --log_path=systemd --line_match="Stopped Funkwhale" ynh_systemd_action --action="stop" --service_name="${app}-server" --log_path="systemd" --line_match="Stopped Funkwhale"
ynh_systemd_action --action=stop --service_name=${app}-worker --log_path=systemd --line_match="Stopped Funkwhale" ynh_systemd_action --action="stop" --service_name="${app}-worker" --log_path="systemd" --line_match="Stopped Funkwhale"
# Remove the dedicated systemd config # Remove the dedicated systemd config
ynh_remove_systemd_config "$app-server" ynh_remove_systemd_config --service="$app-server"
ynh_remove_systemd_config "$app-worker" ynh_remove_systemd_config --service="$app-worker"
ynh_remove_systemd_config "$app-beat" ynh_remove_systemd_config --service="$app-beat"
ynh_secure_remove "/etc/systemd/system/$app.target" ynh_secure_remove --file="/etc/systemd/system/$app.target"
#================================================= #=================================================
# REMOVE THE POSTGRESQL DATABASE # REMOVE THE POSTGRESQL DATABASE
#================================================= #=================================================
ynh_print_info "Removing the PostgreSQL database" ynh_print_info --message="Removing the PostgreSQL database"
ynh_psql_execute_as_root "\connect $db_name
SELECT pg_terminate_backend (pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = '$db_name';"
# 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_name="$db_name" --db_user="$app" ynh_psql_remove_db --db_name="$db_name" --db_user="$db_user"
#================================================= #=================================================
# REMOVE THE REDIS DATABASE # REMOVE THE REDIS DATABASE
#================================================= #=================================================
ynh_print_info "Removing the Redis database" ynh_print_info --message="Removing the Redis database"
# Remove a database if it exists, along with the associated user # Remove a database if it exists, along with the associated user
ynh_redis_remove_db "$redis_db" ynh_redis_remove_db "$redis_db"
@ -86,7 +83,7 @@ ynh_redis_remove_db "$redis_db"
#================================================= #=================================================
# REMOVE DEPENDENCIES # REMOVE DEPENDENCIES
#================================================= #=================================================
ynh_print_info "Removing dependencies" ynh_print_info --message="Removing dependencies"
# Remove metapackage and its dependencies # Remove metapackage and its dependencies
ynh_remove_app_dependencies ynh_remove_app_dependencies
@ -94,17 +91,17 @@ ynh_remove_app_dependencies
#================================================= #=================================================
# REMOVE APP MAIN DIR # REMOVE APP MAIN DIR
#================================================= #=================================================
ynh_print_info "Removing app main directory" ynh_print_info --message="Removing app main directory"
# Remove the app directory securely # Remove the app directory securely
ynh_secure_remove "$final_path" ynh_secure_remove --file="$final_path"
ynh_secure_remove "/var/log/$app" ynh_secure_remove --file="/var/log/$app"
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # REMOVE NGINX CONFIGURATION
#================================================= #=================================================
ynh_print_info "Removing nginx web server configuration" ynh_print_info --message="Removing nginx web server configuration"
# remove domain specific configuration # remove domain specific configuration
funkwhale_nginx_domain_cleaning funkwhale_nginx_domain_cleaning
@ -118,28 +115,29 @@ ynh_remove_nginx_config
if yunohost firewall list | grep -q "\- $port$" if yunohost firewall list | grep -q "\- $port$"
then then
ynh_print_info "Closing port $port" ynh_print_info --message="Closing port $port"
ynh_exec_warn_less yunohost firewall disallow TCP $port ynh_exec_warn_less yunohost firewall disallow TCP $port
fi fi
#=================================================
# GENERIC FINALIZATION
#================================================= #=================================================
# REMOVE FAIL2BAN CONFIGURATION # REMOVE FAIL2BAN CONFIGURATION
#================================================= #=================================================
ynh_print_info --message="Removing fail2ban configuration..."
ynh_remove_fail2ban_config ynh_remove_fail2ban_config
#=================================================
# GENERIC FINALIZATION
#================================================= #=================================================
# REMOVE DEDICATED USER # REMOVE DEDICATED USER
#================================================= #=================================================
ynh_print_info "Removing the dedicated system user" ynh_print_info --message="Removing the dedicated system user"
# Delete a system user # Delete a system user
ynh_system_user_delete "$app" ynh_system_user_delete --username="$app"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_print_info "Removal of $app completed" ynh_print_info --message="Removal of $app completed"

View file

@ -23,26 +23,26 @@ ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_print_info "Loading settings..." ynh_print_info --message="Loading settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get "$app" domain) domain=$(ynh_app_setting_get --app="$app" --key=domain)
path_url=$(ynh_app_setting_get "$app" path) path_url=$(ynh_app_setting_get --app="$app" --key=path)
final_path=$(ynh_app_setting_get "$app" final_path) final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
db_name=$(ynh_app_setting_get "$app" db_name) db_name=$(ynh_app_setting_get --app="$app" --key=db_name)
db_user=$db_name db_user="$db_name"
db_pwd=$(ynh_app_setting_get "$app" psqlpwd) db_pwd=$(ynh_app_setting_get --app="$app" --key=psqlpwd)
#================================================= #=================================================
# CHECK IF THE APP CAN BE RESTORED # CHECK IF THE APP CAN BE RESTORED
#================================================= #=================================================
ynh_print_info "Validating restoration parameters..." ynh_print_info --message="Validating restoration parameters..."
ynh_webpath_available "$domain" "$path_url" \ ynh_webpath_available -domain="$domain" --path_url="$path_url" \
|| ynh_die "Path not available: ${domain}${path_url}" || ynh_die --message="Path not available: ${domain}${path_url}"
test ! -d "$final_path" \ test ! -d "$final_path" \
|| ynh_die "There is already a directory: $final_path " || ynh_die --message="There is already a directory: $final_path "
#================================================= #=================================================
# STANDARD RESTORATION STEPS # STANDARD RESTORATION STEPS
@ -50,28 +50,28 @@ test ! -d "$final_path" \
# RESTORE THE NGINX CONFIGURATION # RESTORE THE NGINX CONFIGURATION
#================================================= #=================================================
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore_file "/etc/nginx/conf.d/$domain.conf" ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.conf"
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # RESTORE THE APP MAIN DIR
#================================================= #=================================================
ynh_print_info "Restoring the app main directory..." ynh_print_info --message="Restoring the app main directory..."
backup_core_only=$(ynh_app_setting_get "$app" backup_core_only) backup_core_only=$(ynh_app_setting_get --app="$app" --key=backup_core_only)
# If backup_core_only have any value, then restore only code # If backup_core_only have any value, then restore only code
if [ -z "$backup_core_only" ] if [ -z "$backup_core_only" ]
then then
ynh_restore_file "$final_path/code" ynh_restore_file --origin_path="$final_path/code"
else else
ynh_restore_file "$final_path" ynh_restore_file --origin_path="$final_path"
fi fi
# Remove the option backup_core_only if it's in the settings.yml file # Remove the option backup_core_only if it's in the settings.yml file
ynh_app_setting_delete "$app" backup_core_only ynh_app_setting_delete --app="$app" --key=backup_core_only
code_migration=$(ynh_app_setting_get "$app" code_migration) code_migration=$(ynh_app_setting_get --app="$app" --key=code_migration)
# make sure we revert the last code organization # make sure we revert the last code organization
if [ "$code_migration" -eq 1 ] if [ "$code_migration" -eq 1 ]
@ -79,17 +79,17 @@ then
mv "$final_path/code/"* "$final_path" mv "$final_path/code/"* "$final_path"
mv "$final_path/media" "$final_path/code/data/media" mv "$final_path/media" "$final_path/code/data/media"
mv "$final_path/import" "$final_path/code/data/music" mv "$final_path/import" "$final_path/code/data/music"
ynh_secure_remove "$final_path/code" ynh_secure_remove --file="$final_path/code"
ynh_app_setting_delete "$app" code_migration ynh_app_setting_delete --app="$app" --key=code_migration
fi fi
#================================================= #=================================================
# RECREATE THE DEDICATED USER # RECREATE THE DEDICATED USER
#================================================= #=================================================
ynh_print_info "Recreating the dedicated system user..." ynh_print_info --message="Recreating the dedicated system user..."
# Create the dedicated user (if not existing) # Create the dedicated user (if not existing)
ynh_system_user_create "$app" ynh_system_user_create --username="$app" --home_dir="$final_path"
#================================================= #=================================================
# RESTORE USER RIGHTS # RESTORE USER RIGHTS
@ -107,7 +107,7 @@ chown -R "$app": "/var/log/$app"
#================================================= #=================================================
# REINSTALL DEPENDENCIES # REINSTALL DEPENDENCIES
#================================================= #=================================================
ynh_print_info "Reinstalling dependencies..." ynh_print_info --message="Reinstalling dependencies..."
# Define and install dependencies # Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
@ -115,7 +115,7 @@ ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# RESTORE THE POSTGRESQL DATABASE # RESTORE THE POSTGRESQL DATABASE
#================================================= #=================================================
ynh_print_info "Restoring the PostgreSQL database..." ynh_print_info --message="Restoring the PostgreSQL database..."
ynh_psql_test_if_first_run ynh_psql_test_if_first_run
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"
@ -124,12 +124,12 @@ ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name"
#================================================= #=================================================
# RESTORE SYSTEMD # RESTORE SYSTEMD
#================================================= #=================================================
ynh_print_info "Restoring the systemd configuration..." ynh_print_info --message="Restoring the systemd configuration..."
ynh_restore_file "/etc/systemd/system/$app-beat.service" ynh_restore_file --origin_path="/etc/systemd/system/$app-beat.service"
ynh_restore_file "/etc/systemd/system/$app-server.service" ynh_restore_file --origin_path="/etc/systemd/system/$app-server.service"
ynh_restore_file "/etc/systemd/system/$app-worker.service" ynh_restore_file --origin_path="/etc/systemd/system/$app-worker.service"
ynh_restore_file "/etc/systemd/system/$app.target" ynh_restore_file --origin_path="/etc/systemd/system/$app.target"
systemctl enable "$app-beat.service" systemctl enable "$app-beat.service"
systemctl enable "$app-server.service" systemctl enable "$app-server.service"
@ -143,26 +143,26 @@ yunohost service add "$app-server" --log "/var/log/$app/server.log"
yunohost service add "$app-worker" --log "/var/log/$app/worker.log" yunohost service add "$app-worker" --log "/var/log/$app/worker.log"
yunohost service add "$app-beat" --log "/var/log/$app/beat.log" yunohost service add "$app-beat" --log "/var/log/$app/beat.log"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_print_info --message="Starting a systemd service..."
ynh_systemd_action --action="start" --service_name="${app}-beat" --log_path="systemd" --line_match="celery beat process"
ynh_systemd_action --action="start" --service_name="${app}-server" --log_path="systemd" --line_match="Listening on TCP address"
ynh_systemd_action --action="start" --service_name="${app}-worker" --log_path="systemd" --line_match="celery worker"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_print_info "Reloading nginx web server..." ynh_print_info --message="Reloading nginx web server..."
systemctl reload nginx ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# START SERVICES
#=================================================
ynh_print_info "Start Services..."
ynh_systemd_action --action=start --service_name=${app}-beat --log_path=systemd --line_match="celery beat process"
ynh_systemd_action --action=start --service_name=${app}-server --log_path=systemd --line_match="Listening on TCP address"
ynh_systemd_action --action=start --service_name=${app}-worker --log_path=systemd --line_match="celery worker"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_print_info "Restoration completed for $app" ynh_print_info --message="Restoration completed for $app"

View file

@ -12,30 +12,30 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_print_info "Loading installation settings..." ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get "$app" domain) domain=$(ynh_app_setting_get --app="$app" --key=domain)
path_url=$(ynh_app_setting_get "$app" path) path_url=$(ynh_app_setting_get --app="$app" --key=path)
is_public=$(ynh_app_setting_get "$app" is_public) is_public=$(ynh_app_setting_get --app="$app" --key=is_public)
final_path=$(ynh_app_setting_get "$app" final_path) final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
db_name=$(ynh_app_setting_get "$app" db_name) db_name=$(ynh_app_setting_get --app="$app" --key=db_name)
db_user=$db_name db_user="$db_name"
port=$(ynh_app_setting_get "$app" port) port=$(ynh_app_setting_get --app="$app" --key=port)
db_pwd=$(ynh_app_setting_get "$app" psqlpwd) db_pwd=$(ynh_app_setting_get --app="$app" --key=psqlpwd)
redis_db=$(ynh_app_setting_get "$app" redis_db) redis_db=$(ynh_app_setting_get --app="$app" --key=redis_db)
code_migration=$(ynh_app_setting_get "$app" code_migration) code_migration=$(ynh_app_setting_get --app="$app" --key=code_migration)
#================================================= #=================================================
# ENSURE DOWNWARD COMPATIBILITY # ENSURE DOWNWARD COMPATIBILITY
#================================================= #=================================================
ynh_print_info "Ensuring downward compatibility..." ynh_print_info --message="Ensuring downward compatibility..."
# If redis_db doesn't exist, create it # If redis_db doesn't exist, create it
if [ -z "$redis_db" ]; then if [ -z "$redis_db" ]; then
redis_db=0 redis_db=0
ynh_app_setting_set "$app" redis_db "$redis_db" ynh_app_setting_set --app="$app" --key=redis_db --value="$redis_db"
fi fi
# make sure we have the last code organization # make sure we have the last code organization
@ -48,17 +48,17 @@ if [ ! -d "$final_path/code/" ]; then
mv "$final_path-tmp/data/music" "$final_path/import" mv "$final_path-tmp/data/music" "$final_path/import"
mv "$final_path-tmp"/* "$final_path/code" mv "$final_path-tmp"/* "$final_path/code"
ynh_secure_remove "$final_path-tmp/" ynh_secure_remove --file="$final_path-tmp/"
ynh_app_setting_set "$app" code_migration 1 ynh_app_setting_set --app="$app" --key=code_migration --value=1
fi fi
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#================================================= #=================================================
ynh_print_info "Backing up the app before upgrading (may take a while)..." ynh_print_info --message="Backing up the app before upgrading (may take a while)..."
# Inform the backup/restore process that it should not save the data directory # Inform the backup/restore process that it should not save the data directory
ynh_app_setting_set "$app" backup_core_only 1 ynh_app_setting_set --app="$app" --key=backup_core_only --value=1
# Backup the current version of the app # Backup the current version of the app
ynh_backup_before_upgrade ynh_backup_before_upgrade
@ -70,15 +70,6 @@ ynh_clean_setup () {
# 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
#=================================================
# STOP SERVICES
#=================================================
ynh_print_info "Stopping $app services..."
ynh_systemd_action --action=stop --service_name=${app}-beat --log_path=systemd --line_match="Stopped Funkwhale"
ynh_systemd_action --action=stop --service_name=${app}-server --log_path=systemd --line_match="Stopped Funkwhale"
ynh_systemd_action --action=stop --service_name=${app}-worker --log_path=systemd --line_match="Stopped Funkwhale"
#================================================= #=================================================
# CHECK THE PATH # CHECK THE PATH
#================================================= #=================================================
@ -86,8 +77,6 @@ ynh_systemd_action --action=stop --service_name=${app}-worker --log_path=systemd
# Normalize the URL path syntax # Normalize the URL path syntax
path_url=$(ynh_normalize_url_path "$path_url") path_url=$(ynh_normalize_url_path "$path_url")
#=================================================
# STANDARD UPGRADE STEPS
#================================================= #=================================================
# CLOSE A PORT # CLOSE A PORT
#================================================= #=================================================
@ -98,15 +87,26 @@ then
yunohost firewall disallow TCP $port 2>&1 yunohost firewall disallow TCP $port 2>&1
fi fi
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_print_info --message="Stopping a systemd service..."
ynh_systemd_action --action="stop" --service_name="${app}-beat" --log_path="systemd" --line_match="Stopped Funkwhale"
ynh_systemd_action --action="stop" --service_name="${app}-server" --log_path="systemd" --line_match="Stopped Funkwhale"
ynh_systemd_action --action="stop" --service_name="${app}-worker" --log_path="systemd" --line_match="Stopped Funkwhale"
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_print_info "Upgrading source files..." ynh_print_info --message="Upgrading source files..."
ynh_app_setting_set "$app" final_path "$final_path" ynh_app_setting_set --app="$app" --key=final_path --value="$final_path"
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source "$final_path/code" ynh_setup_source --dest_dir="$final_path/code"
ynh_setup_source "$final_path/code" "app-frontend" ynh_setup_source --dest_dir="$final_path/code" --source_id="app-frontend"
( (
cd "$final_path" cd "$final_path"
@ -116,7 +116,7 @@ ynh_setup_source "$final_path/code" "app-frontend"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
ynh_print_info "Upgrading nginx web server configuration..." ynh_print_info --message="Upgrading nginx web server configuration..."
# remove domain specific configuration # remove domain specific configuration
funkwhale_nginx_domain_cleaning funkwhale_nginx_domain_cleaning
@ -130,17 +130,17 @@ ynh_add_nginx_config
#================================================= #=================================================
# UPGRADE DEPENDENCIES # UPGRADE DEPENDENCIES
#================================================= #=================================================
ynh_print_info "Upgrading dependencies..." ynh_print_info --message="Upgrading dependencies..."
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
ynh_print_info "Making sure dedicated system user exists..." ynh_print_info --message="Making sure dedicated system user exists..."
# Create a dedicated user (if not existing) # Create a dedicated user (if not existing)
ynh_system_user_create "$app" ynh_system_user_create --username="$app" --home_dir="$final_path"
#================================================= #=================================================
# SPECIFIC UPGRADE # SPECIFIC UPGRADE
@ -148,7 +148,7 @@ ynh_system_user_create "$app"
# PYTHON DEPENDENCIES # PYTHON DEPENDENCIES
#================================================= #=================================================
ynh_secure_remove "$final_path/code/virtualenv" ynh_secure_remove --file="$final_path/code/virtualenv"
virtualenv -p python3 "$final_path/code/virtualenv" virtualenv -p python3 "$final_path/code/virtualenv"
( (
set +o nounset set +o nounset
@ -173,16 +173,16 @@ cp ../conf/env.prod "$configfile"
key=$(ynh_string_random) key=$(ynh_string_random)
ynh_app_setting_set "$app" key "$key" ynh_app_setting_set --app="$app" --key=key --value="$key"
ynh_replace_string "__REDIS_DB__" "$redis_db" "$configfile" ynh_replace_string --match_string="__REDIS_DB__" --replace_string="$redis_db" --target_file="$configfile"
ynh_replace_string "__PORT__" "$port" "$configfile" ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$configfile"
ynh_replace_string "__DOMAIN__" "$domain" "$configfile" ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$configfile"
ynh_replace_string "__DBUSER__" "$db_name" "$configfile" ynh_replace_string --match_string="__DBUSER__" --replace_string="$db_name" --target_file="$configfile"
ynh_replace_string "__DBPWD__" "$db_pwd" "$configfile" ynh_replace_string --match_string="__DBPWD__" --replace_string="$db_pwd" --target_file="$configfile"
ynh_replace_string "__DBNAME__" "$app" "$configfile" ynh_replace_string --match_string="__DBNAME__" --replace_string="$app" --target_file="$configfile"
ynh_replace_string "__FINALPATH__" "$final_path" "$configfile" ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$configfile"
ynh_replace_string "__KEY__" "$key" "$configfile" ynh_replace_string --match_string="__KEY__" --replace_string="$key" --target_file="$configfile"
loadfile="$final_path/code/load_env" loadfile="$final_path/code/load_env"
@ -193,7 +193,7 @@ EOL
chmod +x "$loadfile" chmod +x "$loadfile"
ynh_replace_string "__FINALPATH__" "$final_path" "$loadfile" ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$loadfile"
#================================================= #=================================================
# MIGRATE # MIGRATE
@ -229,18 +229,25 @@ ynh_replace_string "__FINALPATH__" "$final_path" "$loadfile"
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
#================================================= #=================================================
ynh_print_info "Upgrading systemd configuration..." ynh_print_info --message="Upgrading systemd configuration..."
cp ../conf/funkwhale.target "/etc/systemd/system/$app.target" cp ../conf/funkwhale.target "/etc/systemd/system/$app.target"
ynh_replace_string "__APP__" "$app" "/etc/systemd/system/$app.target" ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="/etc/systemd/system/$app.target"
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_add_systemd_config "$app-server" "funkwhale-server.service" ynh_add_systemd_config --service="$app-server" --template="funkwhale-server.service"
ynh_add_systemd_config "$app-worker" "funkwhale-worker.service" ynh_add_systemd_config --service="$app-worker" --template="funkwhale-worker.service"
ynh_add_systemd_config "$app-beat" "funkwhale-beat.service" ynh_add_systemd_config --service="$app-beat" --template="funkwhale-beat.service"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#=================================================
# UPGRADE FAIL2BAN
#=================================================
ynh_print_info --message="Reconfiguring fail2ban..."
ynh_add_fail2ban_config --logpath="/var/log/nginx/$domain-access.log" --failregex="<HOST>.* \"POST /api/v1/token/ HTTP/1.1\" 400 68.*$" --max_retry=5
#================================================= #=================================================
# SECURE FILES AND DIRECTORIES # SECURE FILES AND DIRECTORIES
#================================================= #=================================================
@ -251,48 +258,42 @@ chmod -R 755 "$final_path/code/front/dist/"
mkdir -p "/var/log/$app" mkdir -p "/var/log/$app"
chown -R "$app": "/var/log/$app" chown -R "$app": "/var/log/$app"
#=================================================
# SETUP FAIL2BAN
#=================================================
ynh_add_fail2ban_config "/var/log/nginx/$domain-access.log" "<HOST>.* \"POST /api/v1/token/ HTTP/1.1\" 400 68.*$" 5
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
#================================================= #=================================================
ynh_print_info "Upgrading SSOwat configuration..." ynh_print_info --message="Upgrading SSOwat configuration..."
# Make app public if necessary # Make app public if necessary
if [ "$is_public" -eq 1 ] if [ "$is_public" -eq 1 ]
then then
# makes sure no SSO credentials to be passed # makes sure no SSO credentials to be passed
ynh_app_setting_set "$app" skipped_uris "/" ynh_app_setting_set --app="$app" --key=skipped_uris --value="/"
fi fi
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_print_info --message="Starting a systemd service..."
ynh_systemd_action --action="start" --service_name="${app}-beat" --log_path="systemd" --line_match="celery beat process"
ynh_systemd_action --action="start" --service_name="${app}-server" --log_path="systemd" --line_match="Listening on TCP address"
ynh_systemd_action --action="start" --service_name="${app}-worker" --log_path="systemd" --line_match="celery worker"
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_print_info "Reloading nginx web server..." ynh_print_info --message="Reloading nginx web server..."
systemctl reload nginx ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# REMOVE CODE MIGRATION FLAG # REMOVE CODE MIGRATION FLAG
#================================================= #=================================================
ynh_app_setting_set "$app" code_migration 2 ynh_app_setting_set --app="$app" --key=code_migration --value=2
#=================================================
# START SERVICES
#=================================================
ynh_print_info "Start Services..."
ynh_systemd_action --action=start --service_name=${app}-beat --log_path=systemd --line_match="celery beat process"
ynh_systemd_action --action=start --service_name=${app}-server --log_path=systemd --line_match="Listening on TCP address"
ynh_systemd_action --action=start --service_name=${app}-worker --log_path=systemd --line_match="celery worker"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_print_info "Upgrade of $app completed" ynh_print_info --message="Upgrade of $app completed"