From 2200f75cb0e238f04da931a3d6997d37a74fead0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Tue, 31 Oct 2023 21:25:40 +0100 Subject: [PATCH 1/7] v2 --- conf/amd64.src | 7 ---- conf/arm64.src | 7 ---- conf/flood.service | 4 +- conf/rtorrent.rc | 8 ++-- conf/rtorrent.service | 4 +- manifest.toml | 61 ++++++++++++++++++++++++++++++ scripts/_common.sh | 2 +- scripts/backup | 18 ++++----- scripts/change_url | 76 +++++++++++++++++++------------------- scripts/install | 86 +++++++++++++++++++++---------------------- scripts/remove | 26 ++++++------- scripts/restore | 54 +++++++++++++-------------- scripts/upgrade | 48 ++++++++++++------------ 13 files changed, 225 insertions(+), 176 deletions(-) delete mode 100644 conf/amd64.src delete mode 100644 conf/arm64.src create mode 100644 manifest.toml diff --git a/conf/amd64.src b/conf/amd64.src deleted file mode 100644 index 9f81244..0000000 --- a/conf/amd64.src +++ /dev/null @@ -1,7 +0,0 @@ -SOURCE_URL=https://github.com/jesec/flood/releases/download/v4.7.0/flood-linux-x64.deb -SOURCE_SUM=d528edc50e2a2a8d60aa1d37e2cdf0353c48f792b7ded4f150a0914931076d3f -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=deb -SOURCE_IN_SUBDIR=false -SOURCE_FILENAME=flood-linux.deb -SOURCE_EXTRACT=false diff --git a/conf/arm64.src b/conf/arm64.src deleted file mode 100644 index f5bfd57..0000000 --- a/conf/arm64.src +++ /dev/null @@ -1,7 +0,0 @@ -SOURCE_URL=https://github.com/jesec/flood/releases/download/v4.7.0/flood-linux-arm64.deb -SOURCE_SUM=ed4626cf22580d2cd9932a870d14b2f93320f6768e5fa7d9bbbfa234ef7c4e6a -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=deb -SOURCE_IN_SUBDIR=false -SOURCE_FILENAME=flood-linux.deb -SOURCE_EXTRACT=false diff --git a/conf/flood.service b/conf/flood.service index 4395de5..7ecff3c 100644 --- a/conf/flood.service +++ b/conf/flood.service @@ -6,8 +6,8 @@ After=network.target Type=simple User=__APP__ Group=__APP__ -WorkingDirectory=__FINALPATH__/ -ExecStart=/usr/bin/flood --rundir="__FINALPATH__/" --baseuri="__PATH__" --port=__PORT__ --rthost="localhost" --rtport="__SCGI_PORT__" --allowedpath="__DATADIR__" --auth="none" +WorkingDirectory=__INSTALL_DIR__/ +ExecStart=/usr/bin/flood --rundir="__INSTALL_DIR__/" --baseuri="__PATH__" --port=__PORT__ --rthost="localhost" --rtport="__SCGI_PORT__" --allowedpath="__DATA_DIR__" --auth="none" [Install] WantedBy=multi-user.target diff --git a/conf/rtorrent.rc b/conf/rtorrent.rc index 317b8f7..0ffb677 100644 --- a/conf/rtorrent.rc +++ b/conf/rtorrent.rc @@ -23,19 +23,19 @@ throttle.max_uploads.set = 15 # Default directory to save the downloaded torrents. # -directory.default.set = __DATADIR__/downloads +directory.default.set = __DATA_DIR__/downloads # Default session directory. Make sure you don't run multiple instance # of rtorrent using the same session directory. Perhaps using a # relative path? # -session.path.set = __DATADIR__/.session +session.path.set = __DATA_DIR__/.session # Watch a directory for new torrents, and stop those that have been # deleted. # -schedule2 = watch_directory,1,1,"load_start=__DATADIR__/watch/*.torrent" -schedule2 = untied_directory,5,5,"stop_untied=__DATADIR__/watch/*.torrent" +schedule2 = watch_directory,1,1,"load_start=__DATA_DIR__/watch/*.torrent" +schedule2 = untied_directory,5,5,"stop_untied=__DATA_DIR__/watch/*.torrent" # Close torrents when diskspace is low. # diff --git a/conf/rtorrent.service b/conf/rtorrent.service index c7d1484..cfce0a8 100644 --- a/conf/rtorrent.service +++ b/conf/rtorrent.service @@ -7,8 +7,8 @@ Type=forking KillMode=none User=__APP__ Group=__APP__ -WorkingDirectory=__FINALPATH__/ -ExecStart=/usr/bin/screen -d -m -fa -S rtorrent /usr/bin/rtorrent -o import=__FINALPATH__/rtorrent.rc +WorkingDirectory=__INSTALL_DIR__/ +ExecStart=/usr/bin/screen -d -m -fa -S rtorrent /usr/bin/rtorrent -o import=__INSTALL_DIR__/rtorrent.rc ExecStop=/usr/bin/killall -w -s 2 /usr/bin/rtorrent Restart=on-failure RestartSec=3 diff --git a/manifest.toml b/manifest.toml new file mode 100644 index 0000000..c281626 --- /dev/null +++ b/manifest.toml @@ -0,0 +1,61 @@ +packaging_format = 2 + +id = "flood" +name = "Flood" +description.en = "Monitoring service for various torrent clients" +description.fr = "Service de surveillance pour divers clients torrent" + +version = "4.7.0~ynh3" + +maintainers = ["Taker"] + +[upstream] +license = "GPL-3.0-or-later" +website = "https://flood.js.org/" +admindoc = "https://github.com/jesec/flood/wiki" +code = "https://github.com/jesec/flood" +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.9" +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 = false +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" + + [install.path] + # this is a generic question - ask strings are automatically handled by Yunohost's core + type = "path" + default = "/flood" + + [install.init_main_permission] + type = "group" + default = false + +[resources] + [resources.sources.main] + format = "deb" + rename = "flood-linux.deb" + arm64.url = "https://github.com/jesec/flood/releases/download/v4.7.0/flood-linux-arm64.deb" + arm64.sha256 = "ed4626cf22580d2cd9932a870d14b2f93320f6768e5fa7d9bbbfa234ef7c4e6a" + amd64.url = "https://github.com/jesec/flood/releases/download/v4.7.0/flood-linux-x64.deb" + amd64.sha256 = "d528edc50e2a2a8d60aa1d37e2cdf0353c48f792b7ded4f150a0914931076d3f" + + + [resources.system_user] + + [resources.install_dir] + + [resources.data_dir] + + [resources.permissions] + main.url = "/" diff --git a/scripts/_common.sh b/scripts/_common.sh index 8c72f40..6f736b5 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,7 @@ #================================================= # dependencies used by the app -pkg_dependencies="rtorrent screen" +#REMOVEME? pkg_dependencies="rtorrent screen" #================================================= # PERSONAL HELPERS diff --git a/scripts/backup b/scripts/backup index dbf7058..3b2df95 100755 --- a/scripts/backup +++ b/scripts/backup @@ -14,22 +14,22 @@ 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) -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? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP @@ -40,13 +40,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 313cccb..4d15063 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -13,60 +13,60 @@ 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..." +#REMOVEME? ynh_script_progression --message="Loading installation settings..." -# Needed for helper "ynh_add_nginx_config" -final_path=$(ynh_app_setting_get --app=$app --key=final_path) +#REMOVEME? # Needed for helper "ynh_add_nginx_config" +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) # Add settings here as needed by your application -datadir=$(ynh_app_setting_get --app=$app --key=datadir) -port=$(ynh_app_setting_get --app=$app --key=port) -scgi_port=$(ynh_app_setting_get --app=$app --key=scgi_port) -rt_port=$(ynh_app_setting_get --app=$app --key=rt_port) +#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir) +#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port) +#REMOVEME? scgi_port=$(ynh_app_setting_get --app=$app --key=scgi_port) +#REMOVEME? rt_port=$(ynh_app_setting_get --app=$app --key=rt_port) #================================================= # BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." +#REMOVEME? ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." # Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { - ynh_clean_check_starting +#REMOVEME? ynh_backup_before_upgrade +#REMOVEME? ynh_clean_setup () { + #REMOVEME? ynh_clean_check_starting # 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 #================================================= @@ -83,28 +83,30 @@ ynh_systemd_action --service_name=$app --action="stop" #================================================= ynh_script_progression --message="Updating NGINX web server configuration..." -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 #================================================= @@ -113,8 +115,8 @@ fi # SETUP SYSTEMD #================================================= ynh_script_progression --message="Upgrading systemd configuration..." - -path_url=$new_path +#REMOVEME? +path=$new_path domain=$new_domain # Create a dedicated systemd config @@ -133,9 +135,9 @@ ynh_systemd_action --service_name=$app --action="start" #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." +#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." -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 1aa7825..d573e2e 100755 --- a/scripts/install +++ b/scripts/install @@ -13,59 +13,59 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { +#REMOVEME? ynh_clean_setup () { ynh_clean_check_starting } # 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=$YNH_APP_ARG_PATH -is_public=$YNH_APP_ARG_IS_PUBLIC +#REMOVEME? domain=$YNH_APP_ARG_DOMAIN +#REMOVEME? path=$YNH_APP_ARG_PATH +#REMOVEME? is_public=$YNH_APP_ARG_IS_PUBLIC -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -ynh_script_progression --message="Validating installation parameters..." +#REMOVEME? ynh_script_progression --message="Validating installation parameters..." -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" # 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..." +#REMOVEME? ynh_script_progression --message="Storing installation settings..." -ynh_app_setting_set --app=$app --key=domain --value=$domain -ynh_app_setting_set --app=$app --key=path --value=$path_url +#REMOVEME? ynh_app_setting_set --app=$app --key=domain --value=$domain +#REMOVEME? ynh_app_setting_set --app=$app --key=path --value=$path #================================================= # STANDARD MODIFICATIONS #================================================= # FIND AND OPEN A PORT #================================================= -ynh_script_progression --message="Finding an available port..." +#REMOVEME? ynh_script_progression --message="Finding an available port..." # 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 # Find an available port -scgi_port=$(ynh_find_port --port=8095) -ynh_app_setting_set --app=$app --key=scgi_port --value=$scgi_port +#REMOVEME? scgi_port=$(ynh_find_port --port=8095) +#REMOVEME? ynh_app_setting_set --app=$app --key=scgi_port --value=$scgi_port # Find an available port -rt_port=$(ynh_find_port --port=45069) -ynh_app_setting_set --app=$app --key=rt_port --value=$rt_port +#REMOVEME? rt_port=$(ynh_find_port --port=45069) +#REMOVEME? ynh_app_setting_set --app=$app --key=rt_port --value=$rt_port # Open the port ynh_script_progression --message="Configuring firewall..." @@ -74,9 +74,9 @@ ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $rt_port #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing dependencies..." +#REMOVEME? ynh_script_progression --message="Installing dependencies..." -ynh_install_app_dependencies $pkg_dependencies +#REMOVEME? ynh_install_app_dependencies $pkg_dependencies tmpdir="$(mktemp -d)" ynh_setup_source --dest_dir="$tmpdir" --source_id=$YNH_ARCH @@ -86,23 +86,23 @@ ynh_secure_remove --file="$tmpdir" #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Configuring system user..." +#REMOVEME? ynh_script_progression --message="Configuring system user..." # 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" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Setting up source files..." -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 -mkdir -p "$final_path" +mkdir -p "$install_dir" -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:$app "$final_path" +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R $app:$app "$install_dir" #================================================= # NGINX CONFIGURATION @@ -119,24 +119,24 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Creating a data directory..." -datadir=/home/yunohost.app/$app -ynh_app_setting_set --app=$app --key=datadir --value=$datadir +#REMOVEME? data_dir=/home/yunohost.app/$app +#REMOVEME? ynh_app_setting_set --app=$app --key=data_dir --value=$data_dir -mkdir -p $datadir/{.session,watch,torrent} +mkdir -p $data_dir/{.session,watch,torrent} -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 #================================================= ynh_script_progression --message="Adding a configuration file..." -ynh_add_config --template="../conf/rtorrent.rc" --destination="$final_path/rtorrent.rc" +ynh_add_config --template="../conf/rtorrent.rc" --destination="$install_dir/rtorrent.rc" -chmod 400 "$final_path/rtorrent.rc" -chown $app:$app "$final_path/rtorrent.rc" +chmod 400 "$install_dir/rtorrent.rc" +chown $app:$app "$install_dir/rtorrent.rc" #================================================= # SETUP SYSTEMD @@ -169,22 +169,22 @@ ynh_systemd_action --service_name=$app-rtorrent --action="start" #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring permissions..." +#REMOVEME? ynh_script_progression --message="Configuring permissions..." # 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..." +#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." -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 c6a845a..51c3e5b 100755 --- a/scripts/remove +++ b/scripts/remove @@ -12,14 +12,14 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." +#REMOVEME? ynh_script_progression --message="Loading installation settings..." -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get --app=$app --key=domain) -rt_port=$(ynh_app_setting_get --app=$app --key=rt_port) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -datadir=$(ynh_app_setting_get --app=$app --key=datadir) +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? rt_port=$(ynh_app_setting_get --app=$app --key=rt_port) +#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) #================================================= # STANDARD REMOVE @@ -53,10 +53,10 @@ ynh_remove_systemd_config --service="$app-rtorrent" #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_script_progression --message="Removing app main directory..." +#REMOVEME? ynh_script_progression --message="Removing app main directory..." # Remove the app directory securely -ynh_secure_remove --file="$final_path" +#REMOVEME? ynh_secure_remove --file="$install_dir" #================================================= # REMOVE DATA DIR @@ -66,7 +66,7 @@ ynh_secure_remove --file="$final_path" if [ "${YNH_APP_PURGE:-0}" -eq 1 ] then ynh_script_progression --message="Removing app data directory..." - ynh_secure_remove --file="$datadir" +#REMOVEME? ynh_secure_remove --file="$data_dir" fi #================================================= @@ -80,10 +80,10 @@ ynh_remove_nginx_config #================================================= # REMOVE DEPENDENCIES #================================================= -ynh_script_progression --message="Removing dependencies..." +#REMOVEME? ynh_script_progression --message="Removing dependencies..." # Remove metapackage and its dependencies -ynh_remove_app_dependencies +#REMOVEME? ynh_remove_app_dependencies dpkg -r flood #================================================= @@ -101,10 +101,10 @@ fi #================================================= # REMOVE DEDICATED USER #================================================= -ynh_script_progression --message="Removing the dedicated system user..." +#REMOVEME? ynh_script_progression --message="Removing the dedicated system user..." # 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 05677ae..a32cd66 100755 --- a/scripts/restore +++ b/scripts/restore @@ -14,33 +14,33 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { +#REMOVEME? ynh_clean_setup () { ynh_clean_check_starting } # 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..." +#REMOVEME? ynh_script_progression --message="Loading installation settings..." -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) -datadir=$(ynh_app_setting_get --app=$app --key=datadir) -scgi_port=$(ynh_app_setting_get --app=$app --key=scgi_port) -rt_port=$(ynh_app_setting_get --app=$app --key=rt_port) +#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? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir) +#REMOVEME? scgi_port=$(ynh_app_setting_get --app=$app --key=scgi_port) +#REMOVEME? rt_port=$(ynh_app_setting_get --app=$app --key=rt_port) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= -ynh_script_progression --message="Validating restoration parameters..." +#REMOVEME? ynh_script_progression --message="Validating restoration parameters..." -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 @@ -54,44 +54,44 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RECREATE THE DEDICATED USER #================================================= -ynh_script_progression --message="Recreating the dedicated system user..." +#REMOVEME? ynh_script_progression --message="Recreating the dedicated system user..." # 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..." -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..." -ynh_restore_file --origin_path="$datadir" --not_mandatory +ynh_restore_file --origin_path="$data_dir" --not_mandatory -mkdir -p $datadir +mkdir -p $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" #================================================= # SPECIFIC RESTORATION #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Reinstalling dependencies..." +#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." # Define and install dependencies -ynh_install_app_dependencies $pkg_dependencies +#REMOVEME? ynh_install_app_dependencies $pkg_dependencies tmpdir="$(mktemp -d)" ynh_setup_source --dest_dir="$tmpdir" --source_id=$YNH_ARCH @@ -101,7 +101,7 @@ ynh_secure_remove --file="$tmpdir" #================================================= # OPEN A PORT #================================================= -ynh_script_progression --message="Finding an available port..." +#REMOVEME? ynh_script_progression --message="Finding an available port..." # Open the port ynh_script_progression --message="Configuring firewall..." diff --git a/scripts/upgrade b/scripts/upgrade index 5d80dd9..da94ae4 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,17 +12,17 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." +#REMOVEME? ynh_script_progression --message="Loading installation settings..." -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) -datadir=$(ynh_app_setting_get --app=$app --key=datadir) -port=$(ynh_app_setting_get --app=$app --key=port) -scgi_port=$(ynh_app_setting_get --app=$app --key=scgi_port) -rt_port=$(ynh_app_setting_get --app=$app --key=rt_port) +#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? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir) +#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port) +#REMOVEME? scgi_port=$(ynh_app_setting_get --app=$app --key=scgi_port) +#REMOVEME? rt_port=$(ynh_app_setting_get --app=$app --key=rt_port) #================================================= # CHECK VERSION @@ -33,17 +33,17 @@ 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)..." +#REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." # Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { +#REMOVEME? ynh_backup_before_upgrade +#REMOVEME? ynh_clean_setup () { ynh_clean_check_starting # 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 @@ -58,10 +58,10 @@ ynh_systemd_action --service_name=$app-rtorrent --action="stop" #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." +#REMOVEME? ynh_script_progression --message="Making sure dedicated system user exists..." # 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 @@ -72,12 +72,12 @@ then ynh_script_progression --message="Upgrading source files..." # Download, check integrity, uncompress and patch the source from app.src - mkdir -p "$final_path" + mkdir -p "$install_dir" 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" #================================================= # NGINX CONFIGURATION @@ -90,9 +90,9 @@ ynh_add_nginx_config #================================================= # UPGRADE DEPENDENCIES #================================================= -ynh_script_progression --message="Upgrading dependencies..." +#REMOVEME? ynh_script_progression --message="Upgrading dependencies..." -ynh_install_app_dependencies $pkg_dependencies +#REMOVEME? ynh_install_app_dependencies $pkg_dependencies tmpdir="$(mktemp -d)" ynh_setup_source --dest_dir="$tmpdir" --source_id=$YNH_ARCH @@ -132,9 +132,9 @@ ynh_systemd_action --service_name=$app-rtorrent --action="start" #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." +#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." -ynh_systemd_action --service_name=nginx --action=reload +#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT From 3a7a2f94d4e6949aca875069b1c6e8abf350d302 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Tue, 31 Oct 2023 21:39:18 +0100 Subject: [PATCH 2/7] v2 --- check_process | 21 -------- conf/config.js | 2 +- conf/flood.service | 2 +- conf/rtorrent.rc | 4 +- doc/DESCRIPTION.md | 2 +- doc/DISCLAIMER.md | 0 manifest.json | 49 ------------------- manifest.toml | 28 ++++++----- scripts/_common.sh | 3 -- scripts/backup | 23 --------- scripts/change_url | 93 +----------------------------------- scripts/install | 116 ++------------------------------------------- scripts/remove | 68 -------------------------- scripts/restore | 78 ++---------------------------- scripts/upgrade | 52 +------------------- tests.toml | 8 ++++ 16 files changed, 41 insertions(+), 508 deletions(-) delete mode 100644 check_process delete mode 100644 doc/DISCLAIMER.md delete mode 100644 manifest.json create mode 100644 tests.toml diff --git a/check_process b/check_process deleted file mode 100644 index ebc398f..0000000 --- a/check_process +++ /dev/null @@ -1,21 +0,0 @@ -;; Test complet - ; Manifest - domain="domain.tld" - path="/path" - is_public=1 - ; Checks - pkg_linter=1 - setup_sub_dir=1 - setup_root=1 - setup_nourl=0 - setup_private=1 - setup_public=1 - upgrade=1 - # upgrade=1 from_commit=CommitHash - backup_restore=1 - multi_instance=0 - port_already_use=1 - change_url=1 -;;; Options -Email= -Notification=none diff --git a/conf/config.js b/conf/config.js index ae25286..e2de64d 100644 --- a/conf/config.js +++ b/conf/config.js @@ -37,7 +37,7 @@ const CONFIG = { // These are defaults for most installs; check your .rtorrent.rc for changes. scgi: { host: 'localhost', - port: __RT_PORT__, + port: __PORT_RT__, socket: false, socketPath: '/tmp/rtorrent.sock' }, diff --git a/conf/flood.service b/conf/flood.service index 7ecff3c..fe568d7 100644 --- a/conf/flood.service +++ b/conf/flood.service @@ -7,7 +7,7 @@ Type=simple User=__APP__ Group=__APP__ WorkingDirectory=__INSTALL_DIR__/ -ExecStart=/usr/bin/flood --rundir="__INSTALL_DIR__/" --baseuri="__PATH__" --port=__PORT__ --rthost="localhost" --rtport="__SCGI_PORT__" --allowedpath="__DATA_DIR__" --auth="none" +ExecStart=/usr/bin/flood --rundir="__INSTALL_DIR__/" --baseuri="__PATH__" --port=__PORT__ --rthost="localhost" --rtport="__PORT_SCGI__" --allowedpath="__DATA_DIR__" --auth="none" [Install] WantedBy=multi-user.target diff --git a/conf/rtorrent.rc b/conf/rtorrent.rc index 0ffb677..ba462e8 100644 --- a/conf/rtorrent.rc +++ b/conf/rtorrent.rc @@ -54,7 +54,7 @@ schedule2 = untied_directory,5,5,"stop_untied=__DATA_DIR__/watch/*.torrent" # Port range to use for listening. # -network.port_range.set = __RT_PORT__-__RT_PORT__ +network.port_range.set = __PORT_RT__-__PORT_RT__ # Start opening ports at a random position within the port range. # @@ -107,4 +107,4 @@ protocol.pex.set = no # Use a IP socket with scgi_port, or a Unix socket with scgi_local. # schedule can be used to set permissions on the unix socket. # -scgi_port = 127.0.0.1:__SCGI_PORT__ +scgi_port = 127.0.0.1:__PORT_SCGI__ diff --git a/doc/DESCRIPTION.md b/doc/DESCRIPTION.md index 9a7e949..12e51a9 100644 --- a/doc/DESCRIPTION.md +++ b/doc/DESCRIPTION.md @@ -1 +1 @@ -Flood is a monitoring service for various torrent clients. It's a Node.js service that communicates with your favorite torrent client and serves a decent web UI for administration. \ No newline at end of file +Flood is a monitoring service for rTorrent. It's a Node.js service that communicates with your favorite torrent client and serves a decent web UI for administration. \ No newline at end of file diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md deleted file mode 100644 index e69de29..0000000 diff --git a/manifest.json b/manifest.json deleted file mode 100644 index ed81a10..0000000 --- a/manifest.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "name": "Flood", - "id": "flood", - "packaging_format": 1, - "description": { - "en": "Monitoring service for various torrent clients", - "fr": "Service de surveillance pour divers clients torrent" - }, - "version": "4.7.0~ynh3", - "url": "https://flood.js.org/", - "upstream": { - "license": "GPL-3.0-or-later", - "website": "https://flood.js.org/", - "admindoc": "https://github.com/jesec/flood/wiki", - "code": "https://github.com/jesec/flood" - }, - "license": "GPL-3.0-or-later", - "maintainer": { - "name": "Taker", - "email": "me@taker.fr", - "url": "https://taker.fr" - }, - "requirements": { - "yunohost": ">= 11.0.9" - }, - "multi_instance": false, - "services": [ - "nginx" - ], - "arguments": { - "install" : [ - { - "name": "domain", - "type": "domain" - }, - { - "name": "path", - "type": "path", - "example": "/flood", - "default": "/flood" - }, - { - "name": "is_public", - "type": "boolean", - "default": false - } - ] - } -} diff --git a/manifest.toml b/manifest.toml index c281626..44fed79 100644 --- a/manifest.toml +++ b/manifest.toml @@ -14,26 +14,22 @@ license = "GPL-3.0-or-later" website = "https://flood.js.org/" admindoc = "https://github.com/jesec/flood/wiki" code = "https://github.com/jesec/flood" -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.9" -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.2" +architectures = "all" multi_instance = false -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" [install.path] - # this is a generic question - ask strings are automatically handled by Yunohost's core type = "path" default = "/flood" @@ -56,6 +52,16 @@ ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requiremen [resources.install_dir] [resources.data_dir] + subdirs = [".session", "watch", "torrent"] + + [resources.ports] + main.default = 8095 + scgi.default = 8096 + rt.default = 45069 + rt.exposed = "TCP" [resources.permissions] main.url = "/" + + [resources.apt] + packages = "rtorrent, screen" diff --git a/scripts/_common.sh b/scripts/_common.sh index 6f736b5..944a65e 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,9 +4,6 @@ # COMMON VARIABLES #================================================= -# dependencies used by the app -#REMOVEME? pkg_dependencies="rtorrent screen" - #================================================= # PERSONAL HELPERS #================================================= diff --git a/scripts/backup b/scripts/backup index 3b2df95..3709aaa 100755 --- a/scripts/backup +++ b/scripts/backup @@ -10,27 +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? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir) - #================================================= # DECLARE DATA AND CONF FILES TO BACKUP #================================================= @@ -54,8 +33,6 @@ ynh_backup --src_path="$data_dir" --is_big ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# SPECIFIC BACKUP #================================================= # BACKUP SYSTEMD #================================================= diff --git a/scripts/change_url b/scripts/change_url index 4d15063..b2d1f61 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -9,66 +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 -#================================================= -#REMOVEME? ynh_script_progression --message="Loading installation settings..." - -#REMOVEME? # Needed for helper "ynh_add_nginx_config" -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) - -# Add settings here as needed by your application -#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir) -#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port) -#REMOVEME? scgi_port=$(ynh_app_setting_get --app=$app --key=scgi_port) -#REMOVEME? rt_port=$(ynh_app_setting_get --app=$app --key=rt_port) - -#================================================= -# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP -#================================================= -#REMOVEME? ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." - -# Backup the current version of the app -#REMOVEME? ynh_backup_before_upgrade -#REMOVEME? ynh_clean_setup () { - #REMOVEME? ynh_clean_check_starting - # 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 #================================================= @@ -85,37 +25,13 @@ 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 - #================================================= # SPECIFIC MODIFICATIONS #================================================= # SETUP SYSTEMD #================================================= ynh_script_progression --message="Upgrading systemd configuration..." -#REMOVEME? + path=$new_path domain=$new_domain @@ -132,13 +48,6 @@ ynh_script_progression --message="Starting a systemd service..." # Start a systemd service ynh_systemd_action --service_name=$app --action="start" -#================================================= -# RELOAD NGINX -#================================================= -#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." - -#REMOVEME? #REMOVEME? ynh_systemd_action --service_name=nginx --action=reload - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/install b/scripts/install index d573e2e..3e8b315 100755 --- a/scripts/install +++ b/scripts/install @@ -9,98 +9,24 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -#REMOVEME? ynh_clean_setup () { - ynh_clean_check_starting -} -# 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 -#REMOVEME? path=$YNH_APP_ARG_PATH -#REMOVEME? is_public=$YNH_APP_ARG_IS_PUBLIC - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#================================================= -# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS -#================================================= -#REMOVEME? ynh_script_progression --message="Validating installation parameters..." - -#REMOVEME? install_dir=/var/www/$app -#REMOVEME? test ! -e "$install_dir" || ynh_die --message="This path already contains a folder" - -# 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..." - -#REMOVEME? ynh_app_setting_set --app=$app --key=domain --value=$domain -#REMOVEME? ynh_app_setting_set --app=$app --key=path --value=$path - -#================================================= -# STANDARD MODIFICATIONS -#================================================= -# FIND AND OPEN A PORT -#================================================= -#REMOVEME? ynh_script_progression --message="Finding an available port..." - -# Find an available port -#REMOVEME? port=$(ynh_find_port --port=8095) -#REMOVEME? ynh_app_setting_set --app=$app --key=port --value=$port - -# Find an available port -#REMOVEME? scgi_port=$(ynh_find_port --port=8095) -#REMOVEME? ynh_app_setting_set --app=$app --key=scgi_port --value=$scgi_port - -# Find an available port -#REMOVEME? rt_port=$(ynh_find_port --port=45069) -#REMOVEME? ynh_app_setting_set --app=$app --key=rt_port --value=$rt_port - -# Open the port -ynh_script_progression --message="Configuring firewall..." -ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $rt_port - #================================================= # INSTALL DEPENDENCIES #================================================= -#REMOVEME? ynh_script_progression --message="Installing dependencies..." - -#REMOVEME? ynh_install_app_dependencies $pkg_dependencies +ynh_script_progression --message="Installing dependencies..." tmpdir="$(mktemp -d)" -ynh_setup_source --dest_dir="$tmpdir" --source_id=$YNH_ARCH +ynh_setup_source --dest_dir="$tmpdir" dpkg -i $tmpdir/flood-linux.deb ynh_secure_remove --file="$tmpdir" -#================================================= -# CREATE DEDICATED USER -#================================================= -#REMOVEME? ynh_script_progression --message="Configuring system user..." - -# Create a system user -#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Setting up source files..." -#REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir # Download, check integrity, uncompress and patch the source from app.src mkdir -p "$install_dir" -chmod 750 "$install_dir" chmod -R o-rwx "$install_dir" chown -R $app:$app "$install_dir" @@ -112,28 +38,12 @@ ynh_script_progression --message="Configuring NGINX web server..." # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# SPECIFIC SETUP -#================================================= -# CREATE DATA DIRECTORY -#================================================= -ynh_script_progression --message="Creating a data directory..." - -#REMOVEME? data_dir=/home/yunohost.app/$app -#REMOVEME? ynh_app_setting_set --app=$app --key=data_dir --value=$data_dir - -mkdir -p $data_dir/{.session,watch,torrent} - -chmod 750 "$data_dir" -chmod -R o-rwx "$data_dir" -chown -R $app:www-data "$data_dir" - #================================================= # ADD A CONFIGURATION #================================================= ynh_script_progression --message="Adding a configuration file..." -ynh_add_config --template="../conf/rtorrent.rc" --destination="$install_dir/rtorrent.rc" +ynh_add_config --template="rtorrent.rc" --destination="$install_dir/rtorrent.rc" chmod 400 "$install_dir/rtorrent.rc" chown $app:$app "$install_dir/rtorrent.rc" @@ -166,26 +76,6 @@ ynh_script_progression --message="Starting a systemd service..." ynh_systemd_action --service_name=$app --action="start" ynh_systemd_action --service_name=$app-rtorrent --action="start" -#================================================= -# SETUP SSOWAT -#================================================= -#REMOVEME? ynh_script_progression --message="Configuring permissions..." - -# 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..." - -#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/remove b/scripts/remove index 51c3e5b..1e11150 100755 --- a/scripts/remove +++ b/scripts/remove @@ -9,18 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -#REMOVEME? ynh_script_progression --message="Loading installation settings..." - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) -#REMOVEME? rt_port=$(ynh_app_setting_get --app=$app --key=rt_port) -#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) - #================================================= # STANDARD REMOVE #================================================= @@ -40,72 +28,16 @@ then yunohost service remove $app-rtorrent fi -#================================================= -# STOP AND REMOVE SERVICE -#================================================= -ynh_script_progression --message="Stopping and removing the systemd service..." - # Remove the dedicated systemd config ynh_remove_systemd_config ynh_remove_systemd_config --service="$app-rtorrent" - -#================================================= -# REMOVE APP MAIN DIR -#================================================= -#REMOVEME? ynh_script_progression --message="Removing app main directory..." - -# 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..." -#REMOVEME? ynh_secure_remove --file="$data_dir" -fi - -#================================================= -# REMOVE NGINX CONFIGURATION -#================================================= -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..." - # Remove metapackage and its dependencies -#REMOVEME? ynh_remove_app_dependencies dpkg -r flood -#================================================= -# CLOSE A PORT -#================================================= - -if yunohost firewall list | grep -q "\- $rt_port$" -then - ynh_script_progression --message="Closing port $rt_port..." - ynh_exec_warn_less yunohost firewall disallow TCP $rt_port -fi - -#================================================= -# GENERIC FINALIZATION -#================================================= -# REMOVE DEDICATED USER -#================================================= -#REMOVEME? ynh_script_progression --message="Removing the dedicated system user..." - -# Delete a system user -#REMOVEME? ynh_system_user_delete --username=$app - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index a32cd66..cacda15 100755 --- a/scripts/restore +++ b/scripts/restore @@ -10,55 +10,6 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -#REMOVEME? ynh_clean_setup () { - ynh_clean_check_starting -} -# 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..." - -#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? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir) -#REMOVEME? scgi_port=$(ynh_app_setting_get --app=$app --key=scgi_port) -#REMOVEME? rt_port=$(ynh_app_setting_get --app=$app --key=rt_port) - -#================================================= -# CHECK IF THE APP CAN BE RESTORED -#================================================= -#REMOVEME? ynh_script_progression --message="Validating restoration parameters..." - -#REMOVEME? test ! -d $install_dir \ - || ynh_die --message="There is already a directory: $install_dir " - -#================================================= -# STANDARD RESTORATION STEPS -#================================================= -# RESTORE THE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the NGINX web server configuration..." - -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" - -#================================================= -# RECREATE THE DEDICATED USER -#================================================= -#REMOVEME? ynh_script_progression --message="Recreating the dedicated system user..." - -# Create the dedicated user (if not existing) -#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" - #================================================= # RESTORE THE APP MAIN DIR #================================================= @@ -66,7 +17,6 @@ ynh_script_progression --message="Restoring the app main directory..." ynh_restore_file --origin_path="$install_dir" -chmod 750 "$install_dir" chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" @@ -77,10 +27,6 @@ ynh_script_progression --message="Restoring the data directory..." ynh_restore_file --origin_path="$data_dir" --not_mandatory -mkdir -p $data_dir - -chmod 750 "$data_dir" -chmod -R o-rwx "$data_dir" chown -R $app:www-data "$data_dir" #================================================= @@ -88,40 +34,26 @@ chown -R $app:www-data "$data_dir" #================================================= # REINSTALL DEPENDENCIES #================================================= -#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." - -# Define and install dependencies -#REMOVEME? ynh_install_app_dependencies $pkg_dependencies +ynh_script_progression --message="Reinstalling dependencies..." tmpdir="$(mktemp -d)" -ynh_setup_source --dest_dir="$tmpdir" --source_id=$YNH_ARCH +ynh_setup_source --dest_dir="$tmpdir" dpkg -i $tmpdir/flood-linux.deb ynh_secure_remove --file="$tmpdir" -#================================================= -# OPEN A PORT -#================================================= -#REMOVEME? ynh_script_progression --message="Finding an available port..." - -# Open the port -ynh_script_progression --message="Configuring firewall..." -ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $rt_port - #================================================= # RESTORE SYSTEMD #================================================= ynh_script_progression --message="Restoring the systemd configuration..." +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" + ynh_restore_file --origin_path="/etc/systemd/system/$app.service" systemctl enable $app.service --quiet + ynh_restore_file --origin_path="/etc/systemd/system/$app-rtorrent.service" systemctl enable $app-rtorrent.service --quiet -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." - yunohost service add $app yunohost service add $app-rtorrent --needs_exposed_ports $rt_port diff --git a/scripts/upgrade b/scripts/upgrade index da94ae4..35bc73c 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,42 +9,12 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -#REMOVEME? ynh_script_progression --message="Loading installation settings..." - -#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? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir) -#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port) -#REMOVEME? scgi_port=$(ynh_app_setting_get --app=$app --key=scgi_port) -#REMOVEME? rt_port=$(ynh_app_setting_get --app=$app --key=rt_port) - #================================================= # CHECK VERSION #================================================= 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)..." - -# Backup the current version of the app -#REMOVEME? ynh_backup_before_upgrade -#REMOVEME? ynh_clean_setup () { - ynh_clean_check_starting - # 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 #================================================= @@ -55,14 +25,6 @@ ynh_script_progression --message="Stopping a systemd service..." ynh_systemd_action --service_name=$app --action="stop" ynh_systemd_action --service_name=$app-rtorrent --action="stop" -#================================================= -# CREATE DEDICATED USER -#================================================= -#REMOVEME? ynh_script_progression --message="Making sure dedicated system user exists..." - -# Create a dedicated user (if not existing) -#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -75,7 +37,6 @@ then mkdir -p "$install_dir" fi -chmod 750 "$install_dir" chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" @@ -90,12 +51,10 @@ ynh_add_nginx_config #================================================= # UPGRADE DEPENDENCIES #================================================= -#REMOVEME? ynh_script_progression --message="Upgrading dependencies..." - -#REMOVEME? ynh_install_app_dependencies $pkg_dependencies +ynh_script_progression --message="Upgrading dependencies..." tmpdir="$(mktemp -d)" -ynh_setup_source --dest_dir="$tmpdir" --source_id=$YNH_ARCH +ynh_setup_source --dest_dir="$tmpdir" dpkg -i $tmpdir/flood-linux.deb ynh_secure_remove --file="$tmpdir" @@ -129,13 +88,6 @@ ynh_script_progression --message="Starting a systemd service..." ynh_systemd_action --service_name=$app --action="start" ynh_systemd_action --service_name=$app-rtorrent --action="start" -#================================================= -# RELOAD NGINX -#================================================= -#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." - -#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..55d5cb2 --- /dev/null +++ b/tests.toml @@ -0,0 +1,8 @@ +test_format = 1.0 + +[default] + + # ------------ + # Tests to run + # ------------ + \ No newline at end of file From 5a4712708df7bbb264f05967612c1dca16425825 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Tue, 31 Oct 2023 20:39:22 +0000 Subject: [PATCH 3/7] 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 a39a54c..3e139a5 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in ## Overview -Flood is a monitoring service for various torrent clients. It's a Node.js service that communicates with your favorite torrent client and serves a decent web UI for administration. +Flood is a monitoring service for rTorrent. It's a Node.js service that communicates with your favorite torrent client and serves a decent web UI for administration. **Shipped version:** 4.7.0~ynh3 diff --git a/README_fr.md b/README_fr.md index 17fa2ac..8fd69a8 100644 --- a/README_fr.md +++ b/README_fr.md @@ -16,7 +16,7 @@ Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po ## Vue d’ensemble -Flood is a monitoring service for various torrent clients. It's a Node.js service that communicates with your favorite torrent client and serves a decent web UI for administration. +Flood is a monitoring service for rTorrent. It's a Node.js service that communicates with your favorite torrent client and serves a decent web UI for administration. **Version incluse :** 4.7.0~ynh3 From f49bb0997e6733073e26cd761bbedd1e54da3f47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Tue, 31 Oct 2023 21:40:06 +0100 Subject: [PATCH 4/7] Update manifest.toml --- manifest.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/manifest.toml b/manifest.toml index 44fed79..5781630 100644 --- a/manifest.toml +++ b/manifest.toml @@ -46,7 +46,6 @@ ram.runtime = "50M" amd64.url = "https://github.com/jesec/flood/releases/download/v4.7.0/flood-linux-x64.deb" amd64.sha256 = "d528edc50e2a2a8d60aa1d37e2cdf0353c48f792b7ded4f150a0914931076d3f" - [resources.system_user] [resources.install_dir] From a60d572a35a349d884da3749e3adc114a0fc27a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Tue, 31 Oct 2023 21:40:21 +0100 Subject: [PATCH 5/7] Update manifest.toml --- manifest.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.toml b/manifest.toml index 5781630..63044d2 100644 --- a/manifest.toml +++ b/manifest.toml @@ -35,7 +35,7 @@ ram.runtime = "50M" [install.init_main_permission] type = "group" - default = false + default = "visitors" [resources] [resources.sources.main] From 02ace9208c0f2b06e8657e99d36f8a08067e0202 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Tue, 31 Oct 2023 21:44:21 +0100 Subject: [PATCH 6/7] fix --- scripts/install | 2 +- scripts/restore | 2 +- scripts/upgrade | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index 3e8b315..d7b68a7 100755 --- a/scripts/install +++ b/scripts/install @@ -65,7 +65,7 @@ ynh_add_systemd_config --service=$app-rtorrent --template="rtorrent.service" ynh_script_progression --message="Integrating service in YunoHost..." yunohost service add $app -yunohost service add $app-rtorrent --needs_exposed_ports $rt_port +yunohost service add $app-rtorrent --needs_exposed_ports $port_rt #================================================= # START SYSTEMD SERVICE diff --git a/scripts/restore b/scripts/restore index cacda15..39efbc7 100755 --- a/scripts/restore +++ b/scripts/restore @@ -55,7 +55,7 @@ ynh_restore_file --origin_path="/etc/systemd/system/$app-rtorrent.service" systemctl enable $app-rtorrent.service --quiet yunohost service add $app -yunohost service add $app-rtorrent --needs_exposed_ports $rt_port +yunohost service add $app-rtorrent --needs_exposed_ports $port_rt #================================================= # START SYSTEMD SERVICE diff --git a/scripts/upgrade b/scripts/upgrade index 35bc73c..cddd324 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -77,7 +77,7 @@ ynh_add_systemd_config --service=$app-rtorrent --template="rtorrent.service" ynh_script_progression --message="Integrating service in YunoHost..." yunohost service add $app -yunohost service add $app-rtorrent --needs_exposed_ports $rt_port +yunohost service add $app-rtorrent --needs_exposed_ports $port_rt #================================================= # START SYSTEMD SERVICE From aa318cb9fa2af0f2ea11c622504d126d93ae84d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Tue, 31 Oct 2023 21:44:53 +0100 Subject: [PATCH 7/7] Update manifest.toml --- manifest.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/manifest.toml b/manifest.toml index 63044d2..feea2f2 100644 --- a/manifest.toml +++ b/manifest.toml @@ -39,7 +39,6 @@ ram.runtime = "50M" [resources] [resources.sources.main] - format = "deb" rename = "flood-linux.deb" arm64.url = "https://github.com/jesec/flood/releases/download/v4.7.0/flood-linux-arm64.deb" arm64.sha256 = "ed4626cf22580d2cd9932a870d14b2f93320f6768e5fa7d9bbbfa234ef7c4e6a"