From 7ecb150a4361bedaf1dbbb764f5e3043396eb853 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Fri, 24 Mar 2023 12:21:19 +0100 Subject: [PATCH 01/30] v2 --- conf/api.src | 7 -- conf/env.prod | 12 +-- conf/front.src | 7 -- conf/funkwhale-beat.service | 6 +- conf/funkwhale-server.service | 6 +- conf/funkwhale-worker.service | 6 +- conf/nginx.conf | 16 ++-- manifest.toml | 69 ++++++++++++++ scripts/_common.sh | 2 +- scripts/backup | 20 ++--- scripts/change_url | 92 +++++++++---------- scripts/install | 122 ++++++++++++------------- scripts/remove | 36 ++++---- scripts/restore | 62 ++++++------- scripts/upgrade | 164 +++++++++++++++++----------------- 15 files changed, 342 insertions(+), 285 deletions(-) delete mode 100644 conf/api.src delete mode 100644 conf/front.src create mode 100644 manifest.toml diff --git a/conf/api.src b/conf/api.src deleted file mode 100644 index f92a438..0000000 --- a/conf/api.src +++ /dev/null @@ -1,7 +0,0 @@ -SOURCE_URL=https://dev.funkwhale.audio/funkwhale/funkwhale/-/jobs/artifacts/1.2.10/download?job=build_api -SOURCE_SUM=fc6f54d37993f74e057d1a59438e21b68a8cff1a7f9438415459ede7cf7f09d0 -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=zip -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME= -SOURCE_EXTRACT=true diff --git a/conf/env.prod b/conf/env.prod index 5b32746..0ea9385 100644 --- a/conf/env.prod +++ b/conf/env.prod @@ -110,12 +110,12 @@ CACHE_URL=redis://127.0.0.1:6379/__REDIS_DB__ # Where media files (such as album covers or audio tracks) should be stored # on your system? # (Ensure this directory actually exists) -MEDIA_ROOT=__DATADIR__/media +MEDIA_ROOT=__DATA_DIR__/media # Where static files (such as API css or icons) should be compiled # on your system? # (Ensure this directory actually exists) -STATIC_ROOT=__DATADIR__/static +STATIC_ROOT=__DATA_DIR__/static # which settings module should django use? # You don't have to touch this unless you really know what you're doing @@ -138,8 +138,8 @@ DJANGO_SECRET_KEY=__KEY__ # MUSIC_DIRECTORY_PATH=/srv/funkwhale/data/music # # MUSIC_DIRECTORY_SERVE_PATH= # stays commented, not needed -MUSIC_DIRECTORY_PATH=__DATADIR__/music -#MUSIC_DIRECTORY_SERVE_PATH=__DATADIR__/import +MUSIC_DIRECTORY_PATH=__DATA_DIR__/music +#MUSIC_DIRECTORY_SERVE_PATH=__DATA_DIR__/import # LDAP settings # Use the following options to allow authentication on your Funkwhale instance @@ -157,8 +157,8 @@ LDAP_START_TLS=False LDAP_ROOT_DN=ou=users,dc=yunohost,dc=org LDAP_USER_ATTR_MAP=username:uid -FUNKWHALE_FRONTEND_PATH=__FINALPATH__/front/dist -FUNKWHALE_SPA_HTML_ROOT=__FINALPATH__/front/dist/index.html +FUNKWHALE_FRONTEND_PATH=__INSTALL_DIR__/front/dist +FUNKWHALE_SPA_HTML_ROOT=__INSTALL_DIR__/front/dist/index.html # Nginx related configuration NGINX_MAX_BODY_SIZE=100M diff --git a/conf/front.src b/conf/front.src deleted file mode 100644 index f5316c7..0000000 --- a/conf/front.src +++ /dev/null @@ -1,7 +0,0 @@ -SOURCE_URL=https://dev.funkwhale.audio/funkwhale/funkwhale/builds/artifacts/1.2.10/download?job=build_front -SOURCE_SUM=bcf0ba380295be58dfcfe4d88605cfce357859adf623c8236fb1182095c38bfd -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=zip -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME= -SOURCE_EXTRACT=true diff --git a/conf/funkwhale-beat.service b/conf/funkwhale-beat.service index 2efd191..54c356b 100644 --- a/conf/funkwhale-beat.service +++ b/conf/funkwhale-beat.service @@ -6,9 +6,9 @@ PartOf=__APP__.target [Service] User=__APP__ Group=__APP__ -WorkingDirectory=__FINALPATH__/api -EnvironmentFile=__FINALPATH__/config/.env -ExecStart=__FINALPATH__/virtualenv/bin/celery -A funkwhale_api.taskapp beat -l INFO +WorkingDirectory=__INSTALL_DIR__/api +EnvironmentFile=__INSTALL_DIR__/config/.env +ExecStart=__INSTALL_DIR__/virtualenv/bin/celery -A funkwhale_api.taskapp beat -l INFO [Install] WantedBy=multi-user.target diff --git a/conf/funkwhale-server.service b/conf/funkwhale-server.service index 59d5dd2..ce58d87 100644 --- a/conf/funkwhale-server.service +++ b/conf/funkwhale-server.service @@ -6,9 +6,9 @@ PartOf=__APP__.target [Service] User=__APP__ Group=__APP__ -WorkingDirectory=__FINALPATH__/api -EnvironmentFile=__FINALPATH__/config/.env -ExecStart=__FINALPATH__/virtualenv/bin/gunicorn config.asgi:application -w ${FUNKWHALE_WEB_WORKERS} -k uvicorn.workers.UvicornWorker -b ${FUNKWHALE_API_IP}:${FUNKWHALE_API_PORT} +WorkingDirectory=__INSTALL_DIR__/api +EnvironmentFile=__INSTALL_DIR__/config/.env +ExecStart=__INSTALL_DIR__/virtualenv/bin/gunicorn config.asgi:application -w ${FUNKWHALE_WEB_WORKERS} -k uvicorn.workers.UvicornWorker -b ${FUNKWHALE_API_IP}:${FUNKWHALE_API_PORT} [Install] WantedBy=multi-user.target diff --git a/conf/funkwhale-worker.service b/conf/funkwhale-worker.service index ca8bd26..b6d5048 100644 --- a/conf/funkwhale-worker.service +++ b/conf/funkwhale-worker.service @@ -6,9 +6,9 @@ PartOf=__APP__.target [Service] User=__APP__ Group=__APP__ -WorkingDirectory=__FINALPATH__/api -EnvironmentFile=__FINALPATH__/config/.env -ExecStart=__FINALPATH__/virtualenv/bin/celery -A funkwhale_api.taskapp worker -l INFO --concurrency=0 +WorkingDirectory=__INSTALL_DIR__/api +EnvironmentFile=__INSTALL_DIR__/config/.env +ExecStart=__INSTALL_DIR__/virtualenv/bin/celery -A funkwhale_api.taskapp worker -l INFO --concurrency=0 [Install] WantedBy=multi-user.target diff --git a/conf/nginx.conf b/conf/nginx.conf index 920e2c7..f6fdd0a 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,4 +1,4 @@ -root __FINALPATH__/front/dist; +root __INSTALL_DIR__/front/dist; location / { @@ -26,7 +26,7 @@ location /front/ { more_set_headers "Referrer-Policy: strict-origin-when-cross-origin"; more_set_headers "Service-Worker-Allowed: /"; more_set_headers "X-Frame-Options: SAMEORIGIN"; - alias __FINALPATH__/front/dist/; + alias __INSTALL_DIR__/front/dist/; expires 30d; more_set_headers "Pragma: public"; more_set_headers "Cache-Control: public, must-revalidate, proxy-revalidate"; @@ -37,7 +37,7 @@ location /front/embed.html { more_set_headers "Referrer-Policy: strict-origin-when-cross-origin"; more_set_headers "X-Frame-Options: ALLOW"; - alias __FINALPATH__/front/dist/embed.html; + alias __INSTALL_DIR__/front/dist/embed.html; expires 30d; more_set_headers "Pragma: public"; more_set_headers "Cache-Control: public, must-revalidate, proxy-revalidate"; @@ -102,11 +102,11 @@ location /.well-known/ { } location /media/__sized__/ { - alias __DATADIR__/media/__sized__/; + alias __DATA_DIR__/media/__sized__/; } location /media/attachments/ { - alias __DATADIR__//media/attachments/; + alias __DATA_DIR__//media/attachments/; } location /_protected/media/ { @@ -114,7 +114,7 @@ location /_protected/media/ { # audio files once correct permission / authentication # has been checked on API side internal; - alias __DATADIR__/media/; + alias __DATA_DIR__/media/; } # Comment the previous location and uncomment this one if you're storing @@ -132,10 +132,10 @@ location /_protected/music/ { # has been checked on API side # Set this to the same value as your MUSIC_DIRECTORY_PATH setting internal; - alias __DATADIR__/music/; + alias __DATA_DIR__/music/; } location /staticfiles/ { # django static files - alias __DATADIR__/static/; + alias __DATA_DIR__/static/; } diff --git a/manifest.toml b/manifest.toml new file mode 100644 index 0000000..6481202 --- /dev/null +++ b/manifest.toml @@ -0,0 +1,69 @@ +packaging_format = 2 + +id = "funkwhale" +name = "Funkwhale" +description.en = "Convivial and modern music server" +description.fr = "Serveur de musique moderne et convivial" + +version = "1.2.10~ynh1" + +maintainers = ["Ciarán Ainsworth"] + +[upstream] +license = "AGPL-3.0-or-later" +website = "https://funkwhale.audio/" +demo = "https://demo.funkwhale.audio" +admindoc = "https://docs.funkwhale.audio/admin/index.html" +userdoc = "https://docs.funkwhale.audio/users/index.html" +code = "https://dev.funkwhale.audio/funkwhale/funkwhale" +cpe = "???" # FIXME: optional but recommended if relevant, this is meant to contain the Common Platform Enumeration, which is sort of a standard id for applications defined by the NIST. In particular, Yunohost may use this is in the future to easily track CVE (=security reports) related to apps. The CPE may be obtained by searching here: https://nvd.nist.gov/products/cpe/search. For example, for Nextcloud, the CPE is 'cpe:2.3:a:nextcloud:nextcloud' (no need to include the version number) +fund = "???" # FIXME: optional but recommended (or remove if irrelevant / not applicable). This is meant to be an URL where people can financially support this app, especially when its development is based on volunteers and/or financed by its community. YunoHost may later advertise it in the webadmin. + +[integration] +yunohost = ">= 11.0.0" +architectures = "all" # FIXME: can be replaced by a list of supported archs using the dpkg --print-architecture nomenclature (amd64/i386/armhf/arm64), for example: ["amd64", "i386"] +multi_instance = true +ldap = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "sso" key : the "ldap" key corresponds to wether or not a user *can* login on the app using its YunoHost credentials. +sso = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "ldap" key : the "sso" key corresponds to wether or not a user is *automatically logged-in* on the app when logged-in on the YunoHost portal. +disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ... +ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... +ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... + +[install] + [install.domain] + # this is a generic question - ask strings are automatically handled by Yunohost's core + type = "domain" + full_domain = true + + [install.init_main_permission] + help.en = "If enabled, Funkwhale will be accessible by Funkwhale for Android and by users without a YunoHost account. This can be changed later in the webadmin." + help.fr = "Si cette case est cochée, Funkwhale sera accessible par Funkwhale for Android et par les utilisateurs n’ayant pas de compte YunoHost. Vous pourrez changer cela dans la webadmin." + type = "group" + default = "visitors" + + [install.admin] + # this is a generic question - ask strings are automatically handled by Yunohost's core + type = "user" + +[resources] + [resources.sources] + [resources.sources.api] + url = "https://dev.funkwhale.audio/funkwhale/funkwhale/-/jobs/artifacts/1.2.10/download?job=build_api" + sha256 = "2544fa01bc64c7481dbd03faaa777ff6d2006e6a36cb79c694e13f6e2761f025" + + [resources.sources.front] + url = "https://dev.funkwhale.audio/funkwhale/funkwhale/builds/artifacts/1.2.10/download?job=build_front" + sha256 = "6471722068ac6586194ee2c28d0691a2acdcb1eae881625fcf15c10a750bb51a" + + + [resources.system_user] + + [resources.install_dir] + + [resources.data_dir] + + [resources.permissions] + main.url = "/" + + [resources.database] + type = "postgresql" diff --git a/scripts/_common.sh b/scripts/_common.sh index e031277..035a2a9 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,7 @@ #================================================= # dependencies used by the app (must be on a single line) -pkg_dependencies="curl python3-pip python3-venv git unzip libldap2-dev libsasl2-dev gettext-base zlib1g-dev libffi-dev libssl-dev \ +#REMOVEME? pkg_dependencies="curl python3-pip python3-venv git unzip libldap2-dev libsasl2-dev gettext-base zlib1g-dev libffi-dev libssl-dev \ build-essential ffmpeg libjpeg-dev libmagic-dev libpq-dev postgresql postgresql-contrib python3-dev make \ redis-server \ `# add arm support` \ diff --git a/scripts/backup b/scripts/backup index 52b125d..e76e863 100644 --- a/scripts/backup +++ b/scripts/backup @@ -14,23 +14,23 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { +#REMOVEME? ynh_clean_setup () { true } # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_print_info --message="Loading installation settings..." +#REMOVEME? ynh_print_info --message="Loading installation settings..." -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -domain=$(ynh_app_setting_get --app=$app --key=domain) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -datadir=$(ynh_app_setting_get --app=$app --key=datadir) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) +#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP @@ -41,13 +41,13 @@ ynh_print_info --message="Declaring files to be backed up..." # BACKUP THE APP MAIN DIR #================================================= -ynh_backup --src_path="$final_path" +ynh_backup --src_path="$install_dir" #================================================= # BACKUP THE DATA DIR #================================================= -ynh_backup --src_path="$datadir" --is_big +ynh_backup --src_path="$data_dir" --is_big #================================================= # BACKUP THE NGINX CONFIGURATION diff --git a/scripts/change_url b/scripts/change_url index 67769f4..df595fc 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -13,63 +13,63 @@ source /usr/share/yunohost/helpers # RETRIEVE ARGUMENTS #================================================= -old_domain=$YNH_APP_OLD_DOMAIN -old_path=$YNH_APP_OLD_PATH +#REMOVEME? old_domain=$YNH_APP_OLD_DOMAIN +#REMOVEME? old_path=$YNH_APP_OLD_PATH -new_domain=$YNH_APP_NEW_DOMAIN -new_path=$YNH_APP_NEW_PATH +#REMOVEME? new_domain=$YNH_APP_NEW_DOMAIN +#REMOVEME? new_path=$YNH_APP_NEW_PATH -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 +#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1 -# Needed for helper "ynh_add_nginx_config" -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -port=$(ynh_app_setting_get --app=$app --key=port) -key=$(ynh_app_setting_get --app=$app --key=key) -redis_db=$(ynh_app_setting_get --app=$app --key=redis_db) -port=$(ynh_app_setting_get --app=$app --key=port) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_user=$db_name -db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) -datadir=$(ynh_app_setting_get --app=$app --key=datadir) -redis_db=$(ynh_app_setting_get --app=$app --key=redis_db) -key=$(ynh_app_setting_get --app=$app --key=key) +#REMOVEME? # Needed for helper "ynh_add_nginx_config" +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) +#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port) +#REMOVEME? key=$(ynh_app_setting_get --app=$app --key=key) +#REMOVEME? redis_db=$(ynh_app_setting_get --app=$app --key=redis_db) +#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port) +#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) +#REMOVEME? db_user=$db_name +#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) +#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir) +#REMOVEME? redis_db=$(ynh_app_setting_get --app=$app --key=redis_db) +#REMOVEME? key=$(ynh_app_setting_get --app=$app --key=key) #================================================= # BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1 +#REMOVEME? ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1 # Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { +#REMOVEME? ynh_backup_before_upgrade +#REMOVEME? ynh_clean_setup () { # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. - ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" +#REMOVEME? ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" # Restore it if the upgrade fails - ynh_restore_upgradebackup +#REMOVEME? ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # CHECK WHICH PARTS SHOULD BE CHANGED #================================================= -change_domain=0 -if [ "$old_domain" != "$new_domain" ] +#REMOVEME? change_domain=0 +#REMOVEME? if [ "$old_domain" != "$new_domain" ] then - change_domain=1 + #REMOVEME? change_domain=1 fi -change_path=0 -if [ "$old_path" != "$new_path" ] +#REMOVEME? change_path=0 +#REMOVEME? if [ "$old_path" != "$new_path" ] then - change_path=1 + #REMOVEME? change_path=1 fi #================================================= @@ -88,44 +88,46 @@ ynh_systemd_action --service_name="$app-worker" --action=stop --log_path="/var/l #================================================= ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 -nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf +ynh_change_url_nginx_config + +#REMOVEME? nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf # Change the path in the NGINX config file if [ $change_path -eq 1 ] then # Make a backup of the original NGINX config file if modified - ynh_backup_if_checksum_is_different --file="$nginx_conf_path" +#REMOVEME? ynh_backup_if_checksum_is_different --file="$nginx_conf_path" # Set global variables for NGINX helper - domain="$old_domain" - path_url="$new_path" +#REMOVEME? domain="$old_domain" +#REMOVEME? path="$new_path" # Create a dedicated NGINX config - ynh_add_nginx_config +#REMOVEME? ynh_add_nginx_config fi # Change the domain for NGINX if [ $change_domain -eq 1 ] then # Delete file checksum for the old conf file location - ynh_delete_file_checksum --file="$nginx_conf_path" - mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf +#REMOVEME? ynh_delete_file_checksum --file="$nginx_conf_path" +#REMOVEME? mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf # Store file checksum for the new config file location - ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" +#REMOVEME? ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" fi #================================================= # MODIFY THE CONFIG FILE #================================================= ynh_script_progression --message="Modifying a config file..." --weight=1 - +#REMOVEME? domain=$new_domain -ynh_add_config --template="../conf/env.prod" --destination="$final_path/config/.env" +ynh_add_config --template="../conf/env.prod" --destination="$install_dir/config/.env" #================================================= # MODIFY THE FEDERATION #================================================= -source $final_path/virtualenv/bin/activate -ynh_exec_warn_less python3 $final_path/api/manage.py fix_federation_ids https://$old_domain https://$new_domain --no-dry-run --no-input +source $install_dir/virtualenv/bin/activate +ynh_exec_warn_less python3 $install_dir/api/manage.py fix_federation_ids https://$old_domain https://$new_domain --no-dry-run --no-input #================================================= # START SYSTEMD SERVICE @@ -142,14 +144,14 @@ ynh_systemd_action --service_name="$app-worker" --action="start" --log_path="/va ynh_script_progression --message="Configuring Fail2Ban..." --weight=1 # Create a dedicated Fail2Ban config -ynh_add_fail2ban_config --logpath="/var/log/nginx/$new_domain-access.log" --failregex=".* \"POST /api/v1/token/ HTTP/1.1\" 400 68.*$" --max_retry=5 +#REMOVEME? ynh_add_fail2ban_config --logpath="/var/log/nginx/$new_domain-access.log" --failregex=".* \"POST /api/v1/token/ HTTP/1.1\" 400 68.*$" --max_retry=5 #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 +#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1 -ynh_systemd_action --service_name=nginx --action=reload +#REMOVEME? #REMOVEME? ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT diff --git a/scripts/install b/scripts/install index 65c38df..70ec02c 100644 --- a/scripts/install +++ b/scripts/install @@ -13,100 +13,100 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { +#REMOVEME? ynh_clean_setup () { true } # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= -domain=$YNH_APP_ARG_DOMAIN -path_url="/" -is_public=$YNH_APP_ARG_IS_PUBLIC -admin=$YNH_APP_ARG_ADMIN +#REMOVEME? domain=$YNH_APP_ARG_DOMAIN +path="/" +#REMOVEME? is_public=$YNH_APP_ARG_IS_PUBLIC +#REMOVEME? admin=$YNH_APP_ARG_ADMIN -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME admin_mail=$(ynh_user_get_info --username="$admin" --key="mail") #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -ynh_script_progression --message="Validating installation parameters..." --weight=1 +#REMOVEME? ynh_script_progression --message="Validating installation parameters..." --weight=1 -final_path=/var/www/$app -test ! -e "$final_path" || ynh_die --message="This path already contains a folder" +#REMOVEME? install_dir=/var/www/$app +#REMOVEME? test ! -e "$install_dir" || ynh_die --message="This path already contains a folder" -datadir=/home/yunohost.app/$app/data +#REMOVEME? data_dir=/home/yunohost.app/$app/data # Register (book) web path -ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url +#REMOVEME? ynh_webpath_register --app=$app --domain=$domain --path=$path #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_script_progression --message="Storing installation settings..." --weight=1 +#REMOVEME? ynh_script_progression --message="Storing installation settings..." --weight=1 -ynh_app_setting_set --app=$app --key=domain --value=$domain -ynh_app_setting_set --app=$app --key=path --value=$path_url -ynh_app_setting_set --app=$app --key=admin --value=$admin +#REMOVEME? ynh_app_setting_set --app=$app --key=domain --value=$domain +#REMOVEME? ynh_app_setting_set --app=$app --key=path --value=$path +#REMOVEME? ynh_app_setting_set --app=$app --key=admin --value=$admin #================================================= # STANDARD MODIFICATIONS #================================================= # FIND AND OPEN A PORT #================================================= -ynh_script_progression --message="Finding an available port..." --weight=1 +#REMOVEME? ynh_script_progression --message="Finding an available port..." --weight=1 # Find an available port -port=$(ynh_find_port --port=8095) -ynh_app_setting_set --app=$app --key=port --value=$port +#REMOVEME? port=$(ynh_find_port --port=8095) +#REMOVEME? ynh_app_setting_set --app=$app --key=port --value=$port #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing dependencies..." --weight=1 +#REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=1 -ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies +#REMOVEME? ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Configuring system user..." --weight=1 +#REMOVEME? ynh_script_progression --message="Configuring system user..." --weight=1 # Create a system user -ynh_system_user_create --username=$app --home_dir="$final_path" +#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" #================================================= # CREATE A POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Creating a PostgreSQL database..." --weight=1 +#REMOVEME? ynh_script_progression --message="Creating a PostgreSQL database..." --weight=1 -ynh_psql_test_if_first_run -db_name=$(ynh_sanitize_dbid --db_name=$app) -db_user=$db_name -ynh_app_setting_set --app=$app --key=db_name --value=$db_name -ynh_psql_setup_db --db_user=$db_user --db_name=$db_name -db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) +#REMOVEME? ynh_psql_test_if_first_run +#REMOVEME? db_name=$(ynh_sanitize_dbid --db_name=$app) +#REMOVEME? db_user=$db_name +#REMOVEME? ynh_app_setting_set --app=$app --key=db_name --value=$db_name +#REMOVEME? ynh_psql_setup_db --db_user=$db_user --db_name=$db_name +#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Setting up source files..." --weight=1 -ynh_app_setting_set --app=$app --key=final_path --value=$final_path +#REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir="$final_path/api" --source_id="api" -ynh_setup_source --dest_dir="$final_path/front" --source_id="front" +ynh_setup_source --dest_dir="$install_dir/api" --source_id="api" +ynh_setup_source --dest_dir="$install_dir/front" --source_id="front" -mkdir -p $final_path/config +mkdir -p $install_dir/config -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R $app:www-data "$install_dir" #================================================= # NGINX CONFIGURATION @@ -123,14 +123,14 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Creating a data directory..." --weight=1 -ynh_app_setting_set --app=$app --key=datadir --value=$datadir +#REMOVEME? ynh_app_setting_set --app=$app --key=data_dir --value=$data_dir -mkdir -p $datadir -mkdir -p $datadir/{static,media,music} +mkdir -p $data_dir +mkdir -p $data_dir/{static,media,music} -chmod 750 "$datadir" -chmod -R o-rwx "$datadir" -chown -R $app:www-data "$datadir" +chmod 750 "$data_dir" +chmod -R o-rwx "$data_dir" +chown -R $app:www-data "$data_dir" #================================================= # ADD A CONFIGURATION @@ -143,10 +143,10 @@ redis_db=$(ynh_redis_get_free_db) ynh_app_setting_set --app=$app --key=key --value=$key ynh_app_setting_set --app=$app --key=redis_db --value=$redis_db -ynh_add_config --template="../conf/env.prod" --destination="$final_path/config/.env" +ynh_add_config --template="../conf/env.prod" --destination="$install_dir/config/.env" -chmod 400 "$final_path/config/.env" -chown $app:$app "$final_path/config/.env" +chmod 400 "$install_dir/config/.env" +chown $app:$app "$install_dir/config/.env" #================================================= # SETUP SYSTEMD @@ -163,16 +163,16 @@ ynh_add_systemd_config --service="${app}-beat" --template="funkwhale-beat.serv #================================================= # INSTALL PYTHON DEPENDENCIES #================================================= -ynh_script_progression --message="Installing Python dependencies..." --weight=1 +#REMOVEME? ynh_script_progression --message="Installing Python dependencies..." --weight=1 -pushd $final_path - python3 -m venv $final_path/virtualenv - source $final_path/virtualenv/bin/activate +pushd $install_dir + python3 -m venv $install_dir/virtualenv + source $install_dir/virtualenv/bin/activate pip install --upgrade pip pip install --upgrade setuptools ynh_exec_warn_less pip install wheel # Workaround for error AttributeError: module 'lib' has no attribute 'X509_V_FLAG_CB_ISSUER_CHECK' - ynh_replace_string --match_string="pyOpenSSL~=20.0.1" --replace_string="pyOpenSSL~=21.0.0" --target_file="$final_path/api/requirements/base.txt" + ynh_replace_string --match_string="pyOpenSSL~=20.0.1" --replace_string="pyOpenSSL~=21.0.0" --target_file="$install_dir/api/requirements/base.txt" ynh_exec_warn_less pip install -r api/requirements.txt popd @@ -181,8 +181,8 @@ popd #================================================= ynh_script_progression --message="Building funkwhale..." --weight=1 -pushd $final_path - source $final_path/virtualenv/bin/activate +pushd $install_dir + source $install_dir/virtualenv/bin/activate # needed for enabling the 'unaccent' extension ynh_psql_execute_as_root --sql="ALTER USER $db_user WITH SUPERUSER;" --database="$db_name" @@ -192,9 +192,9 @@ pushd $final_path echo "yes" | ynh_exec_warn_less python api/manage.py collectstatic popd -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R $app:www-data "$install_dir" #================================================= # GENERIC FINALIZATION @@ -228,22 +228,22 @@ ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-access.log" --failre #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring permissions..." --weight=1 +#REMOVEME? ynh_script_progression --message="Configuring permissions..." --weight=1 # Make app public if necessary -if [ $is_public -eq 1 ] +#REMOVEME? if [ $is_public -eq 1 ] then # Everyone can access the app. # The "main" permission is automatically created before the install script. - ynh_permission_update --permission="main" --add="visitors" +#REMOVEME? ynh_permission_update --permission="main" --add="visitors" fi #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 +#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1 -ynh_systemd_action --service_name=nginx --action=reload +#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT diff --git a/scripts/remove b/scripts/remove index 1271cb7..78a140b 100644 --- a/scripts/remove +++ b/scripts/remove @@ -12,17 +12,17 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 +#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1 -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get --app=$app --key=domain) -port=$(ynh_app_setting_get --app=$app --key=port) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_user=$db_name -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -datadir=$(ynh_app_setting_get --app=$app --key=datadir) -redis_db=$(ynh_app_setting_get --app=$app --key=redis_db) +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port) +#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) +#REMOVEME? db_user=$db_name +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) +#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir) +#REMOVEME? redis_db=$(ynh_app_setting_get --app=$app --key=redis_db) #================================================= # STANDARD REMOVE @@ -68,18 +68,18 @@ ynh_secure_remove --file="/etc/systemd/system/$app.target" #================================================= # REMOVE THE POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Removing the PostgreSQL database..." --weight=1 +#REMOVEME? ynh_script_progression --message="Removing the PostgreSQL database..." --weight=1 # Remove a database if it exists, along with the associated user -ynh_psql_remove_db --db_user=$db_user --db_name=$db_name +#REMOVEME? ynh_psql_remove_db --db_user=$db_user --db_name=$db_name #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_script_progression --message="Removing app main directory..." --weight=1 +#REMOVEME? ynh_script_progression --message="Removing app main directory..." --weight=1 # Remove the app directory securely -ynh_secure_remove --file="$final_path" +#REMOVEME? ynh_secure_remove --file="$install_dir" #================================================= # REMOVE DATA DIR @@ -89,7 +89,7 @@ ynh_secure_remove --file="$final_path" if [ "${YNH_APP_PURGE:-0}" -eq 1 ] then ynh_script_progression --message="Removing app data directory..." --weight=1 - ynh_secure_remove --file="$datadir" +#REMOVEME? ynh_secure_remove --file="$data_dir" fi #================================================= @@ -103,10 +103,10 @@ ynh_remove_nginx_config #================================================= # REMOVE DEPENDENCIES #================================================= -ynh_script_progression --message="Removing dependencies..." --weight=1 +#REMOVEME? ynh_script_progression --message="Removing dependencies..." --weight=1 # Remove metapackage and its dependencies -ynh_remove_app_dependencies +#REMOVEME? ynh_remove_app_dependencies #================================================= # REMOVE FAIL2BAN CONFIGURATION @@ -131,10 +131,10 @@ ynh_redis_remove_db $redis_db #================================================= # REMOVE DEDICATED USER #================================================= -ynh_script_progression --message="Removing the dedicated system user..." --weight=1 +#REMOVEME? ynh_script_progression --message="Removing the dedicated system user..." --weight=1 # Delete a system user -ynh_system_user_delete --username=$app +#REMOVEME? ynh_system_user_delete --username=$app #================================================= # END OF SCRIPT diff --git a/scripts/restore b/scripts/restore index 848bdd7..f67d7eb 100644 --- a/scripts/restore +++ b/scripts/restore @@ -14,79 +14,79 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { +#REMOVEME? ynh_clean_setup () { true } # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 +#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1 -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get --app=$app --key=domain) -path_url=$(ynh_app_setting_get --app=$app --key=path) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_user=$db_name -datadir=$(ynh_app_setting_get --app=$app --key=datadir) +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) +#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) +#REMOVEME? db_user=$db_name +#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= -ynh_script_progression --message="Validating restoration parameters..." --weight=1 +#REMOVEME? ynh_script_progression --message="Validating restoration parameters..." --weight=1 -test ! -d $final_path \ - || ynh_die --message="There is already a directory: $final_path " +#REMOVEME? test ! -d $install_dir \ + || ynh_die --message="There is already a directory: $install_dir " #================================================= # STANDARD RESTORATION STEPS #================================================= # RECREATE THE DEDICATED USER #================================================= -ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 +#REMOVEME? ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 # Create the dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir="$final_path" +#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" #================================================= # RESTORE THE APP MAIN DIR #================================================= ynh_script_progression --message="Restoring the app main directory..." --weight=1 -ynh_restore_file --origin_path="$final_path" +ynh_restore_file --origin_path="$install_dir" -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R $app:www-data "$install_dir" #================================================= # RESTORE THE DATA DIRECTORY #================================================= ynh_script_progression --message="Restoring the data directory..." --weight=1 -ynh_restore_file --origin_path="$datadir" --not_mandatory +ynh_restore_file --origin_path="$data_dir" --not_mandatory -mkdir -p $datadir +mkdir -p $data_dir -mkdir -p $datadir/{static,media,music} +mkdir -p $data_dir/{static,media,music} -chmod 750 "$datadir" -chmod -R o-rwx "$datadir" -chown -R $app:www-data "$datadir" +chmod 750 "$data_dir" +chmod -R o-rwx "$data_dir" +chown -R $app:www-data "$data_dir" #================================================= # SPECIFIC RESTORATION #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Reinstalling dependencies..." --weight=1 +#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." --weight=1 # Define and install dependencies -ynh_install_app_dependencies $pkg_dependencies +#REMOVEME? ynh_install_app_dependencies $pkg_dependencies #================================================= # RESTORE THE NGINX CONFIGURATION @@ -98,11 +98,11 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RESTORE THE POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1 +#REMOVEME? ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1 -ynh_psql_test_if_first_run -db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) -ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd +#REMOVEME? ynh_psql_test_if_first_run +#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) +#REMOVEME? ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 9763ca9..f359620 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,20 +12,20 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 +#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1 -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get --app=$app --key=domain) -path_url=$(ynh_app_setting_get --app=$app --key=path) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_user=$db_name -db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) -datadir=$(ynh_app_setting_get --app=$app --key=datadir) -port=$(ynh_app_setting_get --app=$app --key=port) -redis_db=$(ynh_app_setting_get --app=$app --key=redis_db) -key=$(ynh_app_setting_get --app=$app --key=key) +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) +#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) +#REMOVEME? db_user=$db_name +#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) +#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir) +#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port) +#REMOVEME? redis_db=$(ynh_app_setting_get --app=$app --key=redis_db) +#REMOVEME? key=$(ynh_app_setting_get --app=$app --key=key) #================================================= # CHECK VERSION @@ -37,16 +37,16 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1 +#REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1 # Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { +#REMOVEME? ynh_backup_before_upgrade +#REMOVEME? ynh_clean_setup () { # Restore it if the upgrade fails - ynh_restore_upgradebackup +#REMOVEME? ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # STANDARD UPGRADE STEPS @@ -72,13 +72,13 @@ fi # If db_pwd doesn't exist, create it if [ -z "$db_pwd" ]; then - db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) - ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd +#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) +#REMOVEME? ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd fi # Cleaning legacy permissions -if ynh_legacy_permissions_exists; then - ynh_legacy_permissions_delete_all +#REMOVEME? if ynh_legacy_permissions_exists; then +#REMOVEME? ynh_legacy_permissions_delete_all ynh_app_setting_delete --app=$app --key=is_public fi @@ -87,55 +87,55 @@ fi # MOVE DATAS #================================================= -# If datadir doesn't exist, create it -if [ -z "$datadir" ]; then +# If data_dir doesn't exist, create it +if [ -z "$data_dir" ]; then # Do a full backup before moving datas yunohost backup create --apps $app - datadir="/home/yunohost.app/${app}/data" - ynh_script_progression --message="Moving datas to $datadir..." --weight=1 + data_dir="/home/yunohost.app/${app}/data" + ynh_script_progression --message="Moving datas to $data_dir..." --weight=1 - mkdir -p $datadir - mkdir -p $datadir/{static,media,music} + mkdir -p $data_dir + mkdir -p $data_dir/{static,media,music} - chmod 750 "$datadir" - chmod -R o-rwx "$datadir" - chown -R $app:www-data "$datadir" + chmod 750 "$data_dir" + chmod -R o-rwx "$data_dir" + chown -R $app:www-data "$data_dir" - ynh_backup_if_checksum_is_different --file="$final_path/code/config/.env" - mkdir -p $final_path/config - rsync -a $final_path/code/config/ $final_path/config/ - chmod 400 $final_path/config/.env - ynh_store_file_checksum --file="$final_path/config/.env" - ynh_delete_file_checksum --file="$final_path/code/config/.env" + ynh_backup_if_checksum_is_different --file="$install_dir/code/config/.env" + mkdir -p $install_dir/config + rsync -a $install_dir/code/config/ $install_dir/config/ + chmod 400 $install_dir/config/.env + ynh_store_file_checksum --file="$install_dir/config/.env" + ynh_delete_file_checksum --file="$install_dir/code/config/.env" - if [ -d "$final_path/code/data/static/" ]; then - rsync -a $final_path/code/data/static/ $datadir/static/ + if [ -d "$install_dir/code/data/static/" ]; then + rsync -a $install_dir/code/data/static/ $data_dir/static/ fi - if [ -d "$final_path/media/" ]; then - rsync -a $final_path/media/ $datadir/media/ + if [ -d "$install_dir/media/" ]; then + rsync -a $install_dir/media/ $data_dir/media/ fi - if [ -d "$final_path/code/data/media/" ]; then - rsync -a $final_path/code/data/media/ $datadir/media/ + if [ -d "$install_dir/code/data/media/" ]; then + rsync -a $install_dir/code/data/media/ $data_dir/media/ fi - if [ -d "$final_path/import/" ]; then - rsync -a $final_path/import/ $datadir/music/ + if [ -d "$install_dir/import/" ]; then + rsync -a $install_dir/import/ $data_dir/music/ fi - if [ -d "$final_path/code/data/music/" ]; then - rsync -a $final_path/code/data/music/ $datadir/music/ + if [ -d "$install_dir/code/data/music/" ]; then + rsync -a $install_dir/code/data/music/ $data_dir/music/ fi - ynh_secure_remove --file="$final_path/code" - ynh_secure_remove --file="$final_path/media" - ynh_secure_remove --file="$final_path/code/data/media" - ynh_secure_remove --file="$final_path/import" - ynh_secure_remove --file="$final_path/code/data/music" +#REMOVEME? ynh_secure_remove --file="$install_dir/code" +#REMOVEME? ynh_secure_remove --file="$install_dir/media" +#REMOVEME? ynh_secure_remove --file="$install_dir/code/data/media" +#REMOVEME? ynh_secure_remove --file="$install_dir/import" +#REMOVEME? ynh_secure_remove --file="$install_dir/code/data/music" - ynh_app_setting_set --app=$app --key=datadir --value=$datadir +#REMOVEME? ynh_app_setting_set --app=$app --key=data_dir --value=$data_dir - chmod 750 "$datadir" - chmod -R o-rwx "$datadir" - chown -R $app:www-data "$datadir" + chmod 750 "$data_dir" + chmod -R o-rwx "$data_dir" + chown -R $app:www-data "$data_dir" upgrade_type="UPGRADE_APP" fi @@ -143,10 +143,10 @@ fi #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 +#REMOVEME? ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 # Create a dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir="$final_path" +#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -156,23 +156,23 @@ if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_script_progression --message="Upgrading source files..." --weight=1 - ynh_secure_remove --file="$final_path/api" - ynh_secure_remove --file="$final_path/front" +#REMOVEME? ynh_secure_remove --file="$install_dir/api" +#REMOVEME? ynh_secure_remove --file="$install_dir/front" # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$final_path/api" --source_id="api" - ynh_setup_source --dest_dir="$final_path/front" --source_id="front" + ynh_setup_source --dest_dir="$install_dir/api" --source_id="api" + ynh_setup_source --dest_dir="$install_dir/front" --source_id="front" fi -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R $app:www-data "$install_dir" #================================================= # UPGRADE DEPENDENCIES #================================================= -ynh_script_progression --message="Upgrading dependencies..." --weight=1 +#REMOVEME? ynh_script_progression --message="Upgrading dependencies..." --weight=1 -ynh_install_app_dependencies $pkg_dependencies +#REMOVEME? ynh_install_app_dependencies $pkg_dependencies #================================================= # NGINX CONFIGURATION @@ -187,17 +187,17 @@ ynh_add_nginx_config #================================================= # INSTALL PYTHON DEPENDENCIES #================================================= -ynh_script_progression --message="Installing Python dependencies..." --weight=1 +#REMOVEME? ynh_script_progression --message="Installing Python dependencies..." --weight=1 -pushd $final_path - ynh_secure_remove --file="$final_path/virtualenv" - python3 -m venv $final_path/virtualenv - source $final_path/virtualenv/bin/activate +pushd $install_dir +#REMOVEME? ynh_secure_remove --file="$install_dir/virtualenv" + python3 -m venv $install_dir/virtualenv + source $install_dir/virtualenv/bin/activate pip install --upgrade pip pip install --upgrade setuptools ynh_exec_warn_less pip install wheel # Workaround for error AttributeError: module 'lib' has no attribute 'X509_V_FLAG_CB_ISSUER_CHECK' - ynh_replace_string --match_string="pyOpenSSL~=20.0.1" --replace_string="pyOpenSSL~=21.0.0" --target_file="$final_path/api/requirements/base.txt" + ynh_replace_string --match_string="pyOpenSSL~=20.0.1" --replace_string="pyOpenSSL~=21.0.0" --target_file="$install_dir/api/requirements/base.txt" ynh_exec_warn_less pip install -r api/requirements.txt popd @@ -206,18 +206,18 @@ popd #================================================= ynh_script_progression --message="Updating a configuration file..." --weight=1 -ynh_add_config --template="../conf/env.prod" --destination="$final_path/config/.env" +ynh_add_config --template="../conf/env.prod" --destination="$install_dir/config/.env" -chmod 400 "$final_path/config/.env" -chown $app:$app "$final_path/config/.env" +chmod 400 "$install_dir/config/.env" +chown $app:$app "$install_dir/config/.env" #================================================= # UPGRADE FUNKWHALE #================================================= ynh_script_progression --message="Upgrading Funkwhale..." --weight=1 -pushd $final_path - source $final_path/virtualenv/bin/activate +pushd $install_dir + source $install_dir/virtualenv/bin/activate echo "yes" | ynh_exec_warn_less python api/manage.py collectstatic --clear --noinput @@ -227,9 +227,9 @@ pushd $final_path ynh_psql_execute_as_root --sql="ALTER USER $db_user WITH NOSUPERUSER;" --database="$db_name" popd -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R $app:www-data "$install_dir" #================================================= # SETUP SYSTEMD @@ -275,9 +275,9 @@ ynh_add_fail2ban_config --logpath="/var/log/nginx/$domain-access.log" --failrege #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 +#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1 -ynh_systemd_action --service_name=nginx --action=reload +#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT From 2627cfeb8c091639fb958ab95d6dfb086b14c16b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Fri, 24 Mar 2023 12:31:51 +0100 Subject: [PATCH 02/30] V2 --- check_process | 40 ---------- doc/{DISCLAIMER.md => ADMIN.md} | 6 +- doc/{DISCLAIMER_fr.md => ADMIN_fr.md} | 6 +- manifest.json | 58 --------------- manifest.toml | 22 +++--- scripts/_common.sh | 7 -- scripts/backup | 22 ------ scripts/change_url | 76 ------------------- scripts/install | 103 +------------------------- scripts/remove | 60 --------------- scripts/restore | 60 +-------------- scripts/upgrade | 85 +-------------------- tests.toml | 7 ++ 13 files changed, 28 insertions(+), 524 deletions(-) delete mode 100644 check_process rename doc/{DISCLAIMER.md => ADMIN.md} (71%) rename doc/{DISCLAIMER_fr.md => ADMIN_fr.md} (71%) delete mode 100644 manifest.json create mode 100644 tests.toml diff --git a/check_process b/check_process deleted file mode 100644 index 536630a..0000000 --- a/check_process +++ /dev/null @@ -1,40 +0,0 @@ -;; Test complet - ; Manifest - domain="domain.tld" - is_public=1 - admin="john" - ; Checks - pkg_linter=1 - setup_sub_dir=0 - setup_root=1 - setup_nourl=0 - setup_private=1 - setup_public=1 - upgrade=1 - # 1.1~ynh1 - upgrade=1 from_commit=8172790fb461d16f09089593fdac380f0d499c83 - # 1.1.1~ynh1 - upgrade=0 from_commit=fa9587f61e4bb4f9db8667b1c6701ede37ac8e91 - # 1.1.2~ynh1 - upgrade=1 from_commit=74255c1c278562eb174fb13ce538d4754f01186c - # 1.1.4~ynh2 - upgrade=1 from_commit=313335d5aa851a497fa92cd7ac264f989e1052d9 - # 1.2.1~ynh1 - upgrade=0 from_commit=9fc8b84ba24260e28f791aa9c47688c1a1f085c2 - # 1.2.2~ynh2 - upgrade=0 from_commit=192afe93f66bb08cc7d487db02dc4d187e5b29e2 - # 1.2.3~ynh1 - upgrade=0 from_commit=1c1b64b8b04ee917a63580dce21d149182ee319d - # 1.2.4~ynh1 - upgrade=0 from_commit=5961e7283e52963329e30ca22df4d5505adfc256 - #1.2.5~ynh1 - upgrade=0 from_commit=a070baf105a94ac6fefc280f0335b044db643ec8 - #1.2.7~ynh1 - upgrade=0 from_commit=557386e0c1306f78c43ccf2e5ec7b3b46a07ab56 - backup_restore=1 - multi_instance=1 - port_already_use=0 - change_url=1 -;;; Options -Email=cda@rootkey.co.uk -Notification=all diff --git a/doc/DISCLAIMER.md b/doc/ADMIN.md similarity index 71% rename from doc/DISCLAIMER.md rename to doc/ADMIN.md index 8e16d23..808552c 100644 --- a/doc/DISCLAIMER.md +++ b/doc/ADMIN.md @@ -2,10 +2,10 @@ * Admin * The admin uses the login you provided at installation. The password is the same you use for YunoHost. - * The admin interface is accessible at the address: `your.domain.fr/api/admin` + * The admin interface is accessible at the address: `__DOMAIN__/api/admin` -To add a collection of music files to a library in your YunoHost installation of Funkwhale, create a symlink to your collection titled "music" in `/home/yunohost.app/funkwhale/data` +To add a collection of music files to a library in your YunoHost installation of Funkwhale, create a symlink to your collection titled "music" in `__DATA_DIR__/data` ```console -foo@bar:~$sudo ln -s /your/music/collection /home/yunohost.app/funkwhale/data/music +foo@bar:~$sudo ln -s /your/music/collection __DATA_DIR__/data/music ``` The files can then be added to your library from the *uploading* tab in a music library under the heading **Import music from your server**. diff --git a/doc/DISCLAIMER_fr.md b/doc/ADMIN_fr.md similarity index 71% rename from doc/DISCLAIMER_fr.md rename to doc/ADMIN_fr.md index 30590da..eb21687 100644 --- a/doc/DISCLAIMER_fr.md +++ b/doc/ADMIN_fr.md @@ -2,8 +2,8 @@ * Admin * L'administrateur utilise le login que vous avez fourni lors de l'installation. Le mot de passe est le même que celui que vous utilisez pour YunoHost. - * L'interface d'administration est accessible à l'adresse : votre.domaine.fr/api/admin + * L'interface d'administration est accessible à l'adresse : __DOMAIN__/api/admin -Pour ajouter une collection de fichiers musicaux à une bibliothèque dans votre installation YunoHost de Funkwhale, créez un lien symbolique vers votre collection intitulée "music" dans `/home/yunohost.app/funkwhale/data/`. -`foo@bar:~$sudo ln -s /your/music/collection /home/yunohost.app/funkwhale/data/music` +Pour ajouter une collection de fichiers musicaux à une bibliothèque dans votre installation YunoHost de Funkwhale, créez un lien symbolique vers votre collection intitulée "music" dans `__DATA_DIR__/data/`. +`foo@bar:~$sudo ln -s /your/music/collection __DATA_DIR__/data/music` Les fichiers peuvent ensuite être ajoutés à votre bibliothèque à partir de l'onglet *Envoi* dans une bibliothèque musicale sous la rubrique **Importer de la musique de votre serveur**. diff --git a/manifest.json b/manifest.json deleted file mode 100644 index b2bbeb1..0000000 --- a/manifest.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "Funkwhale", - "id": "funkwhale", - "packaging_format": 1, - "description": { - "en": "Convivial and modern music server", - "fr": "Serveur de musique moderne et convivial" - }, - "version": "1.2.10~ynh2", - "url": "https://funkwhale.audio", - "upstream": { - "license": "AGPL-3.0-or-later", - "website": "https://funkwhale.audio/", - "demo": "https://demo.funkwhale.audio", - "admindoc": "https://docs.funkwhale.audio/admin/index.html", - "userdoc": "https://docs.funkwhale.audio/users/index.html", - "code": "https://dev.funkwhale.audio/funkwhale/funkwhale" - }, - "license": "AGPL-3.0-or-later", - "maintainer": { - "name": "Ciarán Ainsworth", - "email": "cda@rootkey.co.uk" - }, - "previous_maintainers": [ - { - "name": "Jean-Baptiste Holcroft", - "email": "jean-baptiste@holcroft.fr" - } - ], - "requirements": { - "yunohost": ">= 11.0.0" - }, - "multi_instance": true, - "services": [ - "nginx" - ], - "arguments": { - "install": [ - { - "name": "domain", - "type": "domain" - }, - { - "name": "is_public", - "type": "boolean", - "help": { - "en": "If enabled, Funkwhale will be accessible by Funkwhale for Android and by users without a YunoHost account. This can be changed later in the webadmin.", - "fr": "Si cette case est cochée, Funkwhale sera accessible par Funkwhale for Android et par les utilisateurs n’ayant pas de compte YunoHost. Vous pourrez changer cela dans la webadmin." - }, - "default": true - }, - { - "name": "admin", - "type": "user" - } - ] - } -} diff --git a/manifest.toml b/manifest.toml index 6481202..1da73f0 100644 --- a/manifest.toml +++ b/manifest.toml @@ -16,22 +16,19 @@ demo = "https://demo.funkwhale.audio" admindoc = "https://docs.funkwhale.audio/admin/index.html" userdoc = "https://docs.funkwhale.audio/users/index.html" code = "https://dev.funkwhale.audio/funkwhale/funkwhale" -cpe = "???" # FIXME: optional but recommended if relevant, this is meant to contain the Common Platform Enumeration, which is sort of a standard id for applications defined by the NIST. In particular, Yunohost may use this is in the future to easily track CVE (=security reports) related to apps. The CPE may be obtained by searching here: https://nvd.nist.gov/products/cpe/search. For example, for Nextcloud, the CPE is 'cpe:2.3:a:nextcloud:nextcloud' (no need to include the version number) -fund = "???" # FIXME: optional but recommended (or remove if irrelevant / not applicable). This is meant to be an URL where people can financially support this app, especially when its development is based on volunteers and/or financed by its community. YunoHost may later advertise it in the webadmin. [integration] -yunohost = ">= 11.0.0" -architectures = "all" # FIXME: can be replaced by a list of supported archs using the dpkg --print-architecture nomenclature (amd64/i386/armhf/arm64), for example: ["amd64", "i386"] +yunohost = ">= 11.1.15" +architectures = "all" multi_instance = true -ldap = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "sso" key : the "ldap" key corresponds to wether or not a user *can* login on the app using its YunoHost credentials. -sso = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "ldap" key : the "sso" key corresponds to wether or not a user is *automatically logged-in* on the app when logged-in on the YunoHost portal. -disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ... -ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... -ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... +ldap = false +sso = false +disk = "50M" +ram.build = "50M" +ram.runtime = "50M" [install] [install.domain] - # this is a generic question - ask strings are automatically handled by Yunohost's core type = "domain" full_domain = true @@ -42,7 +39,6 @@ ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requiremen default = "visitors" [install.admin] - # this is a generic question - ask strings are automatically handled by Yunohost's core type = "user" [resources] @@ -55,6 +51,7 @@ ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requiremen url = "https://dev.funkwhale.audio/funkwhale/funkwhale/builds/artifacts/1.2.10/download?job=build_front" sha256 = "6471722068ac6586194ee2c28d0691a2acdcb1eae881625fcf15c10a750bb51a" + [resources.ports] [resources.system_user] @@ -65,5 +62,8 @@ ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requiremen [resources.permissions] main.url = "/" + [resources.apt] + packages = "postgresql curl python3-pip python3-venv git unzip libldap2-dev libsasl2-dev gettext-base zlib1g-dev libffi-dev libssl-dev build-essential ffmpeg libjpeg-dev libmagic-dev libpq-dev python3-dev make zlib1g-dev libffi-dev libssl-dev" + [resources.database] type = "postgresql" diff --git a/scripts/_common.sh b/scripts/_common.sh index 035a2a9..b2c67eb 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,13 +4,6 @@ # COMMON VARIABLES #================================================= -# dependencies used by the app (must be on a single line) -#REMOVEME? pkg_dependencies="curl python3-pip python3-venv git unzip libldap2-dev libsasl2-dev gettext-base zlib1g-dev libffi-dev libssl-dev \ - build-essential ffmpeg libjpeg-dev libmagic-dev libpq-dev postgresql postgresql-contrib python3-dev make \ - redis-server \ - `# add arm support` \ - zlib1g-dev libffi-dev libssl-dev" - #================================================= # PERSONAL HELPERS #================================================= diff --git a/scripts/backup b/scripts/backup index e76e863..13fa6d1 100644 --- a/scripts/backup +++ b/scripts/backup @@ -10,28 +10,6 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -#REMOVEME? ynh_clean_setup () { - true -} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -#REMOVEME? ynh_print_info --message="Loading installation settings..." - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) -#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) -#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) -#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir) - #================================================= # DECLARE DATA AND CONF FILES TO BACKUP #================================================= diff --git a/scripts/change_url b/scripts/change_url index df595fc..580cb19 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -9,18 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# RETRIEVE ARGUMENTS -#================================================= - -#REMOVEME? old_domain=$YNH_APP_OLD_DOMAIN -#REMOVEME? old_path=$YNH_APP_OLD_PATH - -#REMOVEME? new_domain=$YNH_APP_NEW_DOMAIN -#REMOVEME? new_path=$YNH_APP_NEW_PATH - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - #================================================= # LOAD SETTINGS #================================================= @@ -39,39 +27,6 @@ source /usr/share/yunohost/helpers #REMOVEME? redis_db=$(ynh_app_setting_get --app=$app --key=redis_db) #REMOVEME? key=$(ynh_app_setting_get --app=$app --key=key) -#================================================= -# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP -#================================================= -#REMOVEME? ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1 - -# Backup the current version of the app -#REMOVEME? ynh_backup_before_upgrade -#REMOVEME? ynh_clean_setup () { - # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. -#REMOVEME? ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" - - # Restore it if the upgrade fails -#REMOVEME? ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - -#================================================= -# CHECK WHICH PARTS SHOULD BE CHANGED -#================================================= - -#REMOVEME? change_domain=0 -#REMOVEME? if [ "$old_domain" != "$new_domain" ] -then - #REMOVEME? change_domain=1 -fi - -#REMOVEME? change_path=0 -#REMOVEME? if [ "$old_path" != "$new_path" ] -then - #REMOVEME? change_path=1 -fi - #================================================= # STANDARD MODIFICATIONS #================================================= @@ -90,30 +45,6 @@ ynh_script_progression --message="Updating NGINX web server configuration..." -- ynh_change_url_nginx_config -#REMOVEME? nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf - -# Change the path in the NGINX config file -if [ $change_path -eq 1 ] -then - # Make a backup of the original NGINX config file if modified -#REMOVEME? ynh_backup_if_checksum_is_different --file="$nginx_conf_path" - # Set global variables for NGINX helper -#REMOVEME? domain="$old_domain" -#REMOVEME? path="$new_path" - # Create a dedicated NGINX config -#REMOVEME? ynh_add_nginx_config -fi - -# Change the domain for NGINX -if [ $change_domain -eq 1 ] -then - # Delete file checksum for the old conf file location -#REMOVEME? ynh_delete_file_checksum --file="$nginx_conf_path" -#REMOVEME? mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf - # Store file checksum for the new config file location -#REMOVEME? ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" -fi - #================================================= # MODIFY THE CONFIG FILE #================================================= @@ -146,13 +77,6 @@ ynh_script_progression --message="Configuring Fail2Ban..." --weight=1 # Create a dedicated Fail2Ban config #REMOVEME? ynh_add_fail2ban_config --logpath="/var/log/nginx/$new_domain-access.log" --failregex=".* \"POST /api/v1/token/ HTTP/1.1\" 400 68.*$" --max_retry=5 -#================================================= -# RELOAD NGINX -#================================================= -#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1 - -#REMOVEME? #REMOVEME? ynh_systemd_action --service_name=nginx --action=reload - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/install b/scripts/install index 70ec02c..d64b102 100644 --- a/scripts/install +++ b/scripts/install @@ -9,95 +9,17 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -#REMOVEME? ynh_clean_setup () { - true -} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= -#REMOVEME? domain=$YNH_APP_ARG_DOMAIN -path="/" -#REMOVEME? is_public=$YNH_APP_ARG_IS_PUBLIC -#REMOVEME? admin=$YNH_APP_ARG_ADMIN - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - admin_mail=$(ynh_user_get_info --username="$admin" --key="mail") -#================================================= -# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS -#================================================= -#REMOVEME? ynh_script_progression --message="Validating installation parameters..." --weight=1 - -#REMOVEME? install_dir=/var/www/$app -#REMOVEME? test ! -e "$install_dir" || ynh_die --message="This path already contains a folder" - -#REMOVEME? data_dir=/home/yunohost.app/$app/data - -# Register (book) web path -#REMOVEME? ynh_webpath_register --app=$app --domain=$domain --path=$path - -#================================================= -# STORE SETTINGS FROM MANIFEST -#================================================= -#REMOVEME? ynh_script_progression --message="Storing installation settings..." --weight=1 - -#REMOVEME? ynh_app_setting_set --app=$app --key=domain --value=$domain -#REMOVEME? ynh_app_setting_set --app=$app --key=path --value=$path -#REMOVEME? ynh_app_setting_set --app=$app --key=admin --value=$admin - -#================================================= -# STANDARD MODIFICATIONS -#================================================= -# FIND AND OPEN A PORT -#================================================= -#REMOVEME? ynh_script_progression --message="Finding an available port..." --weight=1 - -# Find an available port -#REMOVEME? port=$(ynh_find_port --port=8095) -#REMOVEME? ynh_app_setting_set --app=$app --key=port --value=$port - -#================================================= -# INSTALL DEPENDENCIES -#================================================= -#REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=1 - -#REMOVEME? ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies - -#================================================= -# CREATE DEDICATED USER -#================================================= -#REMOVEME? ynh_script_progression --message="Configuring system user..." --weight=1 - -# Create a system user -#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" - -#================================================= -# CREATE A POSTGRESQL DATABASE -#================================================= -#REMOVEME? ynh_script_progression --message="Creating a PostgreSQL database..." --weight=1 - -#REMOVEME? ynh_psql_test_if_first_run -#REMOVEME? db_name=$(ynh_sanitize_dbid --db_name=$app) -#REMOVEME? db_user=$db_name -#REMOVEME? ynh_app_setting_set --app=$app --key=db_name --value=$db_name -#REMOVEME? ynh_psql_setup_db --db_user=$db_user --db_name=$db_name -#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Setting up source files..." --weight=1 -#REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir/api" --source_id="api" ynh_setup_source --dest_dir="$install_dir/front" --source_id="front" @@ -123,9 +45,6 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Creating a data directory..." --weight=1 -#REMOVEME? ynh_app_setting_set --app=$app --key=data_dir --value=$data_dir - -mkdir -p $data_dir mkdir -p $data_dir/{static,media,music} chmod 750 "$data_dir" @@ -163,7 +82,7 @@ ynh_add_systemd_config --service="${app}-beat" --template="funkwhale-beat.serv #================================================= # INSTALL PYTHON DEPENDENCIES #================================================= -#REMOVEME? ynh_script_progression --message="Installing Python dependencies..." --weight=1 +ynh_script_progression --message="Installing Python dependencies..." --weight=1 pushd $install_dir python3 -m venv $install_dir/virtualenv @@ -225,26 +144,6 @@ ynh_script_progression --message="Configuring Fail2Ban..." --weight=1 # Create a dedicated Fail2Ban config ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-access.log" --failregex=".* \"POST /api/v1/token/ HTTP/1.1\" 400 68.*$" --max_retry=5 -#================================================= -# SETUP SSOWAT -#================================================= -#REMOVEME? ynh_script_progression --message="Configuring permissions..." --weight=1 - -# Make app public if necessary -#REMOVEME? if [ $is_public -eq 1 ] -then - # Everyone can access the app. - # The "main" permission is automatically created before the install script. -#REMOVEME? ynh_permission_update --permission="main" --add="visitors" -fi - -#================================================= -# RELOAD NGINX -#================================================= -#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1 - -#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/remove b/scripts/remove index 78a140b..cafe155 100644 --- a/scripts/remove +++ b/scripts/remove @@ -9,21 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1 - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) -#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port) -#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) -#REMOVEME? db_user=$db_name -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) -#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir) -#REMOVEME? redis_db=$(ynh_app_setting_get --app=$app --key=redis_db) - #================================================= # STANDARD REMOVE #================================================= @@ -65,33 +50,6 @@ ynh_remove_systemd_config --service="${app}-worker" ynh_secure_remove --file="/etc/systemd/system/$app.target" -#================================================= -# REMOVE THE POSTGRESQL DATABASE -#================================================= -#REMOVEME? ynh_script_progression --message="Removing the PostgreSQL database..." --weight=1 - -# Remove a database if it exists, along with the associated user -#REMOVEME? ynh_psql_remove_db --db_user=$db_user --db_name=$db_name - -#================================================= -# REMOVE APP MAIN DIR -#================================================= -#REMOVEME? ynh_script_progression --message="Removing app main directory..." --weight=1 - -# Remove the app directory securely -#REMOVEME? ynh_secure_remove --file="$install_dir" - -#================================================= -# REMOVE DATA DIR -#================================================= - -# Remove the data directory if --purge option is used -if [ "${YNH_APP_PURGE:-0}" -eq 1 ] -then - ynh_script_progression --message="Removing app data directory..." --weight=1 -#REMOVEME? ynh_secure_remove --file="$data_dir" -fi - #================================================= # REMOVE NGINX CONFIGURATION #================================================= @@ -100,14 +58,6 @@ ynh_script_progression --message="Removing NGINX web server configuration..." -- # Remove the dedicated NGINX config ynh_remove_nginx_config -#================================================= -# REMOVE DEPENDENCIES -#================================================= -#REMOVEME? ynh_script_progression --message="Removing dependencies..." --weight=1 - -# Remove metapackage and its dependencies -#REMOVEME? ynh_remove_app_dependencies - #================================================= # REMOVE FAIL2BAN CONFIGURATION #================================================= @@ -126,16 +76,6 @@ ynh_script_progression --message="Removing the Redis database..." --weight=1 # Remove a database if it exists, along with the associated user ynh_redis_remove_db $redis_db -#================================================= -# GENERIC FINALIZATION -#================================================= -# REMOVE DEDICATED USER -#================================================= -#REMOVEME? ynh_script_progression --message="Removing the dedicated system user..." --weight=1 - -# Delete a system user -#REMOVEME? ynh_system_user_delete --username=$app - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index f67d7eb..939c888 100644 --- a/scripts/restore +++ b/scripts/restore @@ -10,48 +10,6 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -#REMOVEME? ynh_clean_setup () { - true -} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1 - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) -#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) -#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) -#REMOVEME? db_user=$db_name -#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir) - -#================================================= -# CHECK IF THE APP CAN BE RESTORED -#================================================= -#REMOVEME? ynh_script_progression --message="Validating restoration parameters..." --weight=1 - -#REMOVEME? test ! -d $install_dir \ - || ynh_die --message="There is already a directory: $install_dir " - -#================================================= -# STANDARD RESTORATION STEPS -#================================================= -# RECREATE THE DEDICATED USER -#================================================= -#REMOVEME? ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 - -# Create the dedicated user (if not existing) -#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" - #================================================= # RESTORE THE APP MAIN DIR #================================================= @@ -59,7 +17,6 @@ ynh_script_progression --message="Restoring the app main directory..." --weight= ynh_restore_file --origin_path="$install_dir" -chmod 750 "$install_dir" chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" @@ -70,24 +27,12 @@ ynh_script_progression --message="Restoring the data directory..." --weight=1 ynh_restore_file --origin_path="$data_dir" --not_mandatory -mkdir -p $data_dir - mkdir -p $data_dir/{static,media,music} chmod 750 "$data_dir" chmod -R o-rwx "$data_dir" chown -R $app:www-data "$data_dir" -#================================================= -# SPECIFIC RESTORATION -#================================================= -# REINSTALL DEPENDENCIES -#================================================= -#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." --weight=1 - -# Define and install dependencies -#REMOVEME? ynh_install_app_dependencies $pkg_dependencies - #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= @@ -98,11 +43,8 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RESTORE THE POSTGRESQL DATABASE #================================================= -#REMOVEME? ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1 +ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1 -#REMOVEME? ynh_psql_test_if_first_run -#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) -#REMOVEME? ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index f359620..0543be1 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,45 +9,12 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1 - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) -#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) -#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) -#REMOVEME? db_user=$db_name -#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) -#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir) -#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port) -#REMOVEME? redis_db=$(ynh_app_setting_get --app=$app --key=redis_db) -#REMOVEME? key=$(ynh_app_setting_get --app=$app --key=key) - #================================================= # CHECK VERSION #================================================= -ynh_script_progression --message="Checking version..." --weight=1 upgrade_type=$(ynh_check_app_version_changed) -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -#REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1 - -# Backup the current version of the app -#REMOVEME? ynh_backup_before_upgrade -#REMOVEME? ynh_clean_setup () { - # Restore it if the upgrade fails -#REMOVEME? ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - #================================================= # STANDARD UPGRADE STEPS #================================================= @@ -59,30 +26,6 @@ ynh_systemd_action --action="stop" --service_name="${app}-beat" --log_path="syst ynh_systemd_action --action="stop" --service_name="${app}-server" --log_path="systemd" --line_match="Stopped" ynh_systemd_action --action="stop" --service_name="${app}-worker" --log_path="systemd" --line_match="Stopped" -#================================================= -# ENSURE DOWNWARD COMPATIBILITY -#================================================= -ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 - -# If redis_db doesn't exist, create it -if [ -z "$redis_db" ]; then - redis_db=$(ynh_redis_get_free_db) - ynh_app_setting_set --app=$app --key=redis_db --value=$redis_db -fi - -# If db_pwd doesn't exist, create it -if [ -z "$db_pwd" ]; then -#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) -#REMOVEME? ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd -fi - -# Cleaning legacy permissions -#REMOVEME? if ynh_legacy_permissions_exists; then -#REMOVEME? ynh_legacy_permissions_delete_all - - ynh_app_setting_delete --app=$app --key=is_public -fi - #================================================= # MOVE DATAS #================================================= @@ -140,14 +83,6 @@ if [ -z "$data_dir" ]; then upgrade_type="UPGRADE_APP" fi -#================================================= -# CREATE DEDICATED USER -#================================================= -#REMOVEME? ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 - -# Create a dedicated user (if not existing) -#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -156,8 +91,6 @@ if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_script_progression --message="Upgrading source files..." --weight=1 -#REMOVEME? ynh_secure_remove --file="$install_dir/api" -#REMOVEME? ynh_secure_remove --file="$install_dir/front" # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir/api" --source_id="api" ynh_setup_source --dest_dir="$install_dir/front" --source_id="front" @@ -167,13 +100,6 @@ chmod 750 "$install_dir" chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" -#================================================= -# UPGRADE DEPENDENCIES -#================================================= -#REMOVEME? ynh_script_progression --message="Upgrading dependencies..." --weight=1 - -#REMOVEME? ynh_install_app_dependencies $pkg_dependencies - #================================================= # NGINX CONFIGURATION #================================================= @@ -187,10 +113,10 @@ ynh_add_nginx_config #================================================= # INSTALL PYTHON DEPENDENCIES #================================================= -#REMOVEME? ynh_script_progression --message="Installing Python dependencies..." --weight=1 +ynh_script_progression --message="Installing Python dependencies..." --weight=1 pushd $install_dir -#REMOVEME? ynh_secure_remove --file="$install_dir/virtualenv" +ynh_secure_remove --file="$install_dir/virtualenv" python3 -m venv $install_dir/virtualenv source $install_dir/virtualenv/bin/activate pip install --upgrade pip @@ -272,13 +198,6 @@ ynh_script_progression --message="Reconfiguring Fail2Ban..." --weight=1 # Create a dedicated Fail2Ban config ynh_add_fail2ban_config --logpath="/var/log/nginx/$domain-access.log" --failregex=".* \"POST /api/v1/token/ HTTP/1.1\" 400 68.*$" --max_retry=5 -#================================================= -# RELOAD NGINX -#================================================= -#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1 - -#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload - #================================================= # END OF SCRIPT #================================================= diff --git a/tests.toml b/tests.toml new file mode 100644 index 0000000..44c9cd3 --- /dev/null +++ b/tests.toml @@ -0,0 +1,7 @@ +test_format = 1.0 + +[default] + + exclude = ["install.nourl"] + + test_upgrade_from.557386e0.name = "Upgrade from 1.2.7" From 615563479e329b9e1de544d30ecf513255de0f56 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Fri, 24 Mar 2023 11:31:58 +0000 Subject: [PATCH 03/30] Auto-update README --- README.md | 14 -------------- README_fr.md | 12 ------------ 2 files changed, 26 deletions(-) diff --git a/README.md b/README.md index 0330a74..03b8a29 100644 --- a/README.md +++ b/README.md @@ -26,20 +26,6 @@ Funkwhale is a community-driven project that lets you listen and share music and ![Screenshot of Funkwhale](./doc/screenshots/screenshot1.png) -## Disclaimers / important information - -* Installation requires a dedicated domain or subdomain. Installing in a subpath is not supported by the upstream project due to dependency requirements. - -* Admin - * The admin uses the login you provided at installation. The password is the same you use for YunoHost. - * The admin interface is accessible at the address: `your.domain.fr/api/admin` - -To add a collection of music files to a library in your YunoHost installation of Funkwhale, create a symlink to your collection titled "music" in `/home/yunohost.app/funkwhale/data` -```console -foo@bar:~$sudo ln -s /your/music/collection /home/yunohost.app/funkwhale/data/music -``` -The files can then be added to your library from the *uploading* tab in a music library under the heading **Import music from your server**. - ## Documentation and resources * Official app website: diff --git a/README_fr.md b/README_fr.md index 60f2c8f..71c96b1 100644 --- a/README_fr.md +++ b/README_fr.md @@ -26,18 +26,6 @@ Funkwhale est un projet communautaire qui vous permet d'écouter et de partager ![Capture d’écran de Funkwhale](./doc/screenshots/screenshot1.png) -## Avertissements / informations importantes - -* L'installation nécessite un domaine ou un sous-domaine dédié. L'installation dans un chemin du domaine n'est pas prise en charge par le projet en amont en raison des exigences de dépendance. - -* Admin - * L'administrateur utilise le login que vous avez fourni lors de l'installation. Le mot de passe est le même que celui que vous utilisez pour YunoHost. - * L'interface d'administration est accessible à l'adresse : votre.domaine.fr/api/admin - -Pour ajouter une collection de fichiers musicaux à une bibliothèque dans votre installation YunoHost de Funkwhale, créez un lien symbolique vers votre collection intitulée "music" dans `/home/yunohost.app/funkwhale/data/`. -`foo@bar:~$sudo ln -s /your/music/collection /home/yunohost.app/funkwhale/data/music` -Les fichiers peuvent ensuite être ajoutés à votre bibliothèque à partir de l'onglet *Envoi* dans une bibliothèque musicale sous la rubrique **Importer de la musique de votre serveur**. - ## Documentations et ressources * Site officiel de l’app : From 3ae6c0a0dde865f1f37a0b17cae3e8acffdea16b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Fri, 24 Mar 2023 20:18:47 +0100 Subject: [PATCH 04/30] Update manifest.toml --- manifest.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifest.toml b/manifest.toml index 1da73f0..9282212 100644 --- a/manifest.toml +++ b/manifest.toml @@ -45,11 +45,11 @@ ram.runtime = "50M" [resources.sources] [resources.sources.api] url = "https://dev.funkwhale.audio/funkwhale/funkwhale/-/jobs/artifacts/1.2.10/download?job=build_api" - sha256 = "2544fa01bc64c7481dbd03faaa777ff6d2006e6a36cb79c694e13f6e2761f025" + sha256 = "4a0c0cdd8afc72b3fa9be7019392b3c27d819cf240509234b355231e1c59a11d" [resources.sources.front] url = "https://dev.funkwhale.audio/funkwhale/funkwhale/builds/artifacts/1.2.10/download?job=build_front" - sha256 = "6471722068ac6586194ee2c28d0691a2acdcb1eae881625fcf15c10a750bb51a" + sha256 = "9fa6b373fd1baf0f4509eece67380c092dfb8889972db8018f9acc840284b011" [resources.ports] From 4d03bbf329ba05c5a3a1c824faee2107fed7eea1 Mon Sep 17 00:00:00 2001 From: Thomas <51749973+Thovi98@users.noreply.github.com> Date: Mon, 27 Mar 2023 20:13:05 +0200 Subject: [PATCH 05/30] fix shasum one more time :/ --- manifest.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifest.toml b/manifest.toml index 9282212..c8f418b 100644 --- a/manifest.toml +++ b/manifest.toml @@ -45,11 +45,11 @@ ram.runtime = "50M" [resources.sources] [resources.sources.api] url = "https://dev.funkwhale.audio/funkwhale/funkwhale/-/jobs/artifacts/1.2.10/download?job=build_api" - sha256 = "4a0c0cdd8afc72b3fa9be7019392b3c27d819cf240509234b355231e1c59a11d" + sha256 = "fc6f54d37993f74e057d1a59438e21b68a8cff1a7f9438415459ede7cf7f09d0" [resources.sources.front] url = "https://dev.funkwhale.audio/funkwhale/funkwhale/builds/artifacts/1.2.10/download?job=build_front" - sha256 = "9fa6b373fd1baf0f4509eece67380c092dfb8889972db8018f9acc840284b011" + sha256 = "bcf0ba380295be58dfcfe4d88605cfce357859adf623c8236fb1182095c38bfd" [resources.ports] From f50cc2428226a23ad6f3de205ecb0f25a3cf7d24 Mon Sep 17 00:00:00 2001 From: Thomas <51749973+Thovi98@users.noreply.github.com> Date: Mon, 27 Mar 2023 20:39:00 +0200 Subject: [PATCH 06/30] test --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index d64b102..f660a12 100644 --- a/scripts/install +++ b/scripts/install @@ -91,7 +91,7 @@ pushd $install_dir pip install --upgrade setuptools ynh_exec_warn_less pip install wheel # Workaround for error AttributeError: module 'lib' has no attribute 'X509_V_FLAG_CB_ISSUER_CHECK' - ynh_replace_string --match_string="pyOpenSSL~=20.0.1" --replace_string="pyOpenSSL~=21.0.0" --target_file="$install_dir/api/requirements/base.txt" + # ynh_replace_string --match_string="pyOpenSSL~=20.0.1" --replace_string="pyOpenSSL~=21.0.0" --target_file="$install_dir/api/requirements/base.txt" ynh_exec_warn_less pip install -r api/requirements.txt popd From d4e11b3be65bf25baa8e797c7d52c6938d5ba2c2 Mon Sep 17 00:00:00 2001 From: Thomas <51749973+Thovi98@users.noreply.github.com> Date: Mon, 27 Mar 2023 20:49:28 +0200 Subject: [PATCH 07/30] test --- scripts/install | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/install b/scripts/install index f660a12..2937915 100644 --- a/scripts/install +++ b/scripts/install @@ -90,6 +90,10 @@ pushd $install_dir pip install --upgrade pip pip install --upgrade setuptools ynh_exec_warn_less pip install wheel + + ls -lah /$install_dir/ + ls -lah /$install_dir/api/ + ls -lah /$install_dir/front/ # Workaround for error AttributeError: module 'lib' has no attribute 'X509_V_FLAG_CB_ISSUER_CHECK' # ynh_replace_string --match_string="pyOpenSSL~=20.0.1" --replace_string="pyOpenSSL~=21.0.0" --target_file="$install_dir/api/requirements/base.txt" ynh_exec_warn_less pip install -r api/requirements.txt From 83f704f26ce234435ef2caea0f321118bc844e86 Mon Sep 17 00:00:00 2001 From: Thomas <51749973+Thovi98@users.noreply.github.com> Date: Mon, 27 Mar 2023 21:00:13 +0200 Subject: [PATCH 08/30] further tests --- manifest.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/manifest.toml b/manifest.toml index c8f418b..36f2cdc 100644 --- a/manifest.toml +++ b/manifest.toml @@ -46,10 +46,14 @@ ram.runtime = "50M" [resources.sources.api] url = "https://dev.funkwhale.audio/funkwhale/funkwhale/-/jobs/artifacts/1.2.10/download?job=build_api" sha256 = "fc6f54d37993f74e057d1a59438e21b68a8cff1a7f9438415459ede7cf7f09d0" + in_subdir = true + extract = true [resources.sources.front] url = "https://dev.funkwhale.audio/funkwhale/funkwhale/builds/artifacts/1.2.10/download?job=build_front" sha256 = "bcf0ba380295be58dfcfe4d88605cfce357859adf623c8236fb1182095c38bfd" + in_subdir = true + extract = true [resources.ports] From 1860e3535d795399dd313f75eddd4465a805d5ec Mon Sep 17 00:00:00 2001 From: Thomas <51749973+Thovi98@users.noreply.github.com> Date: Mon, 27 Mar 2023 21:10:09 +0200 Subject: [PATCH 09/30] further tests --- manifest.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/manifest.toml b/manifest.toml index 36f2cdc..f640a15 100644 --- a/manifest.toml +++ b/manifest.toml @@ -48,12 +48,14 @@ ram.runtime = "50M" sha256 = "fc6f54d37993f74e057d1a59438e21b68a8cff1a7f9438415459ede7cf7f09d0" in_subdir = true extract = true + format = zip [resources.sources.front] url = "https://dev.funkwhale.audio/funkwhale/funkwhale/builds/artifacts/1.2.10/download?job=build_front" sha256 = "bcf0ba380295be58dfcfe4d88605cfce357859adf623c8236fb1182095c38bfd" in_subdir = true extract = true + format = zip [resources.ports] From c936fcb03c1d13755bac0a75438cb62ed02927ae Mon Sep 17 00:00:00 2001 From: Thomas <51749973+Thovi98@users.noreply.github.com> Date: Mon, 27 Mar 2023 21:14:08 +0200 Subject: [PATCH 10/30] fix --- manifest.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifest.toml b/manifest.toml index f640a15..72ff53c 100644 --- a/manifest.toml +++ b/manifest.toml @@ -48,14 +48,14 @@ ram.runtime = "50M" sha256 = "fc6f54d37993f74e057d1a59438e21b68a8cff1a7f9438415459ede7cf7f09d0" in_subdir = true extract = true - format = zip + format = "zip" [resources.sources.front] url = "https://dev.funkwhale.audio/funkwhale/funkwhale/builds/artifacts/1.2.10/download?job=build_front" sha256 = "bcf0ba380295be58dfcfe4d88605cfce357859adf623c8236fb1182095c38bfd" in_subdir = true extract = true - format = zip + format = "zip" [resources.ports] From db915eb0430157bf7fc76c162f49635b5f48ed08 Mon Sep 17 00:00:00 2001 From: Thomas <51749973+Thovi98@users.noreply.github.com> Date: Mon, 27 Mar 2023 21:24:04 +0200 Subject: [PATCH 11/30] final fix for v2 ? --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 2937915..5ca688e 100644 --- a/scripts/install +++ b/scripts/install @@ -95,7 +95,7 @@ pushd $install_dir ls -lah /$install_dir/api/ ls -lah /$install_dir/front/ # Workaround for error AttributeError: module 'lib' has no attribute 'X509_V_FLAG_CB_ISSUER_CHECK' - # ynh_replace_string --match_string="pyOpenSSL~=20.0.1" --replace_string="pyOpenSSL~=21.0.0" --target_file="$install_dir/api/requirements/base.txt" + ynh_replace_string --match_string="pyOpenSSL~=20.0.1" --replace_string="pyOpenSSL~=21.0.0" --target_file="$install_dir/api/requirements/base.txt" ynh_exec_warn_less pip install -r api/requirements.txt popd From ff8a084b0e05668840fa015fe662b24c0e4ddf4b Mon Sep 17 00:00:00 2001 From: Thomas <51749973+Thovi98@users.noreply.github.com> Date: Mon, 27 Mar 2023 21:31:51 +0200 Subject: [PATCH 12/30] cleanups --- scripts/install | 4 ---- 1 file changed, 4 deletions(-) diff --git a/scripts/install b/scripts/install index 5ca688e..d64b102 100644 --- a/scripts/install +++ b/scripts/install @@ -90,10 +90,6 @@ pushd $install_dir pip install --upgrade pip pip install --upgrade setuptools ynh_exec_warn_less pip install wheel - - ls -lah /$install_dir/ - ls -lah /$install_dir/api/ - ls -lah /$install_dir/front/ # Workaround for error AttributeError: module 'lib' has no attribute 'X509_V_FLAG_CB_ISSUER_CHECK' ynh_replace_string --match_string="pyOpenSSL~=20.0.1" --replace_string="pyOpenSSL~=21.0.0" --target_file="$install_dir/api/requirements/base.txt" ynh_exec_warn_less pip install -r api/requirements.txt From 9ba3d6d78e9039294f1c36656ba4651529f9c0b4 Mon Sep 17 00:00:00 2001 From: Thomas <51749973+Thovi98@users.noreply.github.com> Date: Mon, 27 Mar 2023 21:36:26 +0200 Subject: [PATCH 13/30] adapt tests --- tests.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests.toml b/tests.toml index 44c9cd3..1cffbea 100644 --- a/tests.toml +++ b/tests.toml @@ -5,3 +5,5 @@ test_format = 1.0 exclude = ["install.nourl"] test_upgrade_from.557386e0.name = "Upgrade from 1.2.7" + test_upgrade_from.7a50028.name = "Upgrade from 1.2.9" + test_upgrade_from.0373f8c.name = "Upgrade from 1.2.10~ynh1" From e3739748dbe3ee1e0126c1ce233d8f83d4e5dbc3 Mon Sep 17 00:00:00 2001 From: Thomas <51749973+Thovi98@users.noreply.github.com> Date: Mon, 27 Mar 2023 22:02:35 +0200 Subject: [PATCH 14/30] upgrade ~ynh --- manifest.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.toml b/manifest.toml index 72ff53c..c2c1c01 100644 --- a/manifest.toml +++ b/manifest.toml @@ -5,7 +5,7 @@ name = "Funkwhale" description.en = "Convivial and modern music server" description.fr = "Serveur de musique moderne et convivial" -version = "1.2.10~ynh1" +version = "1.2.10~ynh3" maintainers = ["Ciarán Ainsworth"] From dd8c130776b66d25e44c0a35839b9050813fe4f6 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Mon, 27 Mar 2023 20:05:45 +0000 Subject: [PATCH 15/30] Auto-update README --- README.md | 2 +- README_fr.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 03b8a29..1c0266d 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in Funkwhale is a community-driven project that lets you listen and share music and audio within a decentralized, open network. -**Shipped version:** 1.2.10~ynh2 +**Shipped version:** 1.2.10~ynh3 **Demo:** https://demo.funkwhale.audio diff --git a/README_fr.md b/README_fr.md index 71c96b1..2c5360c 100644 --- a/README_fr.md +++ b/README_fr.md @@ -18,7 +18,7 @@ Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po Funkwhale est un projet communautaire qui vous permet d'écouter et de partager de la musique et de l'audio au sein d'un réseau ouvert et décentralisé. -**Version incluse :** 1.2.10~ynh2 +**Version incluse :** 1.2.10~ynh3 **Démo :** https://demo.funkwhale.audio From 8592610b0f80e7ef9e65cb4a0a8ba8d6004fc6bf Mon Sep 17 00:00:00 2001 From: Thomas <51749973+Thovi98@users.noreply.github.com> Date: Mon, 27 Mar 2023 22:32:44 +0200 Subject: [PATCH 16/30] Test pip install toml for fail2ban --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index d64b102..28db172 100644 --- a/scripts/install +++ b/scripts/install @@ -89,7 +89,7 @@ pushd $install_dir source $install_dir/virtualenv/bin/activate pip install --upgrade pip pip install --upgrade setuptools - ynh_exec_warn_less pip install wheel + ynh_exec_warn_less pip install wheel toml # Workaround for error AttributeError: module 'lib' has no attribute 'X509_V_FLAG_CB_ISSUER_CHECK' ynh_replace_string --match_string="pyOpenSSL~=20.0.1" --replace_string="pyOpenSSL~=21.0.0" --target_file="$install_dir/api/requirements/base.txt" ynh_exec_warn_less pip install -r api/requirements.txt From 4169d787b394774cedb62a00e21ec3e0795dd77f Mon Sep 17 00:00:00 2001 From: Thomas <51749973+Thovi98@users.noreply.github.com> Date: Mon, 27 Mar 2023 23:27:42 +0200 Subject: [PATCH 17/30] fix fail2ban --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 0543be1..f659a84 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -121,7 +121,7 @@ ynh_secure_remove --file="$install_dir/virtualenv" source $install_dir/virtualenv/bin/activate pip install --upgrade pip pip install --upgrade setuptools - ynh_exec_warn_less pip install wheel + ynh_exec_warn_less pip install wheel toml # Workaround for error AttributeError: module 'lib' has no attribute 'X509_V_FLAG_CB_ISSUER_CHECK' ynh_replace_string --match_string="pyOpenSSL~=20.0.1" --replace_string="pyOpenSSL~=21.0.0" --target_file="$install_dir/api/requirements/base.txt" ynh_exec_warn_less pip install -r api/requirements.txt From cec5cd3493b0333ebf56a34bb0809ebafb831b3f Mon Sep 17 00:00:00 2001 From: Thomas <51749973+Thovi98@users.noreply.github.com> Date: Mon, 27 Mar 2023 23:28:53 +0200 Subject: [PATCH 18/30] modify test commit for 1.2.10 because of wrong sources --- tests.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests.toml b/tests.toml index 1cffbea..0c597f0 100644 --- a/tests.toml +++ b/tests.toml @@ -6,4 +6,4 @@ test_format = 1.0 test_upgrade_from.557386e0.name = "Upgrade from 1.2.7" test_upgrade_from.7a50028.name = "Upgrade from 1.2.9" - test_upgrade_from.0373f8c.name = "Upgrade from 1.2.10~ynh1" + test_upgrade_from.945e3d4.name = "Upgrade from 1.2.10~ynh1" From 73b3dffea71861cc5484867e82a265cbd392fffd Mon Sep 17 00:00:00 2001 From: Thomas <51749973+Thovi98@users.noreply.github.com> Date: Mon, 27 Mar 2023 23:31:07 +0200 Subject: [PATCH 19/30] Remove 1.2.7 tests because cannot install --- tests.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/tests.toml b/tests.toml index 0c597f0..c60f8ef 100644 --- a/tests.toml +++ b/tests.toml @@ -4,6 +4,5 @@ test_format = 1.0 exclude = ["install.nourl"] - test_upgrade_from.557386e0.name = "Upgrade from 1.2.7" test_upgrade_from.7a50028.name = "Upgrade from 1.2.9" test_upgrade_from.945e3d4.name = "Upgrade from 1.2.10~ynh1" From 16fa6f9df4b3673ec809117506ca0923da00126d Mon Sep 17 00:00:00 2001 From: Thomas <51749973+Thovi98@users.noreply.github.com> Date: Wed, 29 Mar 2023 19:35:56 +0200 Subject: [PATCH 20/30] apply suggestions --- scripts/change_url | 28 +--------------------------- scripts/upgrade | 12 +++++------- 2 files changed, 6 insertions(+), 34 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 580cb19..673e8a1 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -9,24 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1 - -#REMOVEME? # Needed for helper "ynh_add_nginx_config" -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) -#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port) -#REMOVEME? key=$(ynh_app_setting_get --app=$app --key=key) -#REMOVEME? redis_db=$(ynh_app_setting_get --app=$app --key=redis_db) -#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port) -#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) -#REMOVEME? db_user=$db_name -#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) -#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir) -#REMOVEME? redis_db=$(ynh_app_setting_get --app=$app --key=redis_db) -#REMOVEME? key=$(ynh_app_setting_get --app=$app --key=key) - #================================================= # STANDARD MODIFICATIONS #================================================= @@ -49,7 +31,7 @@ ynh_change_url_nginx_config # MODIFY THE CONFIG FILE #================================================= ynh_script_progression --message="Modifying a config file..." --weight=1 -#REMOVEME? + domain=$new_domain ynh_add_config --template="../conf/env.prod" --destination="$install_dir/config/.env" @@ -69,14 +51,6 @@ ynh_systemd_action --service_name="$app-beat" --action="start" --log_path="/var/ ynh_systemd_action --service_name="$app-server" --action="start" --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name="$app-worker" --action="start" --log_path="/var/log/$app/$app.log" -#================================================= -# SETUP FAIL2BAN -#================================================= -ynh_script_progression --message="Configuring Fail2Ban..." --weight=1 - -# Create a dedicated Fail2Ban config -#REMOVEME? ynh_add_fail2ban_config --logpath="/var/log/nginx/$new_domain-access.log" --failregex=".* \"POST /api/v1/token/ HTTP/1.1\" 400 68.*$" --max_retry=5 - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index f659a84..913437c 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -68,13 +68,11 @@ if [ -z "$data_dir" ]; then rsync -a $install_dir/code/data/music/ $data_dir/music/ fi -#REMOVEME? ynh_secure_remove --file="$install_dir/code" -#REMOVEME? ynh_secure_remove --file="$install_dir/media" -#REMOVEME? ynh_secure_remove --file="$install_dir/code/data/media" -#REMOVEME? ynh_secure_remove --file="$install_dir/import" -#REMOVEME? ynh_secure_remove --file="$install_dir/code/data/music" - -#REMOVEME? ynh_app_setting_set --app=$app --key=data_dir --value=$data_dir + ynh_secure_remove --file="$install_dir/code" + ynh_secure_remove --file="$install_dir/media" + ynh_secure_remove --file="$install_dir/code/data/media" + ynh_secure_remove --file="$install_dir/import" + ynh_secure_remove --file="$install_dir/code/data/music" chmod 750 "$data_dir" chmod -R o-rwx "$data_dir" From c28149e00179d1a3f4035e289980c158e88753ea Mon Sep 17 00:00:00 2001 From: Thomas <51749973+Thovi98@users.noreply.github.com> Date: Wed, 29 Mar 2023 22:22:10 +0200 Subject: [PATCH 21/30] Fix data_dir --- manifest.toml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/manifest.toml b/manifest.toml index c2c1c01..e41f689 100644 --- a/manifest.toml +++ b/manifest.toml @@ -64,7 +64,9 @@ ram.runtime = "50M" [resources.install_dir] [resources.data_dir] - + dir = "/home/yunohost.app/__APP__" + owner = "__APP__:www-data" + [resources.permissions] main.url = "/" From 14449adb373b555a4118e034f4f91b2a306aadf4 Mon Sep 17 00:00:00 2001 From: Thomas <51749973+Thovi98@users.noreply.github.com> Date: Wed, 29 Mar 2023 23:32:14 +0200 Subject: [PATCH 22/30] refix data_dir --- manifest.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.toml b/manifest.toml index e41f689..5aac6fb 100644 --- a/manifest.toml +++ b/manifest.toml @@ -64,7 +64,7 @@ ram.runtime = "50M" [resources.install_dir] [resources.data_dir] - dir = "/home/yunohost.app/__APP__" + dir = "/home/yunohost.app/__APP__/data" owner = "__APP__:www-data" [resources.permissions] From 6d58ed46fdae8b4fd7e15e1b6d43813ebe5b5eee Mon Sep 17 00:00:00 2001 From: Thomas <51749973+Thovi98@users.noreply.github.com> Date: Thu, 30 Mar 2023 20:59:37 +0200 Subject: [PATCH 23/30] fix data_dir/data/ --- manifest.toml | 2 -- scripts/install | 9 +++++---- scripts/restore | 10 +++++----- scripts/upgrade | 8 ++++---- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/manifest.toml b/manifest.toml index 5aac6fb..5b06bef 100644 --- a/manifest.toml +++ b/manifest.toml @@ -64,8 +64,6 @@ ram.runtime = "50M" [resources.install_dir] [resources.data_dir] - dir = "/home/yunohost.app/__APP__/data" - owner = "__APP__:www-data" [resources.permissions] main.url = "/" diff --git a/scripts/install b/scripts/install index 28db172..9c8e64f 100644 --- a/scripts/install +++ b/scripts/install @@ -45,11 +45,12 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Creating a data directory..." --weight=1 -mkdir -p $data_dir/{static,media,music} +mkdir -p $data_dir/data +mkdir -p $data_dir/data/{static,media,music} -chmod 750 "$data_dir" -chmod -R o-rwx "$data_dir" -chown -R $app:www-data "$data_dir" +chmod 750 "$data_dir/data/" +chmod -R o-rwx "$data_dir/data/" +chown -R $app:www-data "$data_dir/data/" #================================================= # ADD A CONFIGURATION diff --git a/scripts/restore b/scripts/restore index 939c888..7b7f1d3 100644 --- a/scripts/restore +++ b/scripts/restore @@ -25,13 +25,13 @@ chown -R $app:www-data "$install_dir" #================================================= ynh_script_progression --message="Restoring the data directory..." --weight=1 -ynh_restore_file --origin_path="$data_dir" --not_mandatory +ynh_restore_file --origin_path="$data_dir/data/" --not_mandatory -mkdir -p $data_dir/{static,media,music} +mkdir -p $data_dir/data/{static,media,music} -chmod 750 "$data_dir" -chmod -R o-rwx "$data_dir" -chown -R $app:www-data "$data_dir" +chmod 750 "$data_dir/data/" +chmod -R o-rwx "$data_dir/data/" +chown -R $app:www-data "$data_dir/data/" #================================================= # RESTORE THE NGINX CONFIGURATION diff --git a/scripts/upgrade b/scripts/upgrade index 913437c..01b3d2a 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -31,7 +31,7 @@ ynh_systemd_action --action="stop" --service_name="${app}-worker" --log_path="sy #================================================= # If data_dir doesn't exist, create it -if [ -z "$data_dir" ]; then +if [ -z "$data_dir/data/" ]; then # Do a full backup before moving datas yunohost backup create --apps $app @@ -74,9 +74,9 @@ if [ -z "$data_dir" ]; then ynh_secure_remove --file="$install_dir/import" ynh_secure_remove --file="$install_dir/code/data/music" - chmod 750 "$data_dir" - chmod -R o-rwx "$data_dir" - chown -R $app:www-data "$data_dir" + chmod 750 "$data_dir/data/" + chmod -R o-rwx "$data_dir/data/" + chown -R $app:www-data "$data_dir/data/" upgrade_type="UPGRADE_APP" fi From 282da0d337bca44c1055e3bf1929127089f9e9ec Mon Sep 17 00:00:00 2001 From: Thomas <51749973+Thovi98@users.noreply.github.com> Date: Thu, 30 Mar 2023 21:01:54 +0200 Subject: [PATCH 24/30] fix nginx --- conf/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index f6fdd0a..d1db0de 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -106,7 +106,7 @@ location /media/__sized__/ { } location /media/attachments/ { - alias __DATA_DIR__//media/attachments/; + alias __DATA_DIR__/media/attachments/; } location /_protected/media/ { From 93fec83d8707aa7e19e31913eebafecea44c08b0 Mon Sep 17 00:00:00 2001 From: Thomas <51749973+Thovi98@users.noreply.github.com> Date: Thu, 30 Mar 2023 22:15:45 +0200 Subject: [PATCH 25/30] Update data_dir --- scripts/upgrade | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 01b3d2a..2ca3e8f 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -35,15 +35,14 @@ if [ -z "$data_dir/data/" ]; then # Do a full backup before moving datas yunohost backup create --apps $app - data_dir="/home/yunohost.app/${app}/data" ynh_script_progression --message="Moving datas to $data_dir..." --weight=1 - mkdir -p $data_dir - mkdir -p $data_dir/{static,media,music} + mkdir -p /home/yunohost.app/${app}/data + mkdir -p /home/yunohost.app/${app}/data/{static,media,music} - chmod 750 "$data_dir" - chmod -R o-rwx "$data_dir" - chown -R $app:www-data "$data_dir" + chmod 750 "/home/yunohost.app/${app}/data" + chmod -R o-rwx "/home/yunohost.app/${app}/data" + chown -R $app:www-data "/home/yunohost.app/${app}/data" ynh_backup_if_checksum_is_different --file="$install_dir/code/config/.env" mkdir -p $install_dir/config @@ -53,23 +52,24 @@ if [ -z "$data_dir/data/" ]; then ynh_delete_file_checksum --file="$install_dir/code/config/.env" if [ -d "$install_dir/code/data/static/" ]; then - rsync -a $install_dir/code/data/static/ $data_dir/static/ + rsync -a $install_dir/code/data/static/ "/home/yunohost.app/${app}/data/static/" fi if [ -d "$install_dir/media/" ]; then - rsync -a $install_dir/media/ $data_dir/media/ + rsync -a $install_dir/media/ "/home/yunohost.app/${app}/data/media/" fi if [ -d "$install_dir/code/data/media/" ]; then - rsync -a $install_dir/code/data/media/ $data_dir/media/ + rsync -a $install_dir/code/data/media/ "/home/yunohost.app/${app}/data/media/" fi if [ -d "$install_dir/import/" ]; then - rsync -a $install_dir/import/ $data_dir/music/ + rsync -a $install_dir/import/ "/home/yunohost.app/${app}/data/music/" fi if [ -d "$install_dir/code/data/music/" ]; then - rsync -a $install_dir/code/data/music/ $data_dir/music/ + rsync -a $install_dir/code/data/music/ "/home/yunohost.app/${app}/data/music/" fi ynh_secure_remove --file="$install_dir/code" ynh_secure_remove --file="$install_dir/media" + ynh_secure_remove --file="$install_dir/static" ynh_secure_remove --file="$install_dir/code/data/media" ynh_secure_remove --file="$install_dir/import" ynh_secure_remove --file="$install_dir/code/data/music" From 689e26170eadab68be3322f28605bb9bedcc6290 Mon Sep 17 00:00:00 2001 From: Thomas <51749973+Thovi98@users.noreply.github.com> Date: Thu, 30 Mar 2023 22:16:26 +0200 Subject: [PATCH 26/30] fix permissions --- manifest.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/manifest.toml b/manifest.toml index 5b06bef..54502ae 100644 --- a/manifest.toml +++ b/manifest.toml @@ -62,6 +62,7 @@ ram.runtime = "50M" [resources.system_user] [resources.install_dir] + owner = __APP__:www-data [resources.data_dir] From 4ead0c52f9ab76310552a6ab756a919fd413bb01 Mon Sep 17 00:00:00 2001 From: Thomas <51749973+Thovi98@users.noreply.github.com> Date: Thu, 30 Mar 2023 22:26:55 +0200 Subject: [PATCH 27/30] fix format issue --- manifest.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.toml b/manifest.toml index 54502ae..338943d 100644 --- a/manifest.toml +++ b/manifest.toml @@ -62,7 +62,7 @@ ram.runtime = "50M" [resources.system_user] [resources.install_dir] - owner = __APP__:www-data + owner = "__APP__:www-data" [resources.data_dir] From a06c41db73f598fcfbeac8242116e65c505933e8 Mon Sep 17 00:00:00 2001 From: Thomas <51749973+Thovi98@users.noreply.github.com> Date: Thu, 30 Mar 2023 22:54:26 +0200 Subject: [PATCH 28/30] fix data_dir --- manifest.toml | 5 +++-- scripts/install | 10 +++++----- scripts/restore | 10 +++++----- scripts/upgrade | 23 ++++++++++++----------- 4 files changed, 25 insertions(+), 23 deletions(-) diff --git a/manifest.toml b/manifest.toml index 338943d..878ed21 100644 --- a/manifest.toml +++ b/manifest.toml @@ -62,9 +62,10 @@ ram.runtime = "50M" [resources.system_user] [resources.install_dir] - owner = "__APP__:www-data" - + [resources.data_dir] + dir = "/home/yunohost.app/__APP__/data/" + owner = "__APP__:www-data" [resources.permissions] main.url = "/" diff --git a/scripts/install b/scripts/install index 9c8e64f..1b6b08a 100644 --- a/scripts/install +++ b/scripts/install @@ -45,12 +45,12 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Creating a data directory..." --weight=1 -mkdir -p $data_dir/data -mkdir -p $data_dir/data/{static,media,music} +mkdir -p $data_dir/ +mkdir -p $data_dir/{static,media,music} -chmod 750 "$data_dir/data/" -chmod -R o-rwx "$data_dir/data/" -chown -R $app:www-data "$data_dir/data/" +chmod 750 "$data_dir/" +chmod -R o-rwx "$data_dir/" +chown -R $app:www-data "$data_dir/" #================================================= # ADD A CONFIGURATION diff --git a/scripts/restore b/scripts/restore index 7b7f1d3..6563e9d 100644 --- a/scripts/restore +++ b/scripts/restore @@ -25,13 +25,13 @@ chown -R $app:www-data "$install_dir" #================================================= ynh_script_progression --message="Restoring the data directory..." --weight=1 -ynh_restore_file --origin_path="$data_dir/data/" --not_mandatory +ynh_restore_file --origin_path="$data_dir/" --not_mandatory -mkdir -p $data_dir/data/{static,media,music} +mkdir -p $data_dir/{static,media,music} -chmod 750 "$data_dir/data/" -chmod -R o-rwx "$data_dir/data/" -chown -R $app:www-data "$data_dir/data/" +chmod 750 "$data_dir/" +chmod -R o-rwx "$data_dir/" +chown -R $app:www-data "$data_dir/" #================================================= # RESTORE THE NGINX CONFIGURATION diff --git a/scripts/upgrade b/scripts/upgrade index 2ca3e8f..28b57ca 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -31,18 +31,19 @@ ynh_systemd_action --action="stop" --service_name="${app}-worker" --log_path="sy #================================================= # If data_dir doesn't exist, create it -if [ -z "$data_dir/data/" ]; then +if [ -z "$data_dir/" ]; then # Do a full backup before moving datas yunohost backup create --apps $app + data_dir="/home/yunohost.app/${app}/data" ynh_script_progression --message="Moving datas to $data_dir..." --weight=1 - mkdir -p /home/yunohost.app/${app}/data - mkdir -p /home/yunohost.app/${app}/data/{static,media,music} + mkdir -p $data_dir + mkdir -p $data_dir/{static,media,music} - chmod 750 "/home/yunohost.app/${app}/data" - chmod -R o-rwx "/home/yunohost.app/${app}/data" - chown -R $app:www-data "/home/yunohost.app/${app}/data" + chmod 750 "$data_dir" + chmod -R o-rwx "$data_dir" + chown -R $app:www-data "$data_dir" ynh_backup_if_checksum_is_different --file="$install_dir/code/config/.env" mkdir -p $install_dir/config @@ -52,19 +53,19 @@ if [ -z "$data_dir/data/" ]; then ynh_delete_file_checksum --file="$install_dir/code/config/.env" if [ -d "$install_dir/code/data/static/" ]; then - rsync -a $install_dir/code/data/static/ "/home/yunohost.app/${app}/data/static/" + rsync -a $install_dir/code/data/static/ $data_dir/static/ fi if [ -d "$install_dir/media/" ]; then - rsync -a $install_dir/media/ "/home/yunohost.app/${app}/data/media/" + rsync -a $install_dir/media/ $data_dir/media/ fi if [ -d "$install_dir/code/data/media/" ]; then - rsync -a $install_dir/code/data/media/ "/home/yunohost.app/${app}/data/media/" + rsync -a $install_dir/code/data/media/ $data_dir/media/ fi if [ -d "$install_dir/import/" ]; then - rsync -a $install_dir/import/ "/home/yunohost.app/${app}/data/music/" + rsync -a $install_dir/import/ $data_dir/music/ fi if [ -d "$install_dir/code/data/music/" ]; then - rsync -a $install_dir/code/data/music/ "/home/yunohost.app/${app}/data/music/" + rsync -a $install_dir/code/data/music/ $data_dir/music/ fi ynh_secure_remove --file="$install_dir/code" From a01da86f6b72778481e65a387496aff58a346199 Mon Sep 17 00:00:00 2001 From: Thomas <51749973+Thovi98@users.noreply.github.com> Date: Thu, 30 Mar 2023 23:11:52 +0200 Subject: [PATCH 29/30] fix --- manifest.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.toml b/manifest.toml index 878ed21..5a54e7d 100644 --- a/manifest.toml +++ b/manifest.toml @@ -64,7 +64,7 @@ ram.runtime = "50M" [resources.install_dir] [resources.data_dir] - dir = "/home/yunohost.app/__APP__/data/" + dir = "/home/yunohost.app/__APP__/data" owner = "__APP__:www-data" [resources.permissions] From f2e0828e7afba26cbb6551edb722310621c1ef69 Mon Sep 17 00:00:00 2001 From: Thomas <51749973+Thovi98@users.noreply.github.com> Date: Fri, 31 Mar 2023 13:19:41 +0200 Subject: [PATCH 30/30] apply Aleks suggestions --- conf/env.prod | 8 ++++---- conf/nginx.conf | 10 +++++----- manifest.toml | 3 +-- scripts/install | 4 ++-- scripts/restore | 1 + 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/conf/env.prod b/conf/env.prod index 0ea9385..ae37480 100644 --- a/conf/env.prod +++ b/conf/env.prod @@ -110,12 +110,12 @@ CACHE_URL=redis://127.0.0.1:6379/__REDIS_DB__ # Where media files (such as album covers or audio tracks) should be stored # on your system? # (Ensure this directory actually exists) -MEDIA_ROOT=__DATA_DIR__/media +MEDIA_ROOT=__DATA_DIR__/data/media # Where static files (such as API css or icons) should be compiled # on your system? # (Ensure this directory actually exists) -STATIC_ROOT=__DATA_DIR__/static +STATIC_ROOT=__DATA_DIR__/data/static # which settings module should django use? # You don't have to touch this unless you really know what you're doing @@ -138,8 +138,8 @@ DJANGO_SECRET_KEY=__KEY__ # MUSIC_DIRECTORY_PATH=/srv/funkwhale/data/music # # MUSIC_DIRECTORY_SERVE_PATH= # stays commented, not needed -MUSIC_DIRECTORY_PATH=__DATA_DIR__/music -#MUSIC_DIRECTORY_SERVE_PATH=__DATA_DIR__/import +MUSIC_DIRECTORY_PATH=__DATA_DIR__/data/music +#MUSIC_DIRECTORY_SERVE_PATH=__DATA_DIR__/data/import # LDAP settings # Use the following options to allow authentication on your Funkwhale instance diff --git a/conf/nginx.conf b/conf/nginx.conf index d1db0de..e01ed0f 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -102,11 +102,11 @@ location /.well-known/ { } location /media/__sized__/ { - alias __DATA_DIR__/media/__sized__/; + alias __DATA_DIR__/data/media/__sized__/; } location /media/attachments/ { - alias __DATA_DIR__/media/attachments/; + alias __DATA_DIR__/data/media/attachments/; } location /_protected/media/ { @@ -114,7 +114,7 @@ location /_protected/media/ { # audio files once correct permission / authentication # has been checked on API side internal; - alias __DATA_DIR__/media/; + alias __DATA_DIR__/data/media/; } # Comment the previous location and uncomment this one if you're storing @@ -132,10 +132,10 @@ location /_protected/music/ { # has been checked on API side # Set this to the same value as your MUSIC_DIRECTORY_PATH setting internal; - alias __DATA_DIR__/music/; + alias __DATA_DIR__/data/music/; } location /staticfiles/ { # django static files - alias __DATA_DIR__/static/; + alias __DATA_DIR__/data/static/; } diff --git a/manifest.toml b/manifest.toml index 5a54e7d..1e82b33 100644 --- a/manifest.toml +++ b/manifest.toml @@ -64,8 +64,7 @@ ram.runtime = "50M" [resources.install_dir] [resources.data_dir] - dir = "/home/yunohost.app/__APP__/data" - owner = "__APP__:www-data" + group = "www-data:rx" [resources.permissions] main.url = "/" diff --git a/scripts/install b/scripts/install index 1b6b08a..b267235 100644 --- a/scripts/install +++ b/scripts/install @@ -45,10 +45,10 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Creating a data directory..." --weight=1 -mkdir -p $data_dir/ +mkdir -p $data_dir/data mkdir -p $data_dir/{static,media,music} -chmod 750 "$data_dir/" +chmod 750 "$data_dir" chmod -R o-rwx "$data_dir/" chown -R $app:www-data "$data_dir/" diff --git a/scripts/restore b/scripts/restore index 6563e9d..66c9940 100644 --- a/scripts/restore +++ b/scripts/restore @@ -27,6 +27,7 @@ ynh_script_progression --message="Restoring the data directory..." --weight=1 ynh_restore_file --origin_path="$data_dir/" --not_mandatory +mkdir -p $data_dir/data mkdir -p $data_dir/{static,media,music} chmod 750 "$data_dir/"