From 598123ed5b1fa02a3fbf6ab186f8a07bbf9c9f8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Fri, 17 Feb 2023 22:27:59 +0100 Subject: [PATCH] v2 --- check_process | 27 --------------- conf/config.default.yml | 2 +- doc/{DISCLAIMER.md => ADMIN.md} | 0 doc/{DISCLAIMER_fr.md => ADMIN_fr.md} | 0 manifest.toml | 19 ++++++----- scripts/change_url | 10 ------ scripts/install | 49 +++++---------------------- scripts/remove | 35 ++----------------- scripts/restore | 43 +++-------------------- scripts/upgrade | 39 ++++----------------- tests.toml | 10 ++++++ 11 files changed, 44 insertions(+), 190 deletions(-) delete mode 100644 check_process rename doc/{DISCLAIMER.md => ADMIN.md} (100%) rename doc/{DISCLAIMER_fr.md => ADMIN_fr.md} (100%) create mode 100644 tests.toml diff --git a/check_process b/check_process deleted file mode 100644 index 64c779f..0000000 --- a/check_process +++ /dev/null @@ -1,27 +0,0 @@ -;; Test complet - ; Manifest - domain="domain.tld" - path="/path" - is_public=1 - admin="john" - password="pass" - ; 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=bbce7cfa6cb8916671a4fec9e8a73095f74a0c9d - backup_restore=1 - multi_instance=1 - change_url=1 -;;; Options -Email= -Notification=none -;;; Upgrade options - ; commit=bbce7cfa6cb8916671a4fec9e8a73095f74a0c9d - name= Upgrade to 1.3.7 (#63) - manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=4533& - \ No newline at end of file diff --git a/conf/config.default.yml b/conf/config.default.yml index c9949db..a529ea6 100644 --- a/conf/config.default.yml +++ b/conf/config.default.yml @@ -41,7 +41,7 @@ EnableUpload: true EnableSeeding: true # EnableSeeding Whether upload even after there's nothing further for us. By default uploading is not altruistic, we'll only upload to encourage the peer to reciprocate. -IncomingPort: __PEER_PORT__ +IncomingPort: __PORT_PEER__ # IncomingPort The port SimpleTorrent listens to. DoneCmd: "" diff --git a/doc/DISCLAIMER.md b/doc/ADMIN.md similarity index 100% rename from doc/DISCLAIMER.md rename to doc/ADMIN.md diff --git a/doc/DISCLAIMER_fr.md b/doc/ADMIN_fr.md similarity index 100% rename from doc/DISCLAIMER_fr.md rename to doc/ADMIN_fr.md diff --git a/manifest.toml b/manifest.toml index fd03351..37f5041 100644 --- a/manifest.toml +++ b/manifest.toml @@ -16,22 +16,20 @@ admindoc = "https://github.com/boypt/simple-torrent/wiki" code = "https://github.com/boypt/simple-torrent" [integration] -yunohost = ">= 11.1.0" +yunohost = ">= 11.1.7" architectures = ["amd64","i386", "arm64"] multi_instance = true -ldap = "false" # FIXME: replace with true, false, or "not_relevant" -sso = "?" # FIXME: replace with true, false, or "not_relevant" -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 = "/simple-torrent" @@ -48,5 +46,10 @@ ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requiremen [resources.data_dir] + [resources.ports] + main.default = 3000 + peer.default = 50007 + peer.exposed = "Both" + [resources.permissions] main.url = "/" diff --git a/scripts/change_url b/scripts/change_url index e6d252b..6477fa0 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -19,16 +19,6 @@ old_path=$YNH_APP_OLD_PATH new_domain=$YNH_APP_NEW_DOMAIN new_path=$YNH_APP_NEW_PATH -app=$YNH_APP_INSTANCE_NAME - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 - -# Needed for helper "ynh_add_nginx_config" -port=$(ynh_app_setting_get --app=$app --key=port) - #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= diff --git a/scripts/install b/scripts/install index 84893aa..d443955 100644 --- a/scripts/install +++ b/scripts/install @@ -9,23 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# STANDARD MODIFICATIONS -#================================================= -# FIND AND OPEN A PORT -#================================================= -ynh_script_progression --message="Finding an available port..." --weight=0 - -# Find an available port -port=$(ynh_find_port --port=3000) -ynh_app_setting_set --app=$app --key=port --value=$port - -peer_port=$(ynh_find_port --port=50007) -# Open this port -ynh_script_progression --message="Configuring firewall..." --weight=1 -ynh_exec_warn_less yunohost firewall allow Both $peer_port -ynh_app_setting_set --app=$app --key=peer_port --value=$peer_port - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -39,19 +22,21 @@ pushd "$install_dir" mv $YNH_ARCH $app popd -chmod 750 "$install_dir" -chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" chmod +x $install_dir/$app #================================================= -# NGINX CONFIGURATION +# SYSTEM CONFIGURATION #================================================= -ynh_script_progression --message="Configuring NGINX web server..." --weight=3 +ynh_script_progression --message="Adding system configurations related to $app ..." --weight=1 # Create a dedicated NGINX config ynh_add_nginx_config +ynh_add_systemd_config + +yunohost service add $app --description="Self-hosted remote torrent client" --needs_exposed_ports="$port_peer" --log="/var/log/$app/$app.log" + #================================================= # CREATE DATA DIRECTORY #================================================= @@ -71,19 +56,8 @@ ynh_script_progression --message="Modifying a config file..." --weight=1 ynh_add_config --template="../conf/config.default.yml" --destination="$install_dir/config.yml" -#================================================= -# SETUP SYSTEMD -#================================================= -ynh_script_progression --message="Configuring a systemd service..." --weight=1 - -ynh_add_systemd_config - -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 - -yunohost service add $app --description="Self-hosted remote torrent client" --needs_exposed_ports="$peer_port" --log="/var/log/$app/$app.log" +chmod 400 "$install_dir/config.yml" +chown $app:$app "$install_dir/config.yml" #================================================= # START SYSTEMD SERVICE @@ -93,13 +67,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=2 # Start a systemd service ynh_systemd_action --service_name=$app --action=start --log_path=systemd -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=2 - -ynh_systemd_action --service_name=nginx --action=reload - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/remove b/scripts/remove index 702a2fd..2848d21 100644 --- a/scripts/remove +++ b/scripts/remove @@ -10,9 +10,11 @@ source _common.sh source /usr/share/yunohost/helpers #================================================= -# REMOVE SERVICE INTEGRATION IN YUNOHOST +# REMOVE SYSTEMD SERVICE #================================================= +ynh_script_progression --message="Removing system configurations related to $app..." --weight=5 + # Remove the service from the list of services known by YunoHost (added from `yunohost service add`) if ynh_exec_warn_less yunohost service status $app >/dev/null then @@ -20,43 +22,12 @@ then yunohost service remove $app fi -#================================================= -# STOP AND REMOVE SERVICE -#================================================= -ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1 - # Remove the dedicated systemd config ynh_remove_systemd_config -#================================================= -# 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 -#================================================= -ynh_script_progression --message="Removing NGINX web server configuration..." --weight=5 - # Remove the dedicated NGINX config ynh_remove_nginx_config -#================================================= -# CLOSE A PORT -#================================================= - -if yunohost firewall list | grep -q "\- $peer_port$" -then - ynh_script_progression --message="Closing port $peer_port..." --weight=1 - ynh_exec_warn_less yunohost firewall disallow Both $peer_port -fi - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index 1a9c817..96729f9 100644 --- a/scripts/restore +++ b/scripts/restore @@ -9,29 +9,6 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading settings..." --weight=1 - -peer_port=$(ynh_app_setting_get --app=$app --key=peer_port) - -#================================================= -# STANDARD RESTORATION STEPS -#================================================= -# RESTORE THE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the NGINX configuration..." --weight=1 - -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" - -#================================================= -# OPEN PORTS -#================================================= -ynh_script_progression --message="Configuring firewall..." --weight=3 - -ynh_exec_warn_less yunohost firewall allow Both $peer_port - #================================================= # RESTORE THE APP MAIN DIR #================================================= @@ -58,34 +35,24 @@ chmod -R o-rwx $data_dir chown -R $app:www-data $data_dir #================================================= -# RESTORE SYSTEMD +# RESTORE SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Restoring the systemd configuration..." --weight=5 +ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 + +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 -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." - yunohost service add $app --description="Self-hosted remote torrent client" --needs_exposed_ports="$peer_port" --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=1 +ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1 ynh_systemd_action --service_name=$app --action=start --log_path=systemd -#================================================= -# GENERIC FINALIZATION -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 - ynh_systemd_action --service_name=nginx --action=reload #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 1333a23..5e6c48f 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,14 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=2 - -port=$(ynh_app_setting_get --app=$app --key=port) -peer_port=$(ynh_app_setting_get --app=$app --key=peer_port) - #================================================= # CHECK VERSION #================================================= @@ -49,19 +41,21 @@ then popd fi -chmod 750 "$install_dir" -chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" chmod +x $install_dir/$app #================================================= -# NGINX CONFIGURATION +# REAPPLY SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2 +ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 # Create a dedicated NGINX config ynh_add_nginx_config +ynh_add_systemd_config + +yunohost service add $app --description="Self-hosted remote torrent client" --needs_exposed_ports="$peer_port" --log="/var/log/$app/$app.log" + #================================================= # MODIFY A CONFIG FILE #================================================= @@ -78,20 +72,6 @@ mkdir -p /home/yunohost.app/$app/{torrents,downloads} chown -R $app:www-data /home/yunohost.app/$app chmod 755 /home/yunohost.app/$app/{torrents,downloads} -#================================================= -# SETUP SYSTEMD -#================================================= -ynh_script_progression --message="Configuring a systemd service..." --weight=2 - -ynh_add_systemd_config - -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." - -yunohost service add $app --description="Self-hosted remote torrent client" --needs_exposed_ports="$peer_port" --log="/var/log/$app/$app.log" - #================================================= # START SYSTEMD SERVICE #================================================= @@ -99,13 +79,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_systemd_action --service_name=$app --action=start --log_path=systemd -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 - -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..02e740e --- /dev/null +++ b/tests.toml @@ -0,0 +1,10 @@ +test_format = 1.0 + +[default] + + # ------------------------------- + # Commits to test upgrade from + # ------------------------------- + + test_upgrade_from.bbce7cfa.name = "Upgrade from 1.3.7" + \ No newline at end of file