diff --git a/README.md b/README.md index d4f945a..288c4c2 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 The Tor network relies on volunteers to donate bandwidth. The more people who run relays, the better the Tor network will be. The current Tor network is quite small compared to the number of people who need to use Tor, which means we need more dedicated volunteers like you to run relays. -**Shipped version:** 0.4.7.13~ynh1 +**Shipped version:** 0.4.7.13~ynh3 ## Documentation and resources * Official app website: diff --git a/README_fr.md b/README_fr.md index d5a890c..ecb281c 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 The Tor network relies on volunteers to donate bandwidth. The more people who run relays, the better the Tor network will be. The current Tor network is quite small compared to the number of people who need to use Tor, which means we need more dedicated volunteers like you to run relays. -**Version incluse :** 0.4.7.13~ynh1 +**Version incluse :** 0.4.7.13~ynh3 ## Documentations et ressources * Site officiel de l’app : diff --git a/conf/torrc b/conf/torrc index 16e014d..6938ea9 100644 --- a/conf/torrc +++ b/conf/torrc @@ -3,14 +3,14 @@ BridgeRelay 1 # Replace "TODO1" with a Tor port of your choice. # This port must be externally reachable. # Avoid port 9001 because it's commonly associated with Tor and censors may be scanning the Internet for this port. -ORPort __OR_PORT__ +ORPort __PORT_OR__ ServerTransportPlugin obfs4 exec /usr/bin/obfs4proxy # Replace "TODO2" with an obfs4 port of your choice. # This port must be externally reachable and must be different from the one specified for ORPort. # Avoid port 9001 because it's commonly associated with Tor and censors may be scanning the Internet for this port. -ServerTransportListenAddr obfs4 0.0.0.0:__OBFS4_PORT__ +ServerTransportListenAddr obfs4 0.0.0.0:__PORT_OBFS4__ # Local communication port between Tor and obfs4. Always set this to "auto". # "Ext" means "extended", not "external". Don't try to set a specific port number, nor listen on 0.0.0.0. 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 571e958..0000000 --- a/manifest.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "name": "Tor relay", - "id": "torrelay", - "packaging_format": 1, - "description": { - "en": "Defend Your Privacy! How To Create Your Own Tor Relay!", - "fr": "Defend Your Privacy! How To Create Your Own Tor Relay!" - }, - "version": "0.4.7.13~ynh1", - "url": "https://www.torproject.org/", - "upstream": { - "license": "BSD-3-Clause", - "website": "https://www.torproject.org/", - "admindoc": "https://community.torproject.org/relay/setup/bridge/debian-ubuntu/", - "code": "https://github.com/torproject/tor" - }, - "license": "BSD-3-Clause", - "maintainer": { - "name": "", - "email": "" - }, - "requirements": { - "yunohost": ">= 4.3.0" - }, - "multi_instance": false, - "services": [], - "arguments": { - "install": [ - { - "name": "domain", - "type": "domain" - }, - { - "name": "contact", - "type": "string", - "ask": { - "en": "Choose an email address so we can contact you if there are problems with your bridge. This is optional but encouraged.", - "fr": "" - }, - "default": "address@email.com" - }, - { - "name": "nickname", - "type": "string", - "ask": { - "en": "Pick a nickname that you like for your bridge. This is optional.", - "fr": "" - }, - "default": "PickANickname" - } - ] - } -} \ No newline at end of file diff --git a/manifest.toml b/manifest.toml new file mode 100644 index 0000000..60ce2f9 --- /dev/null +++ b/manifest.toml @@ -0,0 +1,64 @@ +packaging_format = 2 + +id = "torrelay" +name = "Tor relay" +description.en = "Defend Your Privacy! How To Create Your Own Tor Relay!" +description.fr = "Défendez votre vie privée ! Comment créer votre propre relais Tor !" + +version = "0.4.7.13~ynh3" + +maintainers = [] + +[upstream] +license = "BSD-3-Clause" +website = "https://www.torproject.org/" +admindoc = "https://community.torproject.org/relay/setup/bridge/debian-ubuntu/" +code = "https://github.com/torproject/tor" + +[integration] +yunohost = ">= 11.1.17" +architectures = ["amd64", "arm64", "i386"] +multi_instance = false +ldap ="not_relevant" +sso = "not_relevant" +disk = "50M" +ram.build = "100M" +ram.runtime = "50M" + +[install] + [install.domain] + type = "domain" + full_domain = true + + [install.contact] + ask.en = "Choose an email address so we can contact you if there are problems with your bridge. This is optional but encouraged." + ask.fr = "Choisissez une adresse e-mail afin que nous puissions vous contacter en cas de problème avec votre pont. Ceci est facultatif mais encouragé." + type = "string" + default = "address@email.com" + + [install.nickname] + ask.en = "Pick a nickname that you like for your bridge. This is optional." + ask.fr = "Choisissez un surnom que vous aimez pour votre pont. Ceci est facultatif." + type = "string" + default = "PickANickname" + +[resources] + + [resources.ports] + or.default = 9002 + or.exposed = "Both" + obfs4.default = 9003 + obfs4.exposed = "Both" + + [resources.system_user] + + [resources.install_dir] + + [resources.permissions] + + [resources.apt] + packages = "apt-transport-https obfs4proxy" + + extras.tor.repo = "deb https://deb.torproject.org/torproject.org bullseye main" + extras.tor.key = "https://deb.torproject.org/torproject.org/A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89.asc" + extras.tor.packages = "tor tor-geoipdb deb.torproject.org-keyring" diff --git a/scripts/_common.sh b/scripts/_common.sh index ee93074..944a65e 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,10 +4,6 @@ # COMMON VARIABLES #================================================= -# dependencies used by the app -pkg_dependencies="apt-transport-https obfs4proxy" -pkg_dependencies_extra="tor tor-geoipdb deb.torproject.org-keyring" - #================================================= # PERSONAL HELPERS #================================================= diff --git a/scripts/backup b/scripts/backup index 727e06b..72da480 100755 --- a/scripts/backup +++ b/scripts/backup @@ -10,23 +10,6 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_print_info --message="Loading installation settings..." - -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) - #================================================= # DECLARE DATA AND CONF FILES TO BACKUP #================================================= diff --git a/scripts/change_url b/scripts/change_url index cfea773..ae914ad 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -9,59 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# RETRIEVE ARGUMENTS -#================================================= - -old_domain=$YNH_APP_OLD_DOMAIN -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" -final_path=$(ynh_app_setting_get --app=$app --key=final_path) - -#================================================= -# 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 - -# Backup the current version of the app -ynh_backup_before_upgrade -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" - - # Restore it if the upgrade fails - ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# CHECK WHICH PARTS SHOULD BE CHANGED -#================================================= - -change_domain=0 -if [ "$old_domain" != "$new_domain" ] -then - change_domain=1 -fi - -change_path=0 -if [ "$old_path" != "$new_path" ] -then - change_path=1 -fi - #================================================= # STANDARD MODIFICATIONS #================================================= @@ -76,35 +23,7 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app #================================================= ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 -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" - # Set global variables for NGINX helper - domain="$old_domain" - path_url="$new_path" - # Create a dedicated NGINX config - 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 - # Store file checksum for the new config file location - ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" -fi - -#================================================= -# SPECIFIC MODIFICATIONS -#================================================= -# ... -#================================================= +ynh_change_url_nginx_config #================================================= # GENERIC FINALISATION @@ -115,13 +34,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" -#================================================= -# 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/scripts/install b/scripts/install index 3087755..1ec57f4 100755 --- a/scripts/install +++ b/scripts/install @@ -9,61 +9,13 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# RETRIEVE ARGUMENTS FROM THE MANIFEST -#================================================= - -domain=$YNH_APP_ARG_DOMAIN -contact=$YNH_APP_ARG_CONTACT -nickname=$YNH_APP_ARG_NICKNAME - -app=$YNH_APP_INSTANCE_NAME - #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -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=contact --value=$contact ynh_app_setting_set --app=$app --key=nickname --value=$nickname -#================================================= -# STANDARD MODIFICATIONS -#================================================= -# FIND AND OPEN A PORT -#================================================= -ynh_script_progression --message="Finding an available port..." --weight=1 - -# Find free ports -or_port=$(ynh_find_port --port=9002) -obfs4_port=$(ynh_find_port --port=$(($or_port + 1))) - -# Find an available port -ynh_app_setting_set --app=$app --key=or_port --value=$or_port -ynh_app_setting_set --app=$app --key=obfs4_port --value=$obfs4_port - -# Open the port -ynh_script_progression --message="Configuring firewall..." --weight=1 -ynh_exec_warn_less yunohost firewall allow Both $or_port -ynh_exec_warn_less yunohost firewall allow Both $obfs4_port - -#================================================= -# INSTALL DEPENDENCIES -#================================================= -ynh_script_progression --message="Installing dependencies..." --weight=10 - -ynh_install_app_dependencies "$pkg_dependencies" - -ynh_install_extra_app_dependencies --repo="deb https://deb.torproject.org/torproject.org $(lsb_release -cs) main" --package="$pkg_dependencies_extra" --key="https://deb.torproject.org/torproject.org/A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89.asc" - #================================================= # ADD A CONFIGURATION #================================================= @@ -79,7 +31,7 @@ chown :debian-tor /etc/tor/torrc #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=2 -yunohost service add tor --description="Tor Relay" --log="/var/log/$app/$app.log" --needs_exposed_ports="$or_port" --test_status="pgrep tor" +yunohost service add tor --description="Tor Relay" --log="/var/log/$app/$app.log" --needs_exposed_ports="$port_or" --test_status="pgrep tor" #================================================= # START SYSTEMD SERVICE diff --git a/scripts/remove b/scripts/remove index ab53947..cb19bf4 100755 --- a/scripts/remove +++ b/scripts/remove @@ -9,17 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 - -app=$YNH_APP_INSTANCE_NAME - -domain=$(ynh_app_setting_get --app=$app --key=domain) -or_port=$(ynh_app_setting_get --app=$app --key=or_port) -obfs4_port=$(ynh_app_setting_get --app=$app --key=obfs4_port) - #================================================= # STANDARD REMOVE #================================================= @@ -41,30 +30,6 @@ ynh_script_progression --message="Stopping and removing the systemd service..." # Remove the dedicated systemd config ynh_remove_systemd_config --service=tor -#================================================= -# REMOVE DEPENDENCIES -#================================================= -ynh_script_progression --message="Removing dependencies..." --weight=3 - -# Remove metapackage and its dependencies -ynh_remove_app_dependencies - -#================================================= -# CLOSE A PORT -#================================================= - -if yunohost firewall list | grep -q "\- $or_port$" -then - ynh_script_progression --message="Closing port $or_port..." --weight=1 - ynh_exec_warn_less yunohost firewall disallow TCP $or_port -fi - -if yunohost firewall list | grep -q "\- $obfs4_port$" -then - ynh_script_progression --message="Closing port $obfs4_port..." --weight=1 - ynh_exec_warn_less yunohost firewall disallow TCP $obfs4_port -fi - #================================================= # SPECIFIC REMOVE #================================================= diff --git a/scripts/restore b/scripts/restore index e3cedd6..203d3a2 100755 --- a/scripts/restore +++ b/scripts/restore @@ -10,36 +10,6 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 - -app=$YNH_APP_INSTANCE_NAME - -domain=$(ynh_app_setting_get --app=$app --key=domain) -or_port=$(ynh_app_setting_get --app=$app --key=or_port) -obfs4_port=$(ynh_app_setting_get --app=$app --key=obfs4_port) - -#================================================= -# SPECIFIC RESTORATION -#================================================= -# REINSTALL DEPENDENCIES -#================================================= -ynh_script_progression --message="Reinstalling dependencies..." --weight=10 - -# Define and install dependencies -ynh_install_app_dependencies "$pkg_dependencies" - -ynh_install_extra_app_dependencies --repo="deb https://deb.torproject.org/torproject.org $(lsb_release -cs) main" --package="$pkg_dependencies_extra" --key="https://deb.torproject.org/torproject.org/A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89.asc" - #================================================= # RESTORE VARIOUS FILES #================================================= @@ -52,7 +22,7 @@ ynh_restore_file --origin_path="/etc/tor/torrc" #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -yunohost service add tor --description="Tor Relay" --log="/var/log/$app/$app.log" --needs_exposed_ports="$or_port" --test_status="pgrep tor" +yunohost service add tor --description="Tor Relay" --log="/var/log/$app/$app.log" --needs_exposed_ports="$port_or" --test_status="pgrep tor" #================================================= # START SYSTEMD SERVICE diff --git a/scripts/upgrade b/scripts/upgrade index 44d0c90..286a0d4 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,39 +9,12 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 - -app=$YNH_APP_INSTANCE_NAME - -domain=$(ynh_app_setting_get --app=$app --key=domain) -or_port=$(ynh_app_setting_get --app=$app --key=or_port) -obfs4_port=$(ynh_app_setting_get --app=$app --key=obfs4_port) -contact=$(ynh_app_setting_get --app=$app --key=contact) -nickname=$(ynh_app_setting_get --app=$app --key=nickname) - #================================================= # CHECK VERSION #================================================= 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 - -# Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { - # Restore it if the upgrade fails - ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - #================================================= # STANDARD UPGRADE STEPS #================================================= @@ -51,15 +24,6 @@ ynh_script_progression --message="Stopping a systemd service..." --weight=1 ynh_systemd_action --service_name=tor --action="stop" --log_path="systemd" -#================================================= -# UPGRADE DEPENDENCIES -#================================================= -ynh_script_progression --message="Upgrading dependencies..." --weight=10 - -ynh_install_app_dependencies "$pkg_dependencies" - -ynh_install_extra_app_dependencies --repo="deb https://deb.torproject.org/torproject.org $(lsb_release -cs) main" --package="$pkg_dependencies_extra" --key="https://deb.torproject.org/torproject.org/A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89.asc" - #================================================= # UPDATE A CONFIG FILE #================================================= @@ -75,7 +39,7 @@ chown :debian-tor /etc/tor/torrc #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -yunohost service add tor --description="Tor Relay" --log="/var/log/$app/$app.log" --needs_exposed_ports="$or_port" --test_status="pgrep tor" +yunohost service add tor --description="Tor Relay" --log="/var/log/$app/$app.log" --needs_exposed_ports="$port_or" --test_status="pgrep tor" #================================================= # START SYSTEMD SERVICE diff --git a/tests.toml b/tests.toml index cbbeef1..40d1962 100644 --- a/tests.toml +++ b/tests.toml @@ -1,3 +1,10 @@ test_format = 1.0 [default] + + # ------------------------------- + # Default args to use for install + # ------------------------------- + + args.nickname = "john" + args.contact = "address@email.com" \ No newline at end of file