From 2462aa9b5ae8d9053ef70ce513f0a6f8e5354a13 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 24 Dec 2020 23:36:49 +0100 Subject: [PATCH 01/22] Upgrade --- README.md | 71 +++++++++++++---- check_process | 20 +---- conf/app.src | 7 -- conf/nginx.conf | 1 + conf/opentracker.conf.sample | 106 +++++++++++++++++++++++++ conf/systemd.service | 4 +- manifest.json | 24 +++--- scripts/_common.sh | 120 ++++------------------------ scripts/backup | 78 ++++++++++++------ scripts/install | 137 +++++++++++++------------------- scripts/remove | 71 +++++------------ scripts/restore | 148 ++++++++++++++++++++++++---------- scripts/upgrade | 150 +++++++++++++++++++++++++++-------- 13 files changed, 545 insertions(+), 392 deletions(-) delete mode 100644 conf/app.src create mode 100644 conf/opentracker.conf.sample diff --git a/README.md b/README.md index 5e7e61d..3445154 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,67 @@ -# OpenTracker app for YunoHost -OpenTracker Server +# OpenTracker for YunoHost -**Shipped version:** 2019 +[![Integration level](https://dash.yunohost.org/integration/opentracker.svg)](https://dash.yunohost.org/appci/app/opentracker) ![](https://ci-apps.yunohost.org/ci/badges/opentracker.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/opentracker.maintain.svg) +[![Install OpenTracker with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=opentracker) -- [Yunohost project](https://yunohost.org) -- [OpenTracker website](http://erdgeist.org/arts/software/opentracker/) +*[Lire ce readme en français.](./README_fr.md)* -![](http://erdgeist.org/arts/software/opentracker/opentracker_beta3.png) +> *This package allows you to install OpenTracker quickly and simply on a YunoHost server. +If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.* +## Overview +OpenTracker is a open and free bittorrent tracker project. It aims for minimal resource usage and is intended to run at your wlan router. Currently it is deployed as an open and free tracker instance. Read our free and open tracker blog and announce your torrents there (but do not hesitate to setup your own free trackers!). -[![Install OpenTracker with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=opentracker) +**Shipped version:** 1.0 +## Screenshots -### Installing guide +![](Link to a screenshot of this app.) - App can be installed by YunoHost **admin web-interface** or by **running following command**: +## Configuration - $ sudo yunohost app install https://github.com/YunoHost-Apps/opentracker_ynh - - udp://mydomain.com:6969 +`udp://mydomain.com:6969` - -### Upgrade this package: +## Documentation - $ sudo yunohost app upgrade opentracker -u https://github.com/YunoHost-Apps/opentracker_ynh + * Official documentation: http://erdgeist.org/arts/software/opentracker/index/#overview + * YunoHost documentation: If specific documentation is needed, feel free to contribute. + +## YunoHost specific features + +#### Multi-user support + +Are LDAP and HTTP auth supported? +Can the app be used by multiple users? + +#### Supported architectures + +* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/opentracker%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/opentracker/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/opentracker%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/opentracker/) + +## Limitations + +* Any known limitations. + +## Additional information + +* Other info you would like to add about this app. + +## Links + + * Report a bug: https://github.com/YunoHost-Apps/opentracker_ynh/issues + * App website: http://erdgeist.org/arts/software/opentracker/ + * Upstream app repository: http://erdgeist.org/gitweb/opentracker/ + * YunoHost website: https://yunohost.org/ + +--- + +## Developer info + +Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/opentracker_ynh/tree/testing). + +To try the testing branch, please proceed like that. +``` +sudo yunohost app install https://github.com/YunoHost-Apps/opentracker_ynh/tree/testing --debug +or +sudo yunohost app upgrade opentracker -u https://github.com/YunoHost-Apps/opentracker_ynh/tree/testing --debug +``` diff --git a/check_process b/check_process index 0cbeae3..ef6642a 100644 --- a/check_process +++ b/check_process @@ -8,35 +8,19 @@ domain="domain.tld" (DOMAIN) path="/" (PATH) is_public=1 (PUBLIC|public=1|private=0) -# password="pass" -# nextclouddomain="domain.tld" port="9980" (PORT) ; Checks pkg_linter=1 - setup_sub_dir=0 + setup_sub_dir=1 setup_root=1 setup_nourl=0 - setup_private=0 + setup_private=1 setup_public=1 upgrade=1 backup_restore=1 multi_instance=1 - incorrect_path=1 port_already_use=0 change_url=0 -;;; Levels - Level 1=auto - Level 2=auto - Level 3=auto -# Level 4: - Level 4=1 (This app supports the Nextcloud LDAP auth) -# Level 5: - Level 5=auto - Level 6=auto - Level 7=auto - Level 8=0 - Level 9=0 - Level 10=0 ;;; Options Email= Notification=none diff --git a/conf/app.src b/conf/app.src deleted file mode 100644 index c9f8e42..0000000 --- a/conf/app.src +++ /dev/null @@ -1,7 +0,0 @@ -SOURCE_URL=https://github.com/YunoHost-Apps/opentracker_ynh/releases/download/1.0/opentracker.tar.gz -SOURCE_SUM=89bf73a92eea622a9fa12aa7d91c125bbe69dd3c8cdb70560830be120a22c57bb0e46ec80366a7d7c952400b56d39d346a8ce6a404d30117999280fd3d74071b -SOURCE_SUM_PRG=sha512sum -SOURCE_FORMAT=tar.gz -SOURCE_IN_SUBDIR=true -SOURCE_EXTRACT=true -SOURCE_FILENAME=opentracker.tar.gz diff --git a/conf/nginx.conf b/conf/nginx.conf index 4193bce..f5077b8 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,4 +1,5 @@ location ^~ __PATH__/ { + proxy_pass http://127.0.0.1:__PORT__; proxy_redirect off; proxy_set_header Host $host; diff --git a/conf/opentracker.conf.sample b/conf/opentracker.conf.sample new file mode 100644 index 0000000..db45122 --- /dev/null +++ b/conf/opentracker.conf.sample @@ -0,0 +1,106 @@ +# opentracker config file +# + +# I) Address opentracker will listen on, using both, tcp AND udp family +# (note, that port 6969 is implicite if ommitted). +# +# If no listen option is given (here or on the command line), opentracker +# listens on 0.0.0.0:6969 tcp and udp. +# +# The next variable determines if udp sockets are handled in the event +# loop (set it to 0, the default) or are handled in blocking reads in +# dedicated worker threads. You have to set this value before the +# listen.tcp_udp or listen.udp statements before it takes effect, but you +# can re-set it for each listen statement. Normally you should keep it at +# the top of the config file. +# +# listen.udp.workers 4 +# +# listen.tcp_udp 0.0.0.0 +# listen.tcp_udp 192.168.0.1:80 +# listen.tcp_udp 10.0.0.5:6969 +# +# To only listen on tcp or udp family ports, list them this way: +# +# listen.tcp 0.0.0.0 +# listen.udp 192.168.0.1:6969 +# +# Note, that using 0.0.0.0 for udp sockets may yield surprising results. +# An answer packet sent on that socket will not necessarily have the +# source address that the requesting client may expect, but any address +# on that interface. +# + +# II) If opentracker runs in a non-open mode, point it to files containing +# all torrent hashes that it will serve (shell option -w) +# +# access.whitelist /path/to/whitelist +# +# or, if opentracker was compiled to allow blacklisting (shell option -b) +# +# access.blacklist ./blacklist +# +# It is pointless and hence not possible to compile black AND white +# listing, so choose one of those options at compile time. File format +# is straight forward: "\n\n..." +# +# If you do not want to grant anyone access to your stats, enable the +# WANT_RESTRICT_STATS option in Makefile and bless the ip addresses +# allowed to fetch stats here. +# +# access.stats 192.168.0.23 +# +# There is another way of hiding your stats. You can obfuscate the path +# to them. Normally it is located at /stats but you can configure it to +# appear anywhere on your tracker. +# +# access.stats_path stats + +# III) Live sync uses udp multicast packets to keep a cluster of opentrackers +# synchronized. This option tells opentracker which port to listen for +# incoming live sync packets. The ip address tells opentracker, on which +# interface to join the multicast group, those packets will arrive. +# (shell option -i 192.168.0.1 -s 9696), port 9696 is default. +# +# livesync.cluster.listen 192.168.0.1:9696 +# +# Note that two udp sockets will be opened. One on ip address 0.0.0.0 +# port 9696, that will join the multicast group 224.0.42.23 for incoming +# udp packets and one on ip address 192.168.0.1 port 9696 for outgoing +# udp packets. +# +# As of now one and only one ip address must be given, if opentracker +# was built with the WANT_SYNC_LIVE feature. +# + +# IV) Sync between trackers running in a cluster is restricted to packets +# coming from trusted ip addresses. While source ip verification is far +# from perfect, the authors of opentracker trust in the correct +# application of tunnels, filters and LAN setups (shell option -A). +# +# livesync.cluster.node_ip 192.168.0.4 +# livesync.cluster.node_ip 192.168.0.5 +# livesync.cluster.node_ip 192.168.0.6 +# +# This is the admin ip address for old style (HTTP based) asynchronus +# tracker syncing. +# +# batchsync.cluster.admin_ip 10.1.1.1 +# + +# V) Control privilege drop behaviour. +# Put in the directory opentracker will chroot/chdir to. All black/white +# list files must be put in that directory (shell option -d). +# +# +# tracker.rootdir /usr/local/etc/opentracker +# +# Tell opentracker which user to setuid to. +# +# tracker.user nobody +# + +# VI) opentracker can be told to answer to a "GET / HTTP"-request with a +# redirect to another location (shell option -r). +# +# tracker.redirect_url https://your.tracker.local/ diff --git a/conf/systemd.service b/conf/systemd.service index 820abc5..5648dd2 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -3,12 +3,12 @@ Description=opentracker After=network.target [Service] -WorkingDirectory=/opt/opentracker User=admin Group=users Type=simple UMask=000 -ExecStart=/opt/opentracker/opentracker & +WorkingDirectory=__FINALPATH__ +ExecStart=__FINALPATH__/opentracker & RestartSec=15 Restart=always diff --git a/manifest.json b/manifest.json index 7573723..1e52281 100644 --- a/manifest.json +++ b/manifest.json @@ -3,8 +3,8 @@ "id": "opentracker", "packaging_format": 1, "description": { - "en": "OpenTracker package for YunoHost.", - "fr": "OpenTracker pour YunoHost." + "en": "Bittorrent tracker", + "fr": "Tracker Bittorrent" }, "version": "2019", "url": "http://erdgeist.org/arts/software/opentracker/", @@ -14,13 +14,11 @@ "email": "liberodark@gmail.com" }, "requirements": { - "yunohost": ">= 2.7.2" + "yunohost": ">= 3.8.1" }, "multi_instance": false, "services": [ - "nginx", - "php5-fpm", - "mysql" + "nginx" ], "arguments": { "install": [{ @@ -32,26 +30,24 @@ }, "example": "example.com" }, - { "name": "path", "type": "path", "ask": { - "en": "Choose a path for OpenTracker /opt is accepted", - "fr": "Choisissez un chemin pour OpenTracker /opt est accepté" + "en": "Choose a path for OpenTracker", + "fr": "Choisissez un chemin pour OpenTracker" }, - "example": "/opt", - "default": "/opt" + "example": "/opentracker", + "default": "/opentracker" }, - { "name": "is_public", "type": "boolean", "ask": { - "en": "Is it a public site ?", + "en": "Is it a public site?", "fr": "Est-ce un site public ?" }, - "default": "true" + "default": true } ] } diff --git a/scripts/_common.sh b/scripts/_common.sh index 0f53f77..55ab57b 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,112 +1,20 @@ #!/bin/bash -# ============================================================================= -# YUNOHOST 2.7 FORTHCOMING HELPERS -# ============================================================================= +#================================================= +# COMMON VARIABLES +#================================================= -# Create a dedicated nginx config -# -# usage: ynh_add_nginx_config -ynh_add_nginx_config () { - finalnginxconf="/etc/nginx/conf.d/$domain.d/$app.conf" - ynh_backup_if_checksum_is_different "$finalnginxconf" - sudo cp ../conf/nginx.conf "$finalnginxconf" +# dependencies used by the app +pkg_dependencies="libowfat-dev zlib1g-dev" - # To avoid a break by set -u, use a void substitution ${var:-}. If the variable is not set, it's simply set with an empty variable. - # Substitute in a nginx config file only if the variable is not empty - if test -n "${path_url:-}"; then - ynh_replace_string "__PATH__" "$path_url" "$finalnginxconf" - fi - if test -n "${domain:-}"; then - ynh_replace_string "__DOMAIN__" "$domain" "$finalnginxconf" - fi - if test -n "${port:-}"; then - ynh_replace_string "__PORT__" "$port" "$finalnginxconf" - fi - if test -n "${app:-}"; then - ynh_replace_string "__NAME__" "$app" "$finalnginxconf" - fi - if test -n "${final_path:-}"; then - ynh_replace_string "__FINALPATH__" "$final_path" "$finalnginxconf" - fi - ynh_store_file_checksum "$finalnginxconf" +#================================================= +# PERSONAL HELPERS +#================================================= - sudo systemctl reload nginx -} +#================================================= +# EXPERIMENTAL HELPERS +#================================================= -# Remove the dedicated nginx config -# -# usage: ynh_remove_nginx_config -ynh_remove_nginx_config () { - ynh_secure_remove "/etc/nginx/conf.d/$domain.d/$app.conf" - sudo systemctl reload nginx -} - -# Create a dedicated php-fpm config -# -# usage: ynh_add_fpm_config -ynh_add_fpm_config () { - finalphpconf="/etc/php5/fpm/pool.d/$app.conf" - ynh_backup_if_checksum_is_different "$finalphpconf" - sudo cp ../conf/php-fpm.conf "$finalphpconf" - ynh_replace_string "__NAMETOCHANGE__" "$app" "$finalphpconf" - ynh_replace_string "__FINALPATH__" "$final_path" "$finalphpconf" - ynh_replace_string "__USER__" "$app" "$finalphpconf" - sudo chown root: "$finalphpconf" - ynh_store_file_checksum "$finalphpconf" - - if [ -e "../conf/php-fpm.ini" ] - then - finalphpini="/etc/php5/fpm/conf.d/20-$app.ini" - ynh_backup_if_checksum_is_different "$finalphpini" - sudo cp ../conf/php-fpm.ini "$finalphpini" - sudo chown root: "$finalphpini" - ynh_store_file_checksum "$finalphpini" - fi - - sudo systemctl reload php5-fpm -} - -# Remove the dedicated php-fpm config -# -# usage: ynh_remove_fpm_config -ynh_remove_fpm_config () { - ynh_secure_remove "/etc/php5/fpm/pool.d/$app.conf" - ynh_secure_remove "/etc/php5/fpm/conf.d/20-$app.ini" 2>&1 - sudo systemctl reload php5-fpm -} - -# Create a dedicated systemd config -# -# usage: ynh_add_systemd_config -ynh_add_systemd_config () { - finalsystemdconf="/etc/systemd/system/$app.service" - ynh_backup_if_checksum_is_different "$finalsystemdconf" - sudo cp ../conf/systemd.service "$finalsystemdconf" - - # To avoid a break by set -u, use a void substitution ${var:-}. If the variable is not set, it's simply set with an empty variable. - # Substitute in a nginx config file only if the variable is not empty - if test -n "${final_path:-}"; then - ynh_replace_string "__FINALPATH__" "$final_path" "$finalsystemdconf" - fi - if test -n "${app:-}"; then - ynh_replace_string "__APP__" "$app" "$finalsystemdconf" - fi - ynh_store_file_checksum "$finalsystemdconf" - - sudo chown root: "$finalsystemdconf" - sudo systemctl enable $app - sudo systemctl daemon-reload -} - -# Remove the dedicated systemd config -# -# usage: ynh_remove_systemd_config -ynh_remove_systemd_config () { - finalsystemdconf="/etc/systemd/system/$app.service" - if [ -e "$finalsystemdconf" ]; then - sudo systemctl stop $app - sudo systemctl disable $app - ynh_secure_remove "$finalsystemdconf" - fi -} +#================================================= +# FUTURE OFFICIAL HELPERS +#================================================= diff --git a/scripts/backup b/scripts/backup index af8ccd9..fb3c925 100644 --- a/scripts/backup +++ b/scripts/backup @@ -1,33 +1,61 @@ #!/bin/bash -# Exit on command errors and treat unset variables as an error -set -eu +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= -# See comments in install script -app=$YNH_APP_INSTANCE_NAME - -# Source YunoHost helpers +# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts +source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -# Backup sources & data -# Note: the last argument is where to save this path, see the restore script. -ynh_backup "/var/www/${app}" "sources" +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= -### MySQL (remove if not used) ### -# If a MySQL database is used: -# # Dump the database -# dbname=$app -# dbuser=$app -# dbpass=$(ynh_app_setting_get "$app" mysqlpwd) -# mysqldump -u "$dbuser" -p"$dbpass" --no-create-db "$dbname" > ./dump.sql -### MySQL end ### +ynh_clean_setup () { + ### Remove this function if there's nothing to clean before calling the remove script. + true +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors -# Copy NGINX configuration -domain=$(ynh_app_setting_get "$app" domain) -ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "nginx.conf" +#================================================= +# LOAD SETTINGS +#================================================= +ynh_print_info --message="Loading installation settings..." -### PHP (remove if not used) ### -# If a dedicated php-fpm process is used: -# # Copy PHP-FPM pool configuration -# ynh_backup "/etc/php5/fpm/pool.d/${app}.conf" "php-fpm.conf" -### PHP end ### +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 +#================================================= +ynh_print_info --message="Declaring files to be backed up..." + +#================================================= +# BACKUP THE APP MAIN DIR +#================================================= + +ynh_backup --src_path="$final_path" + +#================================================= +# BACKUP THE NGINX CONFIGURATION +#================================================= + +ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" + +#================================================= +# BACKUP SYSTEMD +#================================================= + +ynh_backup --src_path="/etc/systemd/system/$app.service" + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/install b/scripts/install index 3c39c28..52c7e85 100644 --- a/scripts/install +++ b/scripts/install @@ -29,121 +29,83 @@ domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH is_public=$YNH_APP_ARG_IS_PUBLIC -### If it's a multi-instance app, meaning it can be installed several times independently -### The id of the app as stated in the manifest is available as $YNH_APP_ID -### The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...) -### The app instance name is available as $YNH_APP_INSTANCE_NAME -### - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample -### - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2 -### - ynhexample__{N} for the subsequent installations, with N=3,4, ... -### The app instance name is probably what interests you most, since this is -### guaranteed to be unique. This is a good unique identifier to define installation path, -### db names, ... app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= +ynh_script_progression --message="Validating installation parameters..." --time --weight=1 -### If the app uses nginx as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app". -### If the app provides an internal web server (or uses another application server such as uwsgi), the final path should be "/opt/yunohost/$app" final_path=/opt/$app test ! -e "$final_path" || ynh_die "This path already contains a folder" -# Normalize the url path syntax -path_url=$(ynh_normalize_url_path $path_url) - -# Check web path availability -ynh_webpath_available $domain $path_url # Register (book) web path -ynh_webpath_register $app $domain $path_url +ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= # STORE SETTINGS FROM MANIFEST #================================================= +ynh_script_progression --message="Storing installation settings..." --time --weight=1 -ynh_app_setting_set $app domain $domain -ynh_app_setting_set $app path $path_url -ynh_app_setting_set $app is_public $is_public - -#================================================= -# INSTALL DEPENDENCIES -#================================================= - -ynh_print_info "Installing dependencies..." - -### `ynh_install_app_dependencies` allows you to add any "apt" dependencies to the package. -### Those deb packages will be installed as dependencies of this package. -### If you're not using this helper: -### - Remove the section "REMOVE DEPENDENCIES" in the remove script -### - As well as the section "REINSTALL DEPENDENCIES" in the restore script -### - And the section "UPGRADE DEPENDENCIES" in the upgrade script - -ynh_install_app_dependencies libowfat-dev +ynh_app_setting_set --app=$app --key=domain --value=$domain +ynh_app_setting_set --app=$app --key=path --value=$path_url +ynh_app_setting_set --app=$app --key=is_public --value=$is_public #================================================= # FIND AND OPEN A PORT #================================================= - -### Use these lines if you have to open a port for the application -### `ynh_find_port` will find the first available port starting from the given port. -### If you're not using these lines: -### - Remove the section "CLOSE A PORT" in the remove script +ynh_script_progression --message="Configuring firewall..." --time --weight=1 # Find a free port -port=$(ynh_find_port 6969) -# Open this port -yunohost firewall allow --no-upnp UDP $port 2>&1 -ynh_app_setting_set $app port $port +port=$(ynh_find_port --port=6969) +ynh_app_setting_set --app=$app --key=port --value=$port + +# Open the port +ynh_exec_warn_less yunohost firewall allow Both $port + +#================================================= +# INSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Installing dependencies..." --time --weight=1 + +ynh_install_app_dependencies $pkg_dependencies #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_print_info "Installing OpenTracker..." -ynh_app_setting_set $app final_path $final_path -# Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source "$final_path" +ynh_app_setting_set --app=$app --key=final_path --value=$final_path -#================================================= -# SETUP SYSTEMD -#================================================= +git clone git://erdgeist.org/opentracker "$final_path" --quiet -ynh_add_systemd_config -systemctl enable $app.service +pushd "$final_path" || ynh_die + make + popd || ynh_die #================================================= # NGINX CONFIGURATION #================================================= +ynh_script_progression --message="Configuring NGINX web server..." --time --weight=1 -# Create a dedicated nginx config +# Create a dedicated NGINX config ynh_add_nginx_config #================================================= # CREATE DEDICATED USER #================================================= +ynh_script_progression --message="Configuring system user..." --time --weight=1 # Create a system user -ynh_system_user_create $app +ynh_system_user_create --username=$app #================================================= -# MODIFY A CONFIG FILE +# SETUP SYSTEMD #================================================= -#cp -a ../conf/onlyoffice-documentserver.conf /etc/onlyoffice/documentserver/nginx/onlyoffice-documentserver.conf -#ynh_replace_string "__NEXTCLOUDDOMAIN__" "$nextcloud_domain" "/etc/loolwsd/loolwsd.xml" -#ynh_replace_string "__PASSWORD__" "$password" "/etc/loolwsd/loolwsd.xml" - -#================================================= -# STORE THE CONFIG FILE CHECKSUM -#================================================= - -### `ynh_store_file_checksum` is used to store the checksum of a file. -### That way, during the upgrade script, by using `ynh_backup_if_checksum_is_different`, -### you can make a backup of this file before modifying it again if the admin had modified it. - -# Calculate and store the config file checksum into the app settings -#ynh_store_file_checksum "/etc/onlyoffice/documentserver/nginx/onlyoffice-documentserver.conf" +ynh_script_progression --message="Configuring a systemd service..." --time --weight=1 +# Create a dedicated systemd config +ynh_add_systemd_config #================================================= # GENERIC FINALIZATION @@ -151,25 +113,38 @@ ynh_system_user_create $app # SECURE FILES AND DIRECTORIES #================================================= -### For security reason, any app should set the permissions to root: before anything else. -### Then, if write authorization is needed, any access should be given only to directories -### that really need such authorization. - # Set permissions to app files chown -R admin:1007 $final_path chmod +x $final_path/opentracker +#================================================= +# START SYSTEMD SERVICE +#================================================= +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" --needs_exposed_ports "$port" #================================================= # SETUP SSOWAT #================================================= +ynh_script_progression --message="Configuring SSOwat..." --weight=1 -# If app is public, add url to SSOWat conf as skipped_uris -if [ $is_public -eq 1 ]; then - # unprotected_uris allows SSO credentials to be passed anyway. - ynh_app_setting_set "$app" unprotected_uris "/" +# Make app public if necessary or protect it +if [ $is_public -eq 1 ] +then + ynh_permission_update --permission "main" --add "visitors" fi -# Reload services -systemctl start $app -systemctl reload nginx +#================================================= +# RELOAD NGINX +#================================================= +ynh_script_progression --message="Reloading NGINX web server..." --weight=2 + +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Installation of OpenTracker completed" --last diff --git a/scripts/remove b/scripts/remove index 4446429..f16c3b6 100644 --- a/scripts/remove +++ b/scripts/remove @@ -12,33 +12,31 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_print_info "Loading installation settings..." +ynh_script_progression --message="Loading installation settings..." --time --weight=1 app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get $app domain) -port=$(ynh_app_setting_get $app port) -db_name=$(ynh_app_setting_get $app db_name) -db_user=$db_name -final_path=$(ynh_app_setting_get $app final_path) +domain=$(ynh_app_setting_get --app=$app --key=domain) +port=$(ynh_app_setting_get --app=$app --key=port) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # STANDARD REMOVE #================================================= -# REMOVE SERVICE FROM ADMIN PANEL +# REMOVE SERVICE INTEGRATION IN YUNOHOST #================================================= -# Remove a service from the admin panel, added by `yunohost service add` -if yunohost service status $app >/dev/null 2>&1 +# 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 - ynh_print_info "Removing $app service" + ynh_script_progression --message="Removing $app service integration..." --time --weight=1 yunohost service remove $app fi #================================================= # STOP AND REMOVE SERVICE #================================================= -ynh_print_info "Stopping and removing the systemd service" +ynh_script_progression --message="Stopping and removing the systemd service..." --time --weight=1 # Remove the dedicated systemd config ynh_remove_systemd_config @@ -46,7 +44,7 @@ ynh_remove_systemd_config #================================================= # REMOVE DEPENDENCIES #================================================= -ynh_print_info "Removing dependencies" +ynh_script_progression --message="Removing dependencies..." --time --weight=1 # Remove metapackage and its dependencies ynh_remove_app_dependencies @@ -54,72 +52,41 @@ ynh_remove_app_dependencies #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_print_info "Removing app main directory" +ynh_script_progression --message="Removing app main directory..." --time --weight=1 # Remove the app directory securely -ynh_secure_remove "$final_path" +ynh_secure_remove --file="$final_path" #================================================= # REMOVE NGINX CONFIGURATION #================================================= -ynh_print_info "Removing nginx web server configuration" +ynh_script_progression --message="Removing NGINX web server configuration..." --time --weight=1 -# Remove the dedicated nginx config +# Remove the dedicated NGINX config ynh_remove_nginx_config -#================================================= -# REMOVE PHP-FPM CONFIGURATION -#================================================= -#ynh_print_info "Removing php-fpm configuration" - -# Remove the dedicated php-fpm config -#ynh_remove_fpm_config - -#================================================= -# REMOVE LOGROTATE CONFIGURATION -#================================================= -ynh_print_info "Removing logrotate configuration" - -# Remove the app-specific logrotate config -ynh_remove_logrotate - #================================================= # CLOSE A PORT #================================================= if yunohost firewall list | grep -q "\- $port$" then - ynh_print_info "Closing port $port" - ynh_exec_warn_less yunohost firewall disallow TCP $port + ynh_script_progression --message="Closing port $port..." --time --weight=1 + ynh_exec_warn_less yunohost firewall disallow Both $port fi -#================================================= -# SPECIFIC REMOVE -#================================================= -# REMOVE THE CRON FILE -#================================================= - -# Remove a cron file -ynh_secure_remove "/etc/cron.d/$app" - -# Remove a directory securely -ynh_secure_remove "/etc/$app/" - -# Remove the log files -ynh_secure_remove "/var/log/$app/" - #================================================= # GENERIC FINALIZATION #================================================= # REMOVE DEDICATED USER #================================================= -ynh_print_info "Removing the dedicated system user" +ynh_script_progression --message="Removing the dedicated system user..." --time --weight=1 # Delete a system user -ynh_system_user_delete $app +ynh_system_user_delete --username=$app #================================================= # END OF SCRIPT #================================================= -ynh_print_info "Removal of $app completed" +ynh_script_progression --message="Removal of $app completed" --time --last diff --git a/scripts/restore b/scripts/restore index 93169e9..dc654e2 100644 --- a/scripts/restore +++ b/scripts/restore @@ -1,52 +1,120 @@ #!/bin/bash -# Note: each files and directories you've saved using the ynh_backup helper -# will be located in the current directory, regarding the last argument. +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= -# Exit on command errors and treat unset variables as an error -set -eu - -# See comments in install script -app=$YNH_APP_INSTANCE_NAME - -# Source YunoHost helpers +# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts +source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -# Retrieve old app settings -domain=$(ynh_app_setting_get "$app" domain) -path_url=$(ynh_app_setting_get "$app" path_url) +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= -# Check domain/path availability -sudo yunohost app checkurl "${domain}${path_url}" -a "$app" \ - || ynh_die "Path not available: ${domain}${path_url}" +ynh_clean_setup () { + #### Remove this function if there's nothing to clean before calling the remove script. + true +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors -# Restore sources & data -src_path="/var/www/${app}" -sudo cp -a ./sources "$src_path" +#================================================= +# LOAD SETTINGS +#================================================= +ynh_script_progression --message="Loading installation settings..." --time --weight=1 -# Restore permissions to app files -# you may need to make some file and/or directory writeable by www-data (nginx user) -sudo chown -R root: "$src_path" +app=$YNH_APP_INSTANCE_NAME -### MySQL (remove if not used) ### -# If a MySQL database is used: -# # Create and restore the database -# dbname=$app -# dbuser=$app -# dbpass=$(ynh_app_setting_get "$app" mysqlpwd) -# ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass" -# ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ./dump.sql -### MySQL end ### +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) -# Restore NGINX configuration -sudo cp -a ./nginx.conf "/etc/nginx/conf.d/${domain}.d/${app}.conf" +#================================================= +# CHECK IF THE APP CAN BE RESTORED +#================================================= +ynh_script_progression --message="Validating restoration parameters..." --time --weight=1 -### PHP (remove if not used) ### -# If a dedicated php-fpm process is used: -# # Copy PHP-FPM pool configuration and reload the service -# sudo cp -a ./php-fpm.conf "/etc/php5/fpm/pool.d/${app}.conf" -# sudo service php5-fpm reload -### PHP end ### +ynh_webpath_available --domain=$domain --path_url=$path_url \ + || ynh_die --message="Path not available: ${domain}${path_url}" +test ! -d $final_path \ + || ynh_die --message="There is already a directory: $final_path " -# Restart webserver -sudo service nginx reload +#================================================= +# STANDARD RESTORATION STEPS +#================================================= +# RESTORE THE NGINX CONFIGURATION +#================================================= + +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" + +#================================================= +# RESTORE THE APP MAIN DIR +#================================================= +ynh_script_progression --message="Restoring the app main directory..." --time --weight=1 + +ynh_restore_file --origin_path="$final_path" + +#================================================= +# RECREATE THE DEDICATED USER +#================================================= +ynh_script_progression --message="Recreating the dedicated system user..." --time --weight=1 + +# Create the dedicated user (if not existing) +ynh_system_user_create --username=$app + +#================================================= +# RESTORE USER RIGHTS +#================================================= + +# Restore permissions on app files +chown -R root: $final_path + +#================================================= +# SPECIFIC RESTORATION +#================================================= +# REINSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Reinstalling dependencies..." --time --weight=1 + +# Define and install dependencies +ynh_install_app_dependencies $pkg_dependencies + +#================================================= +# RESTORE SYSTEMD +#================================================= +ynh_script_progression --message="Restoring the systemd configuration..." --time --weight=1 + +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..." --time --weight=1 + +yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log" + +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." --time --weight=1 + +ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" + +#================================================= +# GENERIC FINALIZATION +#================================================= +# RELOAD NGINX AND PHP-FPM +#================================================= +ynh_script_progression --message="Reloading NGINX web server..." --time --weight=1 + +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Restoration completed for $app" --time --last diff --git a/scripts/upgrade b/scripts/upgrade index 3ad3f7a..5f2bc79 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,56 +1,142 @@ #!/bin/bash -# Exit on command errors and treat unset variables as an error -set -eu +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= -# See comments in install script -app=$YNH_APP_INSTANCE_NAME -final_path=/opt/yunohost/$app - -# Source YunoHost helpers +source _common.sh source /usr/share/yunohost/helpers -# Stop emby-server service -systemctl stop emby-server +#================================================= +# LOAD SETTINGS +#================================================= +ynh_script_progression --message="Loading installation settings..." --time --weight=1 + +app=$YNH_APP_INSTANCE_NAME + +domain=$(ynh_app_setting_get --app=$app --key=domain) +path_url=$(ynh_app_setting_get --app=$app --key=path) +is_public=$(ynh_app_setting_get --app=$app --key=is_public) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) + + +#================================================= +# CHECK VERSION +#================================================= + +upgrade_type=$(ynh_check_app_version_changed) + +#================================================= +# ENSURE DOWNWARD COMPATIBILITY +#================================================= +ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1 + +# If final_path doesn't exist, create it +#if [ -z "$final_path" ]; then +# final_path=/var/www/$app +# ynh_app_setting_set --app=$app --key=final_path --value=$final_path +#fi + +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --time --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 +#================================================= +# STOP SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Stopping a systemd service..." --time --weight=1 + +ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_app_setting_set $app final_path $final_path -# Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source "$final_path" +if [ "$upgrade_type" == "UPGRADE_APP" ] +then + ynh_script_progression --message="Upgrading source files..." --time --weight=1 -#============================================== -# INSTALL PLEX -#============================================== - -dpkg --install $final_path/emby-server-deb* + # Download, check integrity, uncompress and patch the source from app.src + ynh_setup_source --dest_dir="$final_path" +fi #================================================= # NGINX CONFIGURATION #================================================= +ynh_script_progression --message="Upgrading NGINX web server configuration..." --time --weight=1 -# Create a dedicated nginx config -#ynh_add_nginx_config - +# Create a dedicated NGINX config +ynh_add_nginx_config #================================================= -# UPGRADE CONFIG +# UPGRADE DEPENDENCIES #================================================= -#cp -a ../conf/loolwsd.xml /etc/loolwsd -#ynh_replace_string "__NEXTCLOUDDOMAIN__" "$nextcloud_domain" "/etc/loolwsd/loolwsd.xml" -#ynh_replace_string "__PASSWORD__" "$password" "/etc/loolwsd/loolwsd.xml" -#systemctl restart loolwsd +ynh_script_progression --message="Upgrading dependencies..." --time --weight=1 +ynh_install_app_dependencies $pkg_dependencies +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Making sure dedicated system user exists..." --time --weight=1 -# If app is public, add url to SSOWat conf as skipped_uris -#if [[ $is_public -eq 1 ]]; then - # See install script -# ynh_app_setting_set "$app" unprotected_uris "/" -#fi +# Create a dedicated user (if not existing) +ynh_system_user_create --username=$app -# Start emby-server service -systemctl start emby-server +#================================================= +# SETUP SYSTEMD +#================================================= +ynh_script_progression --message="Upgrading systemd configuration..." --time --weight=1 +# Create a dedicated systemd config +ynh_add_systemd_config + +#================================================= +# GENERIC FINALIZATION +#================================================= +# SECURE FILES AND DIRECTORIES +#================================================= + +# Set permissions on app files +chown -R root: $final_path + +#================================================= +# INTEGRATE SERVICE IN YUNOHOST +#================================================= +ynh_script_progression --message="Integrating service in YunoHost..." --time --weight=1 + +yunohost service add $app --description "A short description of the app" --log "/var/log/$app/$app.log" + +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." --time --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..." --time --weight=1 + +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Upgrade of $app completed" --time --last From 0835f81629e2e04b735a414a1be58e34e31fdf6b Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 24 Dec 2020 23:40:58 +0100 Subject: [PATCH 02/22] Update install --- scripts/install | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 52c7e85..9dac559 100644 --- a/scripts/install +++ b/scripts/install @@ -80,7 +80,7 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path git clone git://erdgeist.org/opentracker "$final_path" --quiet pushd "$final_path" || ynh_die - make + ynh_exec_warn_less make popd || ynh_die #================================================= @@ -123,7 +123,7 @@ chmod +x $final_path/opentracker 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" --needs_exposed_ports "$port" +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" #--needs_exposed_ports "$port" #================================================= # SETUP SSOWAT From fcf484e0c406dfeb9e91b83a17a5b3153daf9eb5 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 24 Dec 2020 23:46:27 +0100 Subject: [PATCH 03/22] Fix --- scripts/backup | 3 +-- scripts/install | 19 +++++++++---------- scripts/remove | 18 +++++++++--------- scripts/restore | 8 +++----- 4 files changed, 22 insertions(+), 26 deletions(-) diff --git a/scripts/backup b/scripts/backup index fb3c925..ed9df11 100644 --- a/scripts/backup +++ b/scripts/backup @@ -15,8 +15,7 @@ source /usr/share/yunohost/helpers #================================================= ynh_clean_setup () { - ### Remove this function if there's nothing to clean before calling the remove script. - true + ynh_clean_check_starting } # Exit if an error occurs during the execution of the script ynh_abort_if_errors diff --git a/scripts/install b/scripts/install index 9dac559..bac4a1d 100644 --- a/scripts/install +++ b/scripts/install @@ -14,8 +14,7 @@ source /usr/share/yunohost/helpers #================================================= ynh_clean_setup () { - ### Remove this function if there's nothing to clean before calling the remove script. - true + ynh_clean_check_starting } # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -34,7 +33,7 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -ynh_script_progression --message="Validating installation parameters..." --time --weight=1 +ynh_script_progression --message="Validating installation parameters..." --weight=1 final_path=/opt/$app test ! -e "$final_path" || ynh_die "This path already contains a folder" @@ -45,7 +44,7 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_script_progression --message="Storing installation settings..." --time --weight=1 +ynh_script_progression --message="Storing installation settings..." --weight=1 ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=path --value=$path_url @@ -54,7 +53,7 @@ ynh_app_setting_set --app=$app --key=is_public --value=$is_public #================================================= # FIND AND OPEN A PORT #================================================= -ynh_script_progression --message="Configuring firewall..." --time --weight=1 +ynh_script_progression --message="Configuring firewall..." --weight=1 # Find a free port port=$(ynh_find_port --port=6969) @@ -66,14 +65,14 @@ ynh_exec_warn_less yunohost firewall allow Both $port #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing dependencies..." --time --weight=1 +ynh_script_progression --message="Installing dependencies..." --weight=2 ynh_install_app_dependencies $pkg_dependencies #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_print_info "Installing OpenTracker..." +ynh_print_info "Installing OpenTracker..." --weight=5 ynh_app_setting_set --app=$app --key=final_path --value=$final_path @@ -86,7 +85,7 @@ pushd "$final_path" || ynh_die #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Configuring NGINX web server..." --time --weight=1 +ynh_script_progression --message="Configuring NGINX web server..." --weight=10 # Create a dedicated NGINX config ynh_add_nginx_config @@ -94,7 +93,7 @@ ynh_add_nginx_config #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Configuring system user..." --time --weight=1 +ynh_script_progression --message="Configuring system user..." --weight=1 # Create a system user ynh_system_user_create --username=$app @@ -102,7 +101,7 @@ ynh_system_user_create --username=$app #================================================= # SETUP SYSTEMD #================================================= -ynh_script_progression --message="Configuring a systemd service..." --time --weight=1 +ynh_script_progression --message="Configuring a systemd service..." --weight=2 # Create a dedicated systemd config ynh_add_systemd_config diff --git a/scripts/remove b/scripts/remove index f16c3b6..3e706bb 100644 --- a/scripts/remove +++ b/scripts/remove @@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --time --weight=1 +ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME @@ -29,14 +29,14 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) # 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 - ynh_script_progression --message="Removing $app service integration..." --time --weight=1 + ynh_script_progression --message="Removing $app service integration..." --weight=1 yunohost service remove $app fi #================================================= # STOP AND REMOVE SERVICE #================================================= -ynh_script_progression --message="Stopping and removing the systemd service..." --time --weight=1 +ynh_script_progression --message="Stopping and removing the systemd service..." --weight=2 # Remove the dedicated systemd config ynh_remove_systemd_config @@ -44,7 +44,7 @@ ynh_remove_systemd_config #================================================= # REMOVE DEPENDENCIES #================================================= -ynh_script_progression --message="Removing dependencies..." --time --weight=1 +ynh_script_progression --message="Removing dependencies..." --weight=2 # Remove metapackage and its dependencies ynh_remove_app_dependencies @@ -52,7 +52,7 @@ ynh_remove_app_dependencies #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_script_progression --message="Removing app main directory..." --time --weight=1 +ynh_script_progression --message="Removing app main directory..." --weight=1 # Remove the app directory securely ynh_secure_remove --file="$final_path" @@ -60,7 +60,7 @@ ynh_secure_remove --file="$final_path" #================================================= # REMOVE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Removing NGINX web server configuration..." --time --weight=1 +ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1 # Remove the dedicated NGINX config ynh_remove_nginx_config @@ -71,7 +71,7 @@ ynh_remove_nginx_config if yunohost firewall list | grep -q "\- $port$" then - ynh_script_progression --message="Closing port $port..." --time --weight=1 + ynh_script_progression --message="Closing port $port..." --weight=1 ynh_exec_warn_less yunohost firewall disallow Both $port fi @@ -80,7 +80,7 @@ fi #================================================= # REMOVE DEDICATED USER #================================================= -ynh_script_progression --message="Removing the dedicated system user..." --time --weight=1 +ynh_script_progression --message="Removing the dedicated system user..." --weight=2 # Delete a system user ynh_system_user_delete --username=$app @@ -89,4 +89,4 @@ ynh_system_user_delete --username=$app # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of $app completed" --time --last +ynh_script_progression --message="Removal of $app completed" --last diff --git a/scripts/restore b/scripts/restore index dc654e2..f0efb8b 100644 --- a/scripts/restore +++ b/scripts/restore @@ -6,7 +6,6 @@ # IMPORT GENERIC HELPERS #================================================= -# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -15,8 +14,7 @@ source /usr/share/yunohost/helpers #================================================= ynh_clean_setup () { - #### Remove this function if there's nothing to clean before calling the remove script. - true + ynh_clean_check_starting } # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -24,7 +22,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --time --weight=1 +ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME @@ -53,7 +51,7 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." --time --weight=1 +ynh_script_progression --message="Restoring the app main directory..." --weight=1 ynh_restore_file --origin_path="$final_path" From c2441a626c96c4414897c46d2205b2ec609bb4b5 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 24 Dec 2020 23:51:01 +0100 Subject: [PATCH 04/22] Fix --- scripts/install | 9 ++++++++- scripts/restore | 18 +++++++++--------- scripts/upgrade | 26 +++++++++++++------------- 3 files changed, 30 insertions(+), 23 deletions(-) diff --git a/scripts/install b/scripts/install index bac4a1d..a1e813d 100644 --- a/scripts/install +++ b/scripts/install @@ -72,7 +72,7 @@ ynh_install_app_dependencies $pkg_dependencies #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_print_info "Installing OpenTracker..." --weight=5 +ynh_script_progression --message="Installing OpenTracker..." --weight=5 ynh_app_setting_set --app=$app --key=final_path --value=$final_path @@ -116,6 +116,13 @@ ynh_add_systemd_config chown -R admin:1007 $final_path chmod +x $final_path/opentracker +#================================================= +# INTEGRATE SERVICE IN YUNOHOST +#================================================= +ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 + +yunohost service add $app --description "A short description of the app" --log "/var/log/$app/$app.log" + #================================================= # START SYSTEMD SERVICE #================================================= diff --git a/scripts/restore b/scripts/restore index f0efb8b..39e0957 100644 --- a/scripts/restore +++ b/scripts/restore @@ -33,7 +33,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= -ynh_script_progression --message="Validating restoration parameters..." --time --weight=1 +ynh_script_progression --message="Validating restoration parameters..." --weight=1 ynh_webpath_available --domain=$domain --path_url=$path_url \ || ynh_die --message="Path not available: ${domain}${path_url}" @@ -51,14 +51,14 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." --weight=1 +ynh_script_progression --message="Restoring the app main directory..." --weight=2 ynh_restore_file --origin_path="$final_path" #================================================= # RECREATE THE DEDICATED USER #================================================= -ynh_script_progression --message="Recreating the dedicated system user..." --time --weight=1 +ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 # Create the dedicated user (if not existing) ynh_system_user_create --username=$app @@ -75,7 +75,7 @@ chown -R root: $final_path #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Reinstalling dependencies..." --time --weight=1 +ynh_script_progression --message="Reinstalling dependencies..." --time --weight=2 # Define and install dependencies ynh_install_app_dependencies $pkg_dependencies @@ -83,7 +83,7 @@ ynh_install_app_dependencies $pkg_dependencies #================================================= # RESTORE SYSTEMD #================================================= -ynh_script_progression --message="Restoring the systemd configuration..." --time --weight=1 +ynh_script_progression --message="Restoring the systemd configuration..." --weight=11 ynh_restore_file --origin_path="/etc/systemd/system/$app.service" systemctl enable $app.service --quiet @@ -91,14 +91,14 @@ systemctl enable $app.service --quiet #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --time --weight=1 +ynh_script_progression --message="Integrating service in YunoHost..." --weight=2 yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --time --weight=1 +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" @@ -107,7 +107,7 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap #================================================= # RELOAD NGINX AND PHP-FPM #================================================= -ynh_script_progression --message="Reloading NGINX web server..." --time --weight=1 +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 ynh_systemd_action --service_name=nginx --action=reload @@ -115,4 +115,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for $app" --time --last +ynh_script_progression --message="Restoration completed for $app" --last diff --git a/scripts/upgrade b/scripts/upgrade index 5f2bc79..adc9ba9 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --time --weight=1 +ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME @@ -31,7 +31,7 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1 +ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 # If final_path doesn't exist, create it #if [ -z "$final_path" ]; then @@ -42,7 +42,7 @@ ynh_script_progression --message="Ensuring downward compatibility..." --time --w #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --time --weight=1 +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 @@ -58,7 +58,7 @@ ynh_abort_if_errors #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping a systemd service..." --time --weight=1 +ynh_script_progression --message="Stopping a systemd service..." --weight=5 ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" @@ -68,7 +68,7 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_script_progression --message="Upgrading source files..." --time --weight=1 + ynh_script_progression --message="Upgrading source files..." --weight=1 # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path" @@ -77,7 +77,7 @@ fi #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading NGINX web server configuration..." --time --weight=1 +ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=3 # Create a dedicated NGINX config ynh_add_nginx_config @@ -85,14 +85,14 @@ ynh_add_nginx_config #================================================= # UPGRADE DEPENDENCIES #================================================= -ynh_script_progression --message="Upgrading dependencies..." --time --weight=1 +ynh_script_progression --message="Upgrading dependencies..." --weight=2 ynh_install_app_dependencies $pkg_dependencies #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." --time --weight=1 +ynh_script_progression --message="Making sure dedicated system user exists..." --weight=5 # Create a dedicated user (if not existing) ynh_system_user_create --username=$app @@ -100,7 +100,7 @@ ynh_system_user_create --username=$app #================================================= # SETUP SYSTEMD #================================================= -ynh_script_progression --message="Upgrading systemd configuration..." --time --weight=1 +ynh_script_progression --message="Upgrading systemd configuration..." --weight=1 # Create a dedicated systemd config ynh_add_systemd_config @@ -117,21 +117,21 @@ chown -R root: $final_path #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --time --weight=1 +ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 yunohost service add $app --description "A short description of the app" --log "/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --time --weight=1 +ynh_script_progression --message="Starting a systemd service..." --weight=2 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..." --time --weight=1 +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 ynh_systemd_action --service_name=nginx --action=reload @@ -139,4 +139,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" --time --last +ynh_script_progression --message="Upgrade of $app completed" --last From 1a1714a927883dcadf7d49aeba9808a1f9deb00c Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Fri, 25 Dec 2020 11:26:01 +0100 Subject: [PATCH 05/22] Add Makefile --- conf/Makefile | 87 ++++++++++++++++++++++++++++++++++++++++++++++ scripts/_common.sh | 2 +- 2 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 conf/Makefile diff --git a/conf/Makefile b/conf/Makefile new file mode 100644 index 0000000..92e9937 --- /dev/null +++ b/conf/Makefile @@ -0,0 +1,87 @@ +# $Id$ + +CC?=gcc + +# Linux flavour +# PREFIX?=/opt/diet +# LIBOWFAT_HEADERS=$(PREFIX)/include +# LIBOWFAT_LIBRARY=$(PREFIX)/lib + +# BSD flavour +# PREFIX?=/usr/local +# LIBOWFAT_HEADERS=$(PREFIX)/include/libowfat +# LIBOWFAT_LIBRARY=$(PREFIX)/lib + +# Debug flavour +PREFIX?=.. +LIBOWFAT_HEADERS=$(PREFIX)/libowfat +LIBOWFAT_LIBRARY=$(PREFIX)/libowfat + +BINDIR?=$(PREFIX)/bin + +FEATURES+=-DWANT_V6 + +#FEATURES+=-DWANT_ACCESSLIST_BLACK +#FEATURES+=-DWANT_ACCESSLIST_WHITE + +#FEATURES+=-DWANT_SYNC_LIVE +#FEATURES+=-DWANT_IP_FROM_QUERY_STRING +FEATURES+=-DWANT_COMPRESSION_GZIP +#FEATURES+=-DWANT_COMPRESSION_GZIP_ALWAYS +#FEATURES+=-DWANT_LOG_NETWORKS +#FEATURES+=-DWANT_RESTRICT_STATS +#FEATURES+=-DWANT_IP_FROM_PROXY +#FEATURES+=-DWANT_FULLLOG_NETWORKS +#FEATURES+=-DWANT_LOG_NUMWANT +#FEATURES+=-DWANT_MODEST_FULLSCRAPES +#FEATURES+=-DWANT_SPOT_WOODPECKER +#FEATURES+=-DWANT_SYSLOGS +#FEATURES+=-DWANT_DEV_RANDOM +FEATURES+=-DWANT_FULLSCRAPE + +#FEATURES+=-D_DEBUG_HTTPERROR + +OPTS_debug=-D_DEBUG -g -ggdb # -pg -fprofile-arcs -ftest-coverage +OPTS_production=-O3 + +CFLAGS+=-I$(LIBOWFAT_HEADERS) -Wall -pipe -Wextra #-ansi -pedantic +LDFLAGS+=-L$(LIBOWFAT_LIBRARY) -lowfat -pthread -lpthread -lz + +BINARY =opentracker +HEADERS=trackerlogic.h scan_urlencoded_query.h ot_mutex.h ot_stats.h ot_vector.h ot_clean.h ot_udp.h ot_iovec.h ot_fullscrape.h ot_accesslist.h ot_http.h ot_livesync.h ot_rijndael.h +SOURCES=opentracker.c trackerlogic.c scan_urlencoded_query.c ot_mutex.c ot_stats.c ot_vector.c ot_clean.c ot_udp.c ot_iovec.c ot_fullscrape.c ot_accesslist.c ot_http.c ot_livesync.c ot_rijndael.c +SOURCES_proxy=proxy.c ot_vector.c ot_mutex.c + +OBJECTS = $(SOURCES:%.c=%.o) +OBJECTS_debug = $(SOURCES:%.c=%.debug.o) +OBJECTS_proxy = $(SOURCES_proxy:%.c=%.o) +OBJECTS_proxy_debug = $(SOURCES_proxy:%.c=%.debug.o) + +.SUFFIXES: .debug.o .o .c + +all: $(BINARY) $(BINARY).debug + +CFLAGS_production = $(CFLAGS) $(OPTS_production) $(FEATURES) +CFLAGS_debug = $(CFLAGS) $(OPTS_debug) $(FEATURES) + +$(BINARY): $(OBJECTS) $(HEADERS) + $(CC) -o $@ $(OBJECTS) $(LDFLAGS) + strip $@ +$(BINARY).debug: $(OBJECTS_debug) $(HEADERS) + $(CC) -o $@ $(OBJECTS_debug) $(LDFLAGS) +proxy: $(OBJECTS_proxy) $(HEADERS) + $(CC) -o $@ $(OBJECTS_proxy) $(CFLAGS_production) $(LDFLAGS) +proxy.debug: $(OBJECTS_proxy_debug) $(HEADERS) + $(CC) -o $@ $(OBJECTS_proxy_debug) $(LDFLAGS) + +.c.debug.o : $(HEADERS) + $(CC) -c -o $@ $(CFLAGS_debug) $(<:.debug.o=.c) + +.c.o : $(HEADERS) + $(CC) -c -o $@ $(CFLAGS_production) $< + +clean: + rm -rf opentracker opentracker.debug *.o *~ + +install: + install -m 755 opentracker $(BINDIR) diff --git a/scripts/_common.sh b/scripts/_common.sh index 55ab57b..6119194 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,7 @@ #================================================= # dependencies used by the app -pkg_dependencies="libowfat-dev zlib1g-dev" +pkg_dependencies="libowfat-dev zlib1g-dev make build-essential" #================================================= # PERSONAL HELPERS From 8c0e6f6b78c8afa52310314b430546368d630e7c Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Fri, 25 Dec 2020 11:28:21 +0100 Subject: [PATCH 06/22] Fix linter warnings --- 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 a1e813d..8d3fefa 100644 --- a/scripts/install +++ b/scripts/install @@ -121,7 +121,7 @@ chmod +x $final_path/opentracker #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -yunohost service add $app --description "A short description of the app" --log "/var/log/$app/$app.log" +yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE diff --git a/scripts/restore b/scripts/restore index 39e0957..7147947 100644 --- a/scripts/restore +++ b/scripts/restore @@ -75,7 +75,7 @@ chown -R root: $final_path #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Reinstalling dependencies..." --time --weight=2 +ynh_script_progression --message="Reinstalling dependencies..." --weight=2 # Define and install dependencies ynh_install_app_dependencies $pkg_dependencies diff --git a/scripts/upgrade b/scripts/upgrade index adc9ba9..4894753 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -119,7 +119,7 @@ chown -R root: $final_path #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -yunohost service add $app --description "A short description of the app" --log "/var/log/$app/$app.log" +yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE From 052b4893a45ec2b6d66ecd081179b48810faba4e Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Fri, 25 Dec 2020 12:31:59 +0100 Subject: [PATCH 07/22] Update check_process --- check_process | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check_process b/check_process index ef6642a..c11e66f 100644 --- a/check_process +++ b/check_process @@ -18,7 +18,7 @@ setup_public=1 upgrade=1 backup_restore=1 - multi_instance=1 + multi_instance=0 port_already_use=0 change_url=0 ;;; Options From baf9aef34151dadc74f23756a2ca696c24d85454 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Fri, 25 Dec 2020 12:34:37 +0100 Subject: [PATCH 08/22] Update upgrade --- scripts/upgrade | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 4894753..9197ad0 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -21,7 +21,6 @@ path_url=$(ynh_app_setting_get --app=$app --key=path) is_public=$(ynh_app_setting_get --app=$app --key=is_public) final_path=$(ynh_app_setting_get --app=$app --key=final_path) - #================================================= # CHECK VERSION #================================================= @@ -71,7 +70,11 @@ then ynh_script_progression --message="Upgrading source files..." --weight=1 # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$final_path" + git clone git://erdgeist.org/opentracker "$final_path" --quiet + + pushd "$final_path" || ynh_die + ynh_exec_warn_less make + popd || ynh_die fi #================================================= From ec1906aab12694c21e7146c9388bd5be4129ffb3 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Fri, 25 Dec 2020 12:47:05 +0100 Subject: [PATCH 09/22] Update install --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 8d3fefa..4eb16b2 100644 --- a/scripts/install +++ b/scripts/install @@ -35,7 +35,7 @@ app=$YNH_APP_INSTANCE_NAME #================================================= ynh_script_progression --message="Validating installation parameters..." --weight=1 -final_path=/opt/$app +final_path=/home/admin/$app test ! -e "$final_path" || ynh_die "This path already contains a folder" # Register (book) web path From 9ec6fc045637d142e40c8b4a9f19b4045c5629f1 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Fri, 25 Dec 2020 14:39:16 +0100 Subject: [PATCH 10/22] set permissions --- README.md | 4 ++++ check_process | 2 +- conf/systemd.service | 6 +++--- scripts/install | 4 ++-- scripts/remove | 2 +- scripts/restore | 2 +- scripts/upgrade | 2 +- 7 files changed, 13 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 3445154..2a2362f 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,10 @@ OpenTracker is a open and free bittorrent tracker project. It aims for minimal r `udp://mydomain.com:6969` +by default the tracker will run on 6969 port on both UDP and TCP. + +visit `http://serverIP:6969/stats` to view the tracker stats. + ## Documentation * Official documentation: http://erdgeist.org/arts/software/opentracker/index/#overview diff --git a/check_process b/check_process index c11e66f..ed27fe5 100644 --- a/check_process +++ b/check_process @@ -6,7 +6,7 @@ ;; Test complet ; Manifest domain="domain.tld" (DOMAIN) - path="/" (PATH) + path="/path" (PATH) is_public=1 (PUBLIC|public=1|private=0) port="9980" (PORT) ; Checks diff --git a/conf/systemd.service b/conf/systemd.service index 5648dd2..f445039 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -1,10 +1,10 @@ [Unit] -Description=opentracker +Description=OpenTracker After=network.target [Service] -User=admin -Group=users +User=__APP__ +Group=__APP__ Type=simple UMask=000 WorkingDirectory=__FINALPATH__ diff --git a/scripts/install b/scripts/install index 4eb16b2..d3a0084 100644 --- a/scripts/install +++ b/scripts/install @@ -35,7 +35,7 @@ app=$YNH_APP_INSTANCE_NAME #================================================= ynh_script_progression --message="Validating installation parameters..." --weight=1 -final_path=/home/admin/$app +final_path=/opt/$app test ! -e "$final_path" || ynh_die "This path already contains a folder" # Register (book) web path @@ -113,7 +113,7 @@ ynh_add_systemd_config #================================================= # Set permissions to app files -chown -R admin:1007 $final_path +chown -R $app: $final_path chmod +x $final_path/opentracker #================================================= diff --git a/scripts/remove b/scripts/remove index 3e706bb..5e2cfe6 100644 --- a/scripts/remove +++ b/scripts/remove @@ -26,7 +26,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) # REMOVE SERVICE INTEGRATION IN YUNOHOST #================================================= -# Remove the service from the list of services known by Yunohost (added from `yunohost service add`) +# 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 ynh_script_progression --message="Removing $app service integration..." --weight=1 diff --git a/scripts/restore b/scripts/restore index 7147947..7356d25 100644 --- a/scripts/restore +++ b/scripts/restore @@ -68,7 +68,7 @@ ynh_system_user_create --username=$app #================================================= # Restore permissions on app files -chown -R root: $final_path +chown -R $app: $final_path #================================================= # SPECIFIC RESTORATION diff --git a/scripts/upgrade b/scripts/upgrade index 9197ad0..b8e2cd8 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -115,7 +115,7 @@ ynh_add_systemd_config #================================================= # Set permissions on app files -chown -R root: $final_path +chown -R $app: $final_path #================================================= # INTEGRATE SERVICE IN YUNOHOST From d1fc216142cf06a6d2d1feaa5653baac5797549e Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 27 Jan 2021 18:33:31 +0100 Subject: [PATCH 11/22] Fix --- README.md | 4 +-- README_fr.md | 71 ++++++++++++++++++++++++++++++++++++++++++++ check_process | 13 ++++---- conf/systemd.service | 2 +- manifest.json | 21 +------------ scripts/backup | 6 ---- scripts/install | 45 ++++------------------------ scripts/remove | 8 ----- scripts/restore | 25 +++------------- scripts/upgrade | 39 ++++-------------------- 10 files changed, 95 insertions(+), 139 deletions(-) create mode 100644 README_fr.md diff --git a/README.md b/README.md index 2a2362f..bbdb84d 100644 --- a/README.md +++ b/README.md @@ -34,8 +34,8 @@ visit `http://serverIP:6969/stats` to view the tracker stats. #### Multi-user support -Are LDAP and HTTP auth supported? -Can the app be used by multiple users? + * Are LDAP and HTTP auth supported? + * Can the app be used by multiple users? #### Supported architectures diff --git a/README_fr.md b/README_fr.md new file mode 100644 index 0000000..be515ff --- /dev/null +++ b/README_fr.md @@ -0,0 +1,71 @@ +# OpenTracker pour YunoHost + +[![Integration level](https://dash.yunohost.org/integration/opentracker.svg)](https://dash.yunohost.org/appci/app/opentracker) ![](https://ci-apps.yunohost.org/ci/badges/opentracker.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/opentracker.maintain.svg) +[![Installer OpenTracker avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=opentracker) + +*[Read this readme in english.](./README.md)* + +> *Ce package vous permet d'installer OpenTracker rapidement et simplement sur un serveur YunoHost. +Si vous n'avez pas YunoHost, consultez [le guide](https://yunohost.org/#/install) pour apprendre comment l'installer.* + +## Vue d'ensemble +OpenTracker is a open and free bittorrent tracker project. It aims for minimal resource usage and is intended to run at your wlan router. Currently it is deployed as an open and free tracker instance. Read our free and open tracker blog and announce your torrents there (but do not hesitate to setup your own free trackers!). + +**Version incluse :** 1.0 + +## Screenshots + +![](Link to a screenshot of this app.) + +## Configuration + +`udp://mydomain.com:6969` + +by default the tracker will run on 6969 port on both UDP and TCP. + +visit `http://serverIP:6969/stats` to view the tracker stats. + +## Documentation + + * Documentation officielle : http://erdgeist.org/arts/software/opentracker/index/#overview + * Documentation YunoHost : Si une documentation spécifique est nécessaire, n'hésitez pas à contribuer. + +## Caractéristiques spécifiques YunoHost + +#### Support multi-utilisateur + +* L'authentification LDAP et HTTP est-elle prise en charge ? +* L'application peut-elle être utilisée par plusieurs utilisateurs ? + +#### Architectures supportées + +* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/opentracker%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/opentracker/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/opentracker%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/opentracker/) + +## Limitations + +* Limitations connues. + +## Informations additionnelles + +* Autres informations que vous souhaitez ajouter sur cette application. + +## Liens + + * Signaler un bug : https://github.com/YunoHost-Apps/opentracker_ynh/issues + * Site de l'application : http://erdgeist.org/arts/software/opentracker/ + * Dépôt de l'application principale : http://erdgeist.org/gitweb/opentracker/ + * Site web YunoHost : https://yunohost.org/ + +--- + +## Informations pour les développeurs + +Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/opentracker_ynh/tree/testing). + +To try the testing branch, please proceed like that. +``` +sudo yunohost app install https://github.com/YunoHost-Apps/opentracker_ynh/tree/testing --debug +or +sudo yunohost app upgrade opentracker -u https://github.com/YunoHost-Apps/opentracker_ynh/tree/testing --debug +``` diff --git a/check_process b/check_process index ed27fe5..caffa1b 100644 --- a/check_process +++ b/check_process @@ -6,16 +6,13 @@ ;; Test complet ; Manifest domain="domain.tld" (DOMAIN) - path="/path" (PATH) - is_public=1 (PUBLIC|public=1|private=0) - port="9980" (PORT) ; Checks pkg_linter=1 - setup_sub_dir=1 - setup_root=1 - setup_nourl=0 - setup_private=1 - setup_public=1 + setup_sub_dir=0 + setup_root=0 + setup_nourl=1 + setup_private=0 + setup_public=0 upgrade=1 backup_restore=1 multi_instance=0 diff --git a/conf/systemd.service b/conf/systemd.service index f445039..59ff1b9 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -1,5 +1,5 @@ [Unit] -Description=OpenTracker +Description=OpenTracker: Bittorrent tracker After=network.target [Service] diff --git a/manifest.json b/manifest.json index 1e52281..9d9c3d9 100644 --- a/manifest.json +++ b/manifest.json @@ -14,7 +14,7 @@ "email": "liberodark@gmail.com" }, "requirements": { - "yunohost": ">= 3.8.1" + "yunohost": ">= 4.0.1" }, "multi_instance": false, "services": [ @@ -29,25 +29,6 @@ "fr": "Choisissez un nom de domaine pour OpenTracker" }, "example": "example.com" - }, - { - "name": "path", - "type": "path", - "ask": { - "en": "Choose a path for OpenTracker", - "fr": "Choisissez un chemin pour OpenTracker" - }, - "example": "/opentracker", - "default": "/opentracker" - }, - { - "name": "is_public", - "type": "boolean", - "ask": { - "en": "Is it a public site?", - "fr": "Est-ce un site public ?" - }, - "default": true } ] } diff --git a/scripts/backup b/scripts/backup index ed9df11..fe2aaa9 100644 --- a/scripts/backup +++ b/scripts/backup @@ -41,12 +41,6 @@ ynh_print_info --message="Declaring files to be backed up..." ynh_backup --src_path="$final_path" -#================================================= -# BACKUP THE NGINX CONFIGURATION -#================================================= - -ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" - #================================================= # BACKUP SYSTEMD #================================================= diff --git a/scripts/install b/scripts/install index d3a0084..9901e26 100644 --- a/scripts/install +++ b/scripts/install @@ -25,9 +25,6 @@ ynh_abort_if_errors # Retrieve arguments domain=$YNH_APP_ARG_DOMAIN -path_url=$YNH_APP_ARG_PATH -is_public=$YNH_APP_ARG_IS_PUBLIC - app=$YNH_APP_INSTANCE_NAME #================================================= @@ -35,25 +32,20 @@ app=$YNH_APP_INSTANCE_NAME #================================================= ynh_script_progression --message="Validating installation parameters..." --weight=1 -final_path=/opt/$app +final_path=/opt/yunohost/$app test ! -e "$final_path" || ynh_die "This path already contains a folder" -# Register (book) web path -ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url - #================================================= # 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=path --value=$path_url -ynh_app_setting_set --app=$app --key=is_public --value=$is_public #================================================= # FIND AND OPEN A PORT #================================================= -ynh_script_progression --message="Configuring firewall..." --weight=1 +ynh_script_progression --message="Finding an available port..." --weight=1 # Find a free port port=$(ynh_find_port --port=6969) @@ -75,21 +67,12 @@ ynh_install_app_dependencies $pkg_dependencies ynh_script_progression --message="Installing OpenTracker..." --weight=5 ynh_app_setting_set --app=$app --key=final_path --value=$final_path - git clone git://erdgeist.org/opentracker "$final_path" --quiet pushd "$final_path" || ynh_die ynh_exec_warn_less make popd || ynh_die -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Configuring NGINX web server..." --weight=10 - -# Create a dedicated NGINX config -ynh_add_nginx_config - #================================================= # CREATE DEDICATED USER #================================================= @@ -114,14 +97,14 @@ ynh_add_systemd_config # Set permissions to app files chown -R $app: $final_path -chmod +x $final_path/opentracker +chmod +x $final_path/$app #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log" +yunohost service add $app --description="Bittorrent tracker" --log="/var/log/$app/$app.log" --needs_exposed_ports "$port" #================================================= # START SYSTEMD SERVICE @@ -129,25 +112,7 @@ yunohost service add $app --description="A short description of the app" --log=" 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" #--needs_exposed_ports "$port" - -#================================================= -# SETUP SSOWAT -#================================================= -ynh_script_progression --message="Configuring SSOwat..." --weight=1 - -# Make app public if necessary or protect it -if [ $is_public -eq 1 ] -then - ynh_permission_update --permission "main" --add "visitors" -fi - -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=2 - -ynh_systemd_action --service_name=nginx --action=reload +ynh_systemd_action --service_name=$app --action=start --log_path="systemd" #================================================= # END OF SCRIPT diff --git a/scripts/remove b/scripts/remove index 5e2cfe6..8014069 100644 --- a/scripts/remove +++ b/scripts/remove @@ -57,14 +57,6 @@ ynh_script_progression --message="Removing app main directory..." --weight=1 # Remove the app directory securely ynh_secure_remove --file="$final_path" -#================================================= -# REMOVE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1 - -# Remove the dedicated NGINX config -ynh_remove_nginx_config - #================================================= # CLOSE A PORT #================================================= diff --git a/scripts/restore b/scripts/restore index 7356d25..0d0a541 100644 --- a/scripts/restore +++ b/scripts/restore @@ -27,7 +27,6 @@ ynh_script_progression --message="Loading installation settings..." --weight=1 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) #================================================= @@ -35,19 +34,11 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= ynh_script_progression --message="Validating restoration parameters..." --weight=1 -ynh_webpath_available --domain=$domain --path_url=$path_url \ - || ynh_die --message="Path not available: ${domain}${path_url}" +ynh_webpath_available --domain=$domain \ + || ynh_die --message="Path not available: $domain" test ! -d $final_path \ || ynh_die --message="There is already a directory: $final_path " -#================================================= -# STANDARD RESTORATION STEPS -#================================================= -# RESTORE THE NGINX CONFIGURATION -#================================================= - -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" - #================================================= # RESTORE THE APP MAIN DIR #================================================= @@ -69,6 +60,7 @@ ynh_system_user_create --username=$app # Restore permissions on app files chown -R $app: $final_path +chmod +x $final_path/$app #================================================= # SPECIFIC RESTORATION @@ -93,7 +85,7 @@ systemctl enable $app.service --quiet #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=2 -yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log" +yunohost service add $app --description="Bittorrent tracker" --log="/var/log/$app/$app.log" --needs_exposed_ports "$port" #================================================= # START SYSTEMD SERVICE @@ -102,15 +94,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" -#================================================= -# GENERIC FINALIZATION -#================================================= -# RELOAD NGINX AND PHP-FPM -#================================================= -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/upgrade b/scripts/upgrade index b8e2cd8..8f30712 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -17,8 +17,6 @@ ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) -path_url=$(ynh_app_setting_get --app=$app --key=path) -is_public=$(ynh_app_setting_get --app=$app --key=is_public) final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= @@ -27,17 +25,6 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) upgrade_type=$(ynh_check_app_version_changed) -#================================================= -# ENSURE DOWNWARD COMPATIBILITY -#================================================= -ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 - -# If final_path doesn't exist, create it -#if [ -z "$final_path" ]; then -# final_path=/var/www/$app -# ynh_app_setting_set --app=$app --key=final_path --value=$final_path -#fi - #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -59,7 +46,7 @@ ynh_abort_if_errors #================================================= ynh_script_progression --message="Stopping a systemd service..." --weight=5 -ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name=$app --action=stop --log_path="/var/log/$app/$app.log" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -72,19 +59,11 @@ then # Download, check integrity, uncompress and patch the source from app.src git clone git://erdgeist.org/opentracker "$final_path" --quiet - pushd "$final_path" || ynh_die + pushd $final_path ynh_exec_warn_less make - popd || ynh_die + popd fi -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=3 - -# Create a dedicated NGINX config -ynh_add_nginx_config - #================================================= # UPGRADE DEPENDENCIES #================================================= @@ -116,27 +95,21 @@ ynh_add_systemd_config # Set permissions on app files chown -R $app: $final_path +chmod +x $final_path/$app #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log" +yunohost service add $app --description="Bittorrent tracker" --log="/var/log/$app/$app.log" --needs_exposed_ports "$port" #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=2 -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 +ynh_systemd_action --service_name=$app --action=start --log_path="/var/log/$app/$app.log" #================================================= # END OF SCRIPT From fd74914530589f239bae6b06bf2b0b79c2c71dad Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 27 Jan 2021 18:40:35 +0100 Subject: [PATCH 12/22] Fix --- README.md | 4 ++-- README_fr.md | 2 +- manifest.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index bbdb84d..79dcd55 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.* ## Overview -OpenTracker is a open and free bittorrent tracker project. It aims for minimal resource usage and is intended to run at your wlan router. Currently it is deployed as an open and free tracker instance. Read our free and open tracker blog and announce your torrents there (but do not hesitate to setup your own free trackers!). +OpenTracker is a open and free bittorrent tracker project. It aims for minimal resource usage. **Shipped version:** 1.0 @@ -23,7 +23,7 @@ OpenTracker is a open and free bittorrent tracker project. It aims for minimal r by default the tracker will run on 6969 port on both UDP and TCP. -visit `http://serverIP:6969/stats` to view the tracker stats. +visit `https://serverIP:6969/stats` to view the tracker stats. ## Documentation diff --git a/README_fr.md b/README_fr.md index be515ff..fd14675 100644 --- a/README_fr.md +++ b/README_fr.md @@ -9,7 +9,7 @@ Si vous n'avez pas YunoHost, consultez [le guide](https://yunohost.org/#/install) pour apprendre comment l'installer.* ## Vue d'ensemble -OpenTracker is a open and free bittorrent tracker project. It aims for minimal resource usage and is intended to run at your wlan router. Currently it is deployed as an open and free tracker instance. Read our free and open tracker blog and announce your torrents there (but do not hesitate to setup your own free trackers!). +OpenTracker est un projet de tracker bittorrent ouvert et gratuit. Il vise une utilisation minimale des ressources. **Version incluse :** 1.0 diff --git a/manifest.json b/manifest.json index 9d9c3d9..29abc13 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Bittorrent tracker", "fr": "Tracker Bittorrent" }, - "version": "2019", + "version": "1.0~ynh1", "url": "http://erdgeist.org/arts/software/opentracker/", "license": "Beerware", "maintainer": { From 973a4062f3dcec950477e66dbd282d68185ef3fd Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 27 Jan 2021 18:56:02 +0100 Subject: [PATCH 13/22] Fix --- manifest.json | 10 +--------- scripts/install | 8 ++++---- scripts/remove | 2 +- scripts/restore | 14 +++++++------- scripts/upgrade | 2 +- 5 files changed, 14 insertions(+), 22 deletions(-) diff --git a/manifest.json b/manifest.json index 29abc13..0615403 100644 --- a/manifest.json +++ b/manifest.json @@ -21,15 +21,7 @@ "nginx" ], "arguments": { - "install": [{ - "name": "domain", - "type": "domain", - "ask": { - "en": "Choose a domain name for OpenTracker", - "fr": "Choisissez un nom de domaine pour OpenTracker" - }, - "example": "example.com" - } + "install": [ ] } } diff --git a/scripts/install b/scripts/install index 9901e26..dd88004 100644 --- a/scripts/install +++ b/scripts/install @@ -24,7 +24,7 @@ ynh_abort_if_errors #================================================= # Retrieve arguments -domain=$YNH_APP_ARG_DOMAIN +#domain=$YNH_APP_ARG_DOMAIN app=$YNH_APP_INSTANCE_NAME #================================================= @@ -40,7 +40,7 @@ test ! -e "$final_path" || ynh_die "This path already contains a folder" #================================================= 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=domain --value=$domain #================================================= # FIND AND OPEN A PORT @@ -69,9 +69,9 @@ ynh_script_progression --message="Installing OpenTracker..." --weight=5 ynh_app_setting_set --app=$app --key=final_path --value=$final_path git clone git://erdgeist.org/opentracker "$final_path" --quiet -pushd "$final_path" || ynh_die +pushd $final_path ynh_exec_warn_less make - popd || ynh_die + popd #================================================= # CREATE DEDICATED USER diff --git a/scripts/remove b/scripts/remove index 8014069..11f4b5c 100644 --- a/scripts/remove +++ b/scripts/remove @@ -16,7 +16,7 @@ ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get --app=$app --key=domain) +#domain=$(ynh_app_setting_get --app=$app --key=domain) port=$(ynh_app_setting_get --app=$app --key=port) final_path=$(ynh_app_setting_get --app=$app --key=final_path) diff --git a/scripts/restore b/scripts/restore index 0d0a541..80b7058 100644 --- a/scripts/restore +++ b/scripts/restore @@ -26,18 +26,18 @@ ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get --app=$app --key=domain) +#domain=$(ynh_app_setting_get --app=$app --key=domain) final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= -ynh_script_progression --message="Validating restoration parameters..." --weight=1 +# ynh_script_progression --message="Validating restoration parameters..." --weight=1 -ynh_webpath_available --domain=$domain \ - || ynh_die --message="Path not available: $domain" -test ! -d $final_path \ - || ynh_die --message="There is already a directory: $final_path " +# ynh_webpath_available --domain=$domain \ +# || ynh_die --message="Path not available: $domain" +# test ! -d $final_path \ +# || ynh_die --message="There is already a directory: $final_path " #================================================= # RESTORE THE APP MAIN DIR @@ -92,7 +92,7 @@ yunohost service add $app --description="Bittorrent tracker" --log="/var/log/$ap #================================================= 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" +ynh_systemd_action --service_name=$app --action=start --log_path="/var/log/$app/$app.log" #================================================= # END OF SCRIPT diff --git a/scripts/upgrade b/scripts/upgrade index 8f30712..faae3d9 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -16,7 +16,7 @@ ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get --app=$app --key=domain) +#domain=$(ynh_app_setting_get --app=$app --key=domain) final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= From f6f2ad68e6bc260b4178daaaac600a4d3a79272e Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 27 Jan 2021 19:03:16 +0100 Subject: [PATCH 14/22] Update upgrade --- scripts/upgrade | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index faae3d9..b4352bd 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -16,7 +16,6 @@ ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME -#domain=$(ynh_app_setting_get --app=$app --key=domain) final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= @@ -57,7 +56,7 @@ then ynh_script_progression --message="Upgrading source files..." --weight=1 # Download, check integrity, uncompress and patch the source from app.src - git clone git://erdgeist.org/opentracker "$final_path" --quiet + git fetch git://erdgeist.org/opentracker "$final_path" --quiet pushd $final_path ynh_exec_warn_less make From 7fd1daf66f595d703519cd9c8d17025670c36fde Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 27 Jan 2021 19:08:34 +0100 Subject: [PATCH 15/22] fix --- scripts/backup | 2 +- scripts/restore | 13 +------------ 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/scripts/backup b/scripts/backup index fe2aaa9..cc98370 100644 --- a/scripts/backup +++ b/scripts/backup @@ -28,7 +28,7 @@ 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) +port=$(ynh_app_setting_get --app=$app --key=port) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP diff --git a/scripts/restore b/scripts/restore index 80b7058..ba754b1 100644 --- a/scripts/restore +++ b/scripts/restore @@ -25,20 +25,9 @@ ynh_abort_if_errors ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME - -#domain=$(ynh_app_setting_get --app=$app --key=domain) +port=$(ynh_app_setting_get --app=$app --key=port) final_path=$(ynh_app_setting_get --app=$app --key=final_path) -#================================================= -# CHECK IF THE APP CAN BE RESTORED -#================================================= -# ynh_script_progression --message="Validating restoration parameters..." --weight=1 - -# ynh_webpath_available --domain=$domain \ -# || ynh_die --message="Path not available: $domain" -# test ! -d $final_path \ -# || ynh_die --message="There is already a directory: $final_path " - #================================================= # RESTORE THE APP MAIN DIR #================================================= From 288afd91d7977759b590c8e276fdfe957d50a50f Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 27 Jan 2021 19:11:01 +0100 Subject: [PATCH 16/22] Update upgrade --- scripts/upgrade | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/upgrade b/scripts/upgrade index b4352bd..8650f78 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -17,6 +17,7 @@ ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME final_path=$(ynh_app_setting_get --app=$app --key=final_path) +port=$(ynh_app_setting_get --app=$app --key=port) #================================================= # CHECK VERSION From d9cefd7ac486e6cf38a244e0d1f674e1005d43a3 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 27 Jan 2021 19:12:27 +0100 Subject: [PATCH 17/22] Add port --- 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 dd88004..708f3cc 100644 --- a/scripts/install +++ b/scripts/install @@ -104,7 +104,7 @@ chmod +x $final_path/$app #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -yunohost service add $app --description="Bittorrent tracker" --log="/var/log/$app/$app.log" --needs_exposed_ports "$port" +yunohost service add $app --description="Bittorrent tracker" --log=systemd --needs_exposed_ports $port #================================================= # START SYSTEMD SERVICE diff --git a/scripts/restore b/scripts/restore index ba754b1..b989718 100644 --- a/scripts/restore +++ b/scripts/restore @@ -74,7 +74,7 @@ systemctl enable $app.service --quiet #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=2 -yunohost service add $app --description="Bittorrent tracker" --log="/var/log/$app/$app.log" --needs_exposed_ports "$port" +yunohost service add $app --description="Bittorrent tracker" --log=systemd --needs_exposed_ports $port #================================================= # START SYSTEMD SERVICE diff --git a/scripts/upgrade b/scripts/upgrade index 8650f78..fc06068 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -102,7 +102,7 @@ chmod +x $final_path/$app #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -yunohost service add $app --description="Bittorrent tracker" --log="/var/log/$app/$app.log" --needs_exposed_ports "$port" +yunohost service add $app --description="Bittorrent tracker" --log=systemd --needs_exposed_ports $port #================================================= # START SYSTEMD SERVICE From 0fc490e1453edcac090b968c0ddaa46bb7dda73a Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 27 Jan 2021 22:16:35 +0100 Subject: [PATCH 18/22] Update install --- scripts/install | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 708f3cc..f45c433 100644 --- a/scripts/install +++ b/scripts/install @@ -68,7 +68,8 @@ ynh_script_progression --message="Installing OpenTracker..." --weight=5 ynh_app_setting_set --app=$app --key=final_path --value=$final_path git clone git://erdgeist.org/opentracker "$final_path" --quiet - +cp ../conf/Makefile $final_path/Makefile +cp ../conf/opentracker.conf.sample $final_path/opentracker.conf pushd $final_path ynh_exec_warn_less make popd From b537b22d5e0dbb40590dd10756a5b9085a881df5 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 27 Jan 2021 22:18:32 +0100 Subject: [PATCH 19/22] Delete nginx.conf --- conf/nginx.conf | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 conf/nginx.conf diff --git a/conf/nginx.conf b/conf/nginx.conf deleted file mode 100644 index f5077b8..0000000 --- a/conf/nginx.conf +++ /dev/null @@ -1,14 +0,0 @@ -location ^~ __PATH__/ { - - proxy_pass http://127.0.0.1:__PORT__; - proxy_redirect off; - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-Proto $scheme; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Host $server_name; - - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "upgrade"; -} \ No newline at end of file From fa9e27003df4f215c6f7ee3fc90410f6dd9055c2 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 27 Jan 2021 22:29:03 +0100 Subject: [PATCH 20/22] Update upgrade --- scripts/upgrade | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index fc06068..1caca11 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -55,10 +55,11 @@ ynh_systemd_action --service_name=$app --action=stop --log_path="/var/log/$app/$ if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_script_progression --message="Upgrading source files..." --weight=1 - + ynh_secure_remove --file="$final_path" # Download, check integrity, uncompress and patch the source from app.src - git fetch git://erdgeist.org/opentracker "$final_path" --quiet - + git clone git://erdgeist.org/opentracker "$final_path" --quiet + cp ../conf/Makefile $final_path/Makefile + cp ../conf/opentracker.conf.sample $final_path/opentracker.conf pushd $final_path ynh_exec_warn_less make popd From 2503b330035729426b87cd564fe6ef15cdcfecce Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 27 Jan 2021 23:01:09 +0100 Subject: [PATCH 21/22] Fix --- README.md | 2 +- README_fr.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 79dcd55..ac6cdcb 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ OpenTracker is a open and free bittorrent tracker project. It aims for minimal r ## Configuration -`udp://mydomain.com:6969` +`udp://serverIP:6969` by default the tracker will run on 6969 port on both UDP and TCP. diff --git a/README_fr.md b/README_fr.md index fd14675..6008924 100644 --- a/README_fr.md +++ b/README_fr.md @@ -19,7 +19,7 @@ OpenTracker est un projet de tracker bittorrent ouvert et gratuit. Il vise une u ## Configuration -`udp://mydomain.com:6969` +`udp://serverIP:6969` by default the tracker will run on 6969 port on both UDP and TCP. From 16bf1deb4d7ef3a38e48ecb29747d8b613a5c5e8 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 27 Jan 2021 23:26:05 +0100 Subject: [PATCH 22/22] Fix --- README.md | 6 +++--- README_fr.md | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index ac6cdcb..63d0501 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ OpenTracker is a open and free bittorrent tracker project. It aims for minimal r by default the tracker will run on 6969 port on both UDP and TCP. -visit `https://serverIP:6969/stats` to view the tracker stats. +visit `http://serverIP:6969/stats` to view the tracker stats. ## Documentation @@ -34,8 +34,8 @@ visit `https://serverIP:6969/stats` to view the tracker stats. #### Multi-user support - * Are LDAP and HTTP auth supported? - * Can the app be used by multiple users? + * Are LDAP and HTTP auth supported? **NO** + * Can the app be used by multiple users? **NO** #### Supported architectures diff --git a/README_fr.md b/README_fr.md index 6008924..8e12757 100644 --- a/README_fr.md +++ b/README_fr.md @@ -34,8 +34,8 @@ visit `http://serverIP:6969/stats` to view the tracker stats. #### Support multi-utilisateur -* L'authentification LDAP et HTTP est-elle prise en charge ? -* L'application peut-elle être utilisée par plusieurs utilisateurs ? +* L'authentification LDAP et HTTP est-elle prise en charge ? **Non** +* L'application peut-elle être utilisée par plusieurs utilisateurs ? **Non** #### Architectures supportées