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-04-03 14:35:09 +02:00
parent 1fad5efe54
commit e330727bd1
8 changed files with 164 additions and 62 deletions

View file

@ -1,13 +1,22 @@
# Funkwhale # Funkwhale
A modern, convivial and free music server on YunoHost
[![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.
If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.*
## Overview
A modern, convivial and free music server on YunoHost
Installation requires a dedicated domain for now. I hope subpath installation will be possible in the future. Installation requires a dedicated domain for now. I hope subpath installation will be possible in the future.
**Shipped version:** 0.18.2 (this is an Alpha version!) **Shipped version:** 0.18.2 (this is an Alpha version!)
## Screenshots
![](https://funkwhale.audio/assets/images/home-overlay.jpg)
## Admin ## Admin
The admin uses the login you provided at installation. The password is the same you use for YunoHost. The admin uses the login you provided at installation. The password is the same you use for YunoHost.
@ -31,6 +40,14 @@ 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
## YunoHost specific features
#### 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/)
* 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/)
* 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/)
## 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
@ -38,3 +55,18 @@ The admin interface is accessible with the address: your.domain.fr/api/admin
* Documentation: https://docs.funkwhale.audio * Documentation: https://docs.funkwhale.audio
* Funkwhale website: https://funkwhale.audio/ * Funkwhale website: https://funkwhale.audio/
* YunoHost website: https://yunohost.org/ * YunoHost website: https://yunohost.org/
---
Developers info
----------------
**Only if you want to use a testing branch for coding, instead of merging directly into master.**
Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/funkwhale_ynh/tree/testing).
To try the testing branch, please proceed like that.
```
sudo yunohost app install https://github.com/YunoHost-Apps/funkwhale_ynh/tree/testing --debug
or
sudo yunohost app upgrade funkwhale -u https://github.com/YunoHost-Apps/funkwhale_ynh/tree/testing --debug
```

View file

@ -7,7 +7,7 @@
}, },
"version": "0.18.2~ynh1", "version": "0.18.2~ynh1",
"url": "https://funkwhale.audio", "url": "https://funkwhale.audio",
"license": "BSD-3-Clause", "license": "AGPL-3.0-or-later",
"maintainer": { "maintainer": {
"name": "Jean-Baptiste Holcroft", "name": "Jean-Baptiste Holcroft",
"email": "jean-baptiste@holcroft.fr" "email": "jean-baptiste@holcroft.fr"

View file

@ -1,5 +1,20 @@
#!/bin/bash #!/bin/bash
#=================================================
# COMMON VARIABLES
#=================================================
# dependencies used by the app
pkg_dependencies="build-essential curl ffmpeg \
libjpeg-dev libmagic-dev libpq-dev postgresql postgresql-contrib python3-dev virtualenv \
redis-server libldap2-dev libsasl2-dev \
`# add arm support` \
zlib1g-dev libffi-dev libssl-dev"
#=================================================
# PERSONAL HELPERS
#=================================================
# funkwhale needs edits to the domain config file # funkwhale needs edits to the domain config file
# this function removes funkwhale specifics # this function removes funkwhale specifics
funkwhale_nginx_domain_cleaning() { funkwhale_nginx_domain_cleaning() {
@ -35,6 +50,10 @@ map \$http_upgrade \$connection_upgrade {
mv "$tempFile" "$nginxConf" mv "$tempFile" "$nginxConf"
} }
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
#================================================= #=================================================
# #
# Redis HELPERS # Redis HELPERS
@ -208,4 +227,4 @@ ynh_remove_fail2ban_config () {
ynh_secure_remove "/etc/fail2ban/jail.d/$app.conf" ynh_secure_remove "/etc/fail2ban/jail.d/$app.conf"
ynh_secure_remove "/etc/fail2ban/filter.d/$app.conf" ynh_secure_remove "/etc/fail2ban/filter.d/$app.conf"
systemctl reload fail2ban systemctl reload fail2ban
} }

View file

@ -6,12 +6,8 @@
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
if [ ! -e _common.sh ]; then #Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
# Get the _common.sh file if it's not in the current directory source ../settings/scripts/_common.sh
cp ../settings/scripts/_common.sh ./_common.sh
chmod a+rx _common.sh
fi
source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
@ -24,6 +20,7 @@ ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_print_info "Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -37,6 +34,7 @@ db_name=$(ynh_app_setting_get "$app" db_name)
#================================================= #=================================================
# BACKUP THE APP MAIN DIR # BACKUP THE APP MAIN DIR
#================================================= #=================================================
ynh_print_info "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" 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
@ -51,13 +49,15 @@ fi
#================================================= #=================================================
# BACKUP THE NGINX CONFIGURATION # BACKUP THE NGINX CONFIGURATION
#================================================= #=================================================
ynh_print_info "Backing up nginx web server configuration..."
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup "/etc/nginx/conf.d/$domain.conf" ynh_backup "/etc/nginx/conf.d/$domain.conf"
#================================================= #=================================================
# BACKUP THE PostgreSQL DATABASE # BACKUP THE POSTGRESQL DATABASE
#================================================= #=================================================
ynh_print_info "Backing up the PostgreSQL database..."
ynh_psql_dump_db "$db_name" > db.sql ynh_psql_dump_db "$db_name" > db.sql
@ -66,8 +66,15 @@ ynh_psql_dump_db "$db_name" > db.sql
#================================================= #=================================================
# BACKUP SYSTEMD # BACKUP SYSTEMD
#================================================= #=================================================
ynh_print_info "Backing up systemd configuration..."
ynh_backup "/etc/systemd/system/$app-beat.service" ynh_backup "/etc/systemd/system/$app-beat.service"
ynh_backup "/etc/systemd/system/$app-server.service" ynh_backup "/etc/systemd/system/$app-server.service"
ynh_backup "/etc/systemd/system/$app-worker.service" ynh_backup "/etc/systemd/system/$app-worker.service"
ynh_backup "/etc/systemd/system/$app.target" ynh_backup "/etc/systemd/system/$app.target"
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -27,27 +27,21 @@ admin=$YNH_APP_ARG_ADMIN
app=$YNH_APP_INSTANCE_NAME 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..."
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 "This path already contains a folder"
# Normalize the url path syntax
path_url=$(ynh_normalize_url_path "$path_url")
test ! "$path_url" != "/" || ynh_die 'The path should be "/" for now...'
# Check web path availability
ynh_webpath_available "$domain" "$path_url"
# Register (book) web path # Register (book) web path
ynh_webpath_register "$app" "$domain" "$path_url" ynh_webpath_register "$app" "$domain" "$path_url"
#================================================= #=================================================
# STORE SETTINGS FROM MANIFEST # STORE SETTINGS FROM MANIFEST
#================================================= #=================================================
ynh_print_info "Storing installation settings..."
ynh_app_setting_set "$app" domain "$domain" ynh_app_setting_set "$app" domain "$domain"
ynh_app_setting_set "$app" path "$path_url" ynh_app_setting_set "$app" path "$path_url"
@ -59,6 +53,7 @@ ynh_app_setting_set "$app" admin "$admin"
#================================================= #=================================================
# FIND AND OPEN A PORT # FIND AND OPEN A PORT
#================================================= #=================================================
ynh_print_info "Configuring firewall..."
# Find a free port # Find a free port
port=$(ynh_find_port 5000) port=$(ynh_find_port 5000)
@ -68,16 +63,14 @@ ynh_app_setting_set "$app" port "$port"
#================================================= #=================================================
# INSTALL DEPENDENCIES # INSTALL DEPENDENCIES
#================================================= #=================================================
ynh_print_info "Installing dependencies..."
ynh_install_app_dependencies build-essential curl ffmpeg \ ynh_install_app_dependencies $pkg_dependencies
libjpeg-dev libmagic-dev libpq-dev postgresql postgresql-contrib python3-dev virtualenv \
redis-server libldap2-dev libsasl2-dev \
`# add arm support` \
zlib1g-dev libffi-dev libssl-dev
#================================================= #=================================================
# CREATE A PostgreSQL DATABASE # CREATE A POSTGRESQL DATABASE
#================================================= #=================================================
ynh_print_info "Creating a PostgreSQL database..."
ynh_psql_test_if_first_run ynh_psql_test_if_first_run
@ -95,6 +88,7 @@ systemctl reload postgresql
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_print_info "Setting up source files..."
ynh_app_setting_set "$app" final_path "$final_path" ynh_app_setting_set "$app" final_path "$final_path"
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
@ -109,6 +103,7 @@ ynh_setup_source "$final_path/code" "app-frontend"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
ynh_print_info "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
@ -119,6 +114,7 @@ ynh_add_nginx_config
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
ynh_print_info "Configuring system user..."
# Create a system user # Create a system user
ynh_system_user_create "$app" "$final_path" ynh_system_user_create "$app" "$final_path"
@ -175,7 +171,7 @@ chmod +x "$loadfile"
ynh_replace_string "__FINALPATH__" "$final_path" "$loadfile" ynh_replace_string "__FINALPATH__" "$final_path" "$loadfile"
#================================================= #=================================================
# MODIFY THE CONFIG FILE # CONFIGURE ADMIN USER
#================================================= #=================================================
admin_mail=$(ynh_user_get_info "$admin" "mail") admin_mail=$(ynh_user_get_info "$admin" "mail")
@ -197,7 +193,7 @@ admin_mail=$(ynh_user_get_info "$admin" "mail")
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
#================================================= #=================================================
ynh_print_info "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 "__APP__" "$app" "/etc/systemd/system/$app.target"
@ -238,6 +234,7 @@ yunohost service add "$app-beat" --log "/var/log/$app/beat.log"
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
#================================================= #=================================================
ynh_print_info "Configuring SSOwat..."
# Make app public if necessary # Make app public if necessary
if [ "$is_public" -eq 1 ] if [ "$is_public" -eq 1 ]
@ -249,6 +246,19 @@ fi
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_print_info "Reloading nginx web server..."
systemctl reload nginx
#=================================================
# START SERVICES
#=================================================
ynh_print_info "Start Services..."
systemctl start "$app-server" "$app-worker" "$app-beat" systemctl start "$app-server" "$app-worker" "$app-beat"
systemctl reload nginx
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Installation of $app completed"

View file

@ -12,14 +12,15 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_print_info "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 domain)
port=$(ynh_app_setting_get $app port)
db_name=$(ynh_app_setting_get $app db_name) db_name=$(ynh_app_setting_get $app 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 final_path)
port=$(ynh_app_setting_get $app port)
redis_db=$(ynh_app_setting_get $app redis_db) redis_db=$(ynh_app_setting_get $app redis_db)
#================================================= #=================================================
@ -29,19 +30,19 @@ 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 | grep -q "$app-server" if yunohost service status "$app-server" >/dev/null 2>&1
then then
echo "Remove $app-server service" echo "Remove $app-server service"
yunohost service remove "$app-server" yunohost service remove "$app-server"
fi fi
if yunohost service status | grep -q "$app-worker" if yunohost service status "$app-worker" >/dev/null 2>&1
then then
echo "Remove $app-worker service" echo "Remove $app-worker service"
yunohost service remove "$app-worker" yunohost service remove "$app-worker"
fi fi
if yunohost service status | grep -q "$app-beat" if yunohost service status "$app-beat" >/dev/null 2>&1
then then
echo "Remove $app-beat service" echo "Remove $app-beat service"
yunohost service remove "$app-beat" yunohost service remove "$app-beat"
@ -50,6 +51,7 @@ fi
#================================================= #=================================================
# STOP AND REMOVE SERVICE # STOP AND REMOVE SERVICE
#================================================= #=================================================
ynh_print_info "Stopping and removing the systemd service"
systemctl stop "$app".target systemctl stop "$app".target
@ -61,15 +63,17 @@ ynh_remove_systemd_config "$app-beat"
ynh_secure_remove "/etc/systemd/system/$app.target" ynh_secure_remove "/etc/systemd/system/$app.target"
#================================================= #=================================================
# REMOVE THE PostgreSQL DATABASE # REMOVE THE POSTGRESQL DATABASE
#================================================= #=================================================
ynh_print_info "Removing the PostgreSQL database"
# 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" "$app" ynh_psql_remove_db "$db_name" "$app"
#================================================= #=================================================
# REMOVE THE Redis DATABASE # REMOVE THE REDIS DATABASE
#================================================= #=================================================
ynh_print_info "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"
@ -77,6 +81,7 @@ ynh_redis_remove_db "$redis_db"
#================================================= #=================================================
# REMOVE DEPENDENCIES # REMOVE DEPENDENCIES
#================================================= #=================================================
ynh_print_info "Removing dependencies"
# Remove metapackage and its dependencies # Remove metapackage and its dependencies
ynh_remove_app_dependencies ynh_remove_app_dependencies
@ -84,6 +89,7 @@ ynh_remove_app_dependencies
#================================================= #=================================================
# REMOVE APP MAIN DIR # REMOVE APP MAIN DIR
#================================================= #=================================================
ynh_print_info "Removing app main directory"
# Remove the app directory securely # Remove the app directory securely
ynh_secure_remove "$final_path" ynh_secure_remove "$final_path"
@ -93,6 +99,7 @@ ynh_secure_remove "/var/log/$app"
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # REMOVE NGINX CONFIGURATION
#================================================= #=================================================
ynh_print_info "Removing nginx web server configuration"
# remove domain specific configuration # remove domain specific configuration
funkwhale_nginx_domain_cleaning funkwhale_nginx_domain_cleaning
@ -106,8 +113,8 @@ ynh_remove_nginx_config
if yunohost firewall list | grep -q "\- $port$" if yunohost firewall list | grep -q "\- $port$"
then then
echo "Close port $port" ynh_print_info "Closing port $port"
yunohost firewall disallow TCP $port 2>&1 ynh_exec_warn_less yunohost firewall disallow TCP $port
fi fi
#================================================= #=================================================
@ -121,6 +128,13 @@ ynh_remove_fail2ban_config
#================================================= #=================================================
# REMOVE DEDICATED USER # REMOVE DEDICATED USER
#================================================= #=================================================
ynh_print_info "Removing the dedicated system user"
# Delete a system user # Delete a system user
ynh_system_user_delete "$app" ynh_system_user_delete "$app"
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Removal of $app completed"

View file

@ -6,12 +6,8 @@
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
if [ ! -e _common.sh ]; then #Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
# Get the _common.sh file if it's not in the current directory source ../settings/scripts/_common.sh
cp ../settings/scripts/_common.sh ./_common.sh
chmod a+rx _common.sh
fi
source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
@ -24,6 +20,7 @@ ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_print_info "Loading settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -34,10 +31,10 @@ db_name=$(ynh_app_setting_get "$app" 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" psqlpwd)
#================================================= #=================================================
# CHECK IF THE APP CAN BE RESTORED # CHECK IF THE APP CAN BE RESTORED
#================================================= #=================================================
ynh_print_info "Validating restoration parameters..."
ynh_webpath_available "$domain" "$path_url" \ ynh_webpath_available "$domain" "$path_url" \
|| ynh_die "Path not available: ${domain}${path_url}" || ynh_die "Path not available: ${domain}${path_url}"
@ -56,6 +53,7 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.conf"
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # RESTORE THE APP MAIN DIR
#================================================= #=================================================
ynh_print_info "Restoring the app main directory..."
backup_core_only=$(ynh_app_setting_get "$app" backup_core_only) backup_core_only=$(ynh_app_setting_get "$app" backup_core_only)
@ -85,6 +83,7 @@ fi
#================================================= #=================================================
# RECREATE THE DEDICATED USER # RECREATE THE DEDICATED USER
#================================================= #=================================================
ynh_print_info "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 "$app"
@ -94,16 +93,14 @@ ynh_system_user_create "$app"
#================================================= #=================================================
# REINSTALL DEPENDENCIES # REINSTALL DEPENDENCIES
#================================================= #=================================================
ynh_print_info "Reinstalling dependencies..."
ynh_install_app_dependencies build-essential curl ffmpeg \ ynh_install_app_dependencies $pkg_dependencies
libjpeg-dev libmagic-dev libpq-dev postgresql postgresql-contrib python3-dev virtualenv \
redis-server libldap2-dev libsasl2-dev \
`# add arm support` \
zlib1g-dev libffi-dev libssl-dev
#================================================= #=================================================
# RESTORE THE PostgreSQL DATABASE # RESTORE THE POSTGRESQL DATABASE
#================================================= #=================================================
ynh_print_info "Restoring the PostgreSQL database..."
ynh_psql_test_if_first_run ynh_psql_test_if_first_run
ynh_psql_setup_db "$db_user" "$db_name" "$db_pwd" ynh_psql_setup_db "$db_user" "$db_name" "$db_pwd"
@ -123,6 +120,7 @@ chown -R "$app": "/var/log/$app"
#================================================= #=================================================
# RESTORE SYSTEMD # RESTORE SYSTEMD
#================================================= #=================================================
ynh_print_info "Restoring the systemd configuration..."
ynh_restore_file "/etc/systemd/system/$app-beat.service" ynh_restore_file "/etc/systemd/system/$app-beat.service"
ynh_restore_file "/etc/systemd/system/$app-server.service" ynh_restore_file "/etc/systemd/system/$app-server.service"
@ -145,7 +143,15 @@ yunohost service add "$app-beat" --log "/var/log/$app/beat.log"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================
# RELOAD NGINX AND PHP-FPM # RELOAD NGINX
#================================================= #=================================================
ynh_print_info "Reloading nginx web server..."
systemctl reload nginx systemctl reload nginx
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Restoration completed for $app"

View file

@ -12,6 +12,7 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_print_info "Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -29,6 +30,7 @@ code_migration=$(ynh_app_setting_get "$app" code_migration)
#================================================= #=================================================
# ENSURE DOWNWARD COMPATIBILITY # ENSURE DOWNWARD COMPATIBILITY
#================================================= #=================================================
ynh_print_info "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
@ -53,6 +55,7 @@ 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)..."
# 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" backup_core_only 1
@ -69,6 +72,7 @@ ynh_abort_if_errors
#================================================= #=================================================
# STOP SERVICES # STOP SERVICES
#================================================= #=================================================
ynh_print_info "Stopping $app services..."
systemctl stop "$app-beat.service" systemctl stop "$app-beat.service"
systemctl stop "$app-server.service" systemctl stop "$app-server.service"
@ -96,6 +100,7 @@ fi
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_print_info "Upgrading source files..."
ynh_app_setting_set "$app" final_path "$final_path" ynh_app_setting_set "$app" final_path "$final_path"
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
@ -110,6 +115,7 @@ ynh_setup_source "$final_path/code" "app-frontend"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
ynh_print_info "Upgrading nginx web server configuration..."
# remove domain specific configuration # remove domain specific configuration
funkwhale_nginx_domain_cleaning funkwhale_nginx_domain_cleaning
@ -120,23 +126,21 @@ funkwhale_nginx_domain_configure
# Create a dedicated nginx config # Create a dedicated nginx config
ynh_add_nginx_config ynh_add_nginx_config
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_print_info "Upgrading dependencies..."
ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
ynh_print_info "Making sure dedicated system user exists..."
# Create a system user # Create a system user
ynh_system_user_create "$app" ynh_system_user_create "$app"
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_install_app_dependencies build-essential curl ffmpeg \
libjpeg-dev libmagic-dev libpq-dev postgresql postgresql-contrib python3-dev virtualenv \
redis-server libldap2-dev libsasl2-dev \
`# add arm support` \
zlib1g-dev libffi-dev libssl-dev
#================================================= #=================================================
# SPECIFIC UPGRADE # SPECIFIC UPGRADE
#================================================= #=================================================
@ -224,6 +228,7 @@ ynh_replace_string "__FINALPATH__" "$final_path" "$loadfile"
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
#================================================= #=================================================
ynh_print_info "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 "__APP__" "$app" "/etc/systemd/system/$app.target"
@ -256,6 +261,7 @@ ynh_add_fail2ban_config "/var/log/nginx/$domain-access.log" "<HOST>.* \"POST /ap
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
#================================================= #=================================================
ynh_print_info "Upgrading SSOwat configuration..."
# Make app public if necessary # Make app public if necessary
if [ "$is_public" -eq 1 ] if [ "$is_public" -eq 1 ]
@ -267,6 +273,7 @@ fi
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_print_info "Upgrading SSOwat configuration..."
systemctl reload nginx systemctl reload nginx
@ -277,7 +284,14 @@ systemctl reload nginx
ynh_app_setting_set "$app" code_migration 2 ynh_app_setting_set "$app" code_migration 2
#================================================= #=================================================
# RESTART Funkwhale # START SERVICES
#================================================= #=================================================
ynh_print_info "Starting $app services..."
systemctl restart "$app.target" systemctl restart "$app.target"
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Upgrade of $app completed"