mirror of
https://github.com/YunoHost-Apps/opentracker_ynh.git
synced 2024-09-03 19:46:34 +02:00
commit
54b3e3a7e6
15 changed files with 643 additions and 468 deletions
75
README.md
75
README.md
|
@ -1,26 +1,71 @@
|
||||||
# OpenTracker app for YunoHost
|
# OpenTracker for YunoHost
|
||||||
OpenTracker Server
|
|
||||||
|
|
||||||
**Shipped version:** 2019
|
[](https://dash.yunohost.org/appci/app/opentracker)  
|
||||||
|
[](https://install-app.yunohost.org/?app=opentracker)
|
||||||
|
|
||||||
- [Yunohost project](https://yunohost.org)
|
*[Lire ce readme en français.](./README_fr.md)*
|
||||||
- [OpenTracker website](http://erdgeist.org/arts/software/opentracker/)
|
|
||||||
|
|
||||||

|
> *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.
|
||||||
|
|
||||||
[](https://install-app.yunohost.org/?app=opentracker)
|
**Shipped version:** 1.0
|
||||||
|
|
||||||
|
## Screenshots
|
||||||
|
|
||||||
### Installing guide
|

|
||||||
|
|
||||||
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://serverIP:6969`
|
||||||
|
|
||||||
udp://mydomain.com:6969
|
|
||||||
|
|
||||||
|
by default the tracker will run on 6969 port on both UDP and TCP.
|
||||||
### Upgrade this package:
|
|
||||||
|
|
||||||
$ sudo yunohost app upgrade opentracker -u https://github.com/YunoHost-Apps/opentracker_ynh
|
visit `http://serverIP:6969/stats` to view the tracker stats.
|
||||||
|
|
||||||
|
## Documentation
|
||||||
|
|
||||||
|
* 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? **NO**
|
||||||
|
* Can the app be used by multiple users? **NO**
|
||||||
|
|
||||||
|
#### Supported architectures
|
||||||
|
|
||||||
|
* x86-64 - [](https://ci-apps.yunohost.org/ci/apps/opentracker/)
|
||||||
|
* ARMv8-A - [](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
|
||||||
|
```
|
||||||
|
|
71
README_fr.md
Normal file
71
README_fr.md
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
# OpenTracker pour YunoHost
|
||||||
|
|
||||||
|
[](https://dash.yunohost.org/appci/app/opentracker)  
|
||||||
|
[](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 est un projet de tracker bittorrent ouvert et gratuit. Il vise une utilisation minimale des ressources.
|
||||||
|
|
||||||
|
**Version incluse :** 1.0
|
||||||
|
|
||||||
|
## Screenshots
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
`udp://serverIP: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 ? **Non**
|
||||||
|
* L'application peut-elle être utilisée par plusieurs utilisateurs ? **Non**
|
||||||
|
|
||||||
|
#### Architectures supportées
|
||||||
|
|
||||||
|
* x86-64 - [](https://ci-apps.yunohost.org/ci/apps/opentracker/)
|
||||||
|
* ARMv8-A - [](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
|
||||||
|
```
|
|
@ -6,37 +6,18 @@
|
||||||
;; Test complet
|
;; Test complet
|
||||||
; Manifest
|
; Manifest
|
||||||
domain="domain.tld" (DOMAIN)
|
domain="domain.tld" (DOMAIN)
|
||||||
path="/" (PATH)
|
|
||||||
is_public=1 (PUBLIC|public=1|private=0)
|
|
||||||
# password="pass"
|
|
||||||
# nextclouddomain="domain.tld"
|
|
||||||
port="9980" (PORT)
|
|
||||||
; Checks
|
; Checks
|
||||||
pkg_linter=1
|
pkg_linter=1
|
||||||
setup_sub_dir=0
|
setup_sub_dir=0
|
||||||
setup_root=1
|
setup_root=0
|
||||||
setup_nourl=0
|
setup_nourl=1
|
||||||
setup_private=0
|
setup_private=0
|
||||||
setup_public=1
|
setup_public=0
|
||||||
upgrade=1
|
upgrade=1
|
||||||
backup_restore=1
|
backup_restore=1
|
||||||
multi_instance=1
|
multi_instance=0
|
||||||
incorrect_path=1
|
|
||||||
port_already_use=0
|
port_already_use=0
|
||||||
change_url=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
|
;;; Options
|
||||||
Email=
|
Email=
|
||||||
Notification=none
|
Notification=none
|
||||||
|
|
87
conf/Makefile
Normal file
87
conf/Makefile
Normal file
|
@ -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)
|
|
@ -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
|
|
|
@ -1,13 +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";
|
|
||||||
}
|
|
106
conf/opentracker.conf.sample
Normal file
106
conf/opentracker.conf.sample
Normal file
|
@ -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: "<hex info hash>\n<hex info hash>\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/
|
|
@ -1,14 +1,14 @@
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=opentracker
|
Description=OpenTracker: Bittorrent tracker
|
||||||
After=network.target
|
After=network.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
WorkingDirectory=/opt/opentracker
|
User=__APP__
|
||||||
User=admin
|
Group=__APP__
|
||||||
Group=users
|
|
||||||
Type=simple
|
Type=simple
|
||||||
UMask=000
|
UMask=000
|
||||||
ExecStart=/opt/opentracker/opentracker &
|
WorkingDirectory=__FINALPATH__
|
||||||
|
ExecStart=__FINALPATH__/opentracker &
|
||||||
RestartSec=15
|
RestartSec=15
|
||||||
Restart=always
|
Restart=always
|
||||||
|
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
"id": "opentracker",
|
"id": "opentracker",
|
||||||
"packaging_format": 1,
|
"packaging_format": 1,
|
||||||
"description": {
|
"description": {
|
||||||
"en": "OpenTracker package for YunoHost.",
|
"en": "Bittorrent tracker",
|
||||||
"fr": "OpenTracker pour YunoHost."
|
"fr": "Tracker Bittorrent"
|
||||||
},
|
},
|
||||||
"version": "2019",
|
"version": "1.0~ynh1",
|
||||||
"url": "http://erdgeist.org/arts/software/opentracker/",
|
"url": "http://erdgeist.org/arts/software/opentracker/",
|
||||||
"license": "Beerware",
|
"license": "Beerware",
|
||||||
"maintainer": {
|
"maintainer": {
|
||||||
|
@ -14,45 +14,14 @@
|
||||||
"email": "liberodark@gmail.com"
|
"email": "liberodark@gmail.com"
|
||||||
},
|
},
|
||||||
"requirements": {
|
"requirements": {
|
||||||
"yunohost": ">= 2.7.2"
|
"yunohost": ">= 4.0.1"
|
||||||
},
|
},
|
||||||
"multi_instance": false,
|
"multi_instance": false,
|
||||||
"services": [
|
"services": [
|
||||||
"nginx",
|
"nginx"
|
||||||
"php5-fpm",
|
|
||||||
"mysql"
|
|
||||||
],
|
],
|
||||||
"arguments": {
|
"arguments": {
|
||||||
"install": [{
|
"install": [
|
||||||
"name": "domain",
|
|
||||||
"type": "domain",
|
|
||||||
"ask": {
|
|
||||||
"en": "Choose a domain name for OpenTracker",
|
|
||||||
"fr": "Choisissez un nom de domaine pour OpenTracker"
|
|
||||||
},
|
|
||||||
"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é"
|
|
||||||
},
|
|
||||||
"example": "/opt",
|
|
||||||
"default": "/opt"
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
"name": "is_public",
|
|
||||||
"type": "boolean",
|
|
||||||
"ask": {
|
|
||||||
"en": "Is it a public site ?",
|
|
||||||
"fr": "Est-ce un site public ?"
|
|
||||||
},
|
|
||||||
"default": "true"
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,112 +1,20 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# =============================================================================
|
#=================================================
|
||||||
# YUNOHOST 2.7 FORTHCOMING HELPERS
|
# COMMON VARIABLES
|
||||||
# =============================================================================
|
#=================================================
|
||||||
|
|
||||||
# Create a dedicated nginx config
|
# dependencies used by the app
|
||||||
#
|
pkg_dependencies="libowfat-dev zlib1g-dev make build-essential"
|
||||||
# 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"
|
|
||||||
|
|
||||||
# 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
|
# PERSONAL HELPERS
|
||||||
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"
|
|
||||||
|
|
||||||
sudo systemctl reload nginx
|
#=================================================
|
||||||
}
|
# EXPERIMENTAL HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Remove the dedicated nginx config
|
#=================================================
|
||||||
#
|
# FUTURE OFFICIAL HELPERS
|
||||||
# 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
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,33 +1,54 @@
|
||||||
#!/bin/bash
|
#!/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
|
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
source ../settings/scripts/_common.sh
|
||||||
|
|
||||||
# Source YunoHost helpers
|
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
# Backup sources & data
|
#=================================================
|
||||||
# Note: the last argument is where to save this path, see the restore script.
|
# MANAGE SCRIPT FAILURE
|
||||||
ynh_backup "/var/www/${app}" "sources"
|
#=================================================
|
||||||
|
|
||||||
### MySQL (remove if not used) ###
|
ynh_clean_setup () {
|
||||||
# If a MySQL database is used:
|
ynh_clean_check_starting
|
||||||
# # Dump the database
|
}
|
||||||
# dbname=$app
|
# Exit if an error occurs during the execution of the script
|
||||||
# dbuser=$app
|
ynh_abort_if_errors
|
||||||
# dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
|
|
||||||
# mysqldump -u "$dbuser" -p"$dbpass" --no-create-db "$dbname" > ./dump.sql
|
|
||||||
### MySQL end ###
|
|
||||||
|
|
||||||
# Copy NGINX configuration
|
#=================================================
|
||||||
domain=$(ynh_app_setting_get "$app" domain)
|
# LOAD SETTINGS
|
||||||
ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "nginx.conf"
|
#=================================================
|
||||||
|
ynh_print_info --message="Loading installation settings..."
|
||||||
|
|
||||||
### PHP (remove if not used) ###
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
# If a dedicated php-fpm process is used:
|
|
||||||
# # Copy PHP-FPM pool configuration
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
# ynh_backup "/etc/php5/fpm/pool.d/${app}.conf" "php-fpm.conf"
|
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||||
### PHP end ###
|
|
||||||
|
#=================================================
|
||||||
|
# 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 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)."
|
||||||
|
|
157
scripts/install
157
scripts/install
|
@ -14,8 +14,7 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_clean_setup () {
|
ynh_clean_setup () {
|
||||||
### Remove this function if there's nothing to clean before calling the remove script.
|
ynh_clean_check_starting
|
||||||
true
|
|
||||||
}
|
}
|
||||||
# Exit if an error occurs during the execution of the script
|
# Exit if an error occurs during the execution of the script
|
||||||
ynh_abort_if_errors
|
ynh_abort_if_errors
|
||||||
|
@ -25,125 +24,71 @@ ynh_abort_if_errors
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Retrieve arguments
|
# Retrieve arguments
|
||||||
domain=$YNH_APP_ARG_DOMAIN
|
#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
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Validating installation parameters..." --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".
|
final_path=/opt/yunohost/$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"
|
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
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STORE SETTINGS FROM MANIFEST
|
# STORE SETTINGS FROM MANIFEST
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Storing installation settings..." --weight=1
|
||||||
|
|
||||||
ynh_app_setting_set $app domain $domain
|
#ynh_app_setting_set --app=$app --key=domain --value=$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
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# FIND AND OPEN A PORT
|
# FIND AND OPEN A PORT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Finding an available port..." --weight=1
|
||||||
### 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
|
|
||||||
|
|
||||||
# Find a free port
|
# Find a free port
|
||||||
port=$(ynh_find_port 6969)
|
port=$(ynh_find_port --port=6969)
|
||||||
# Open this port
|
ynh_app_setting_set --app=$app --key=port --value=$port
|
||||||
yunohost firewall allow --no-upnp UDP $port 2>&1
|
|
||||||
ynh_app_setting_set $app port $port
|
# Open the port
|
||||||
|
ynh_exec_warn_less yunohost firewall allow Both $port
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# INSTALL DEPENDENCIES
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Installing dependencies..." --weight=2
|
||||||
|
|
||||||
|
ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info "Installing OpenTracker..."
|
ynh_script_progression --message="Installing OpenTracker..." --weight=5
|
||||||
|
|
||||||
ynh_app_setting_set $app final_path $final_path
|
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||||
# Download, check integrity, uncompress and patch the source from app.src
|
git clone git://erdgeist.org/opentracker "$final_path" --quiet
|
||||||
ynh_setup_source "$final_path"
|
cp ../conf/Makefile $final_path/Makefile
|
||||||
|
cp ../conf/opentracker.conf.sample $final_path/opentracker.conf
|
||||||
#=================================================
|
pushd $final_path
|
||||||
# SETUP SYSTEMD
|
ynh_exec_warn_less make
|
||||||
#=================================================
|
popd
|
||||||
|
|
||||||
ynh_add_systemd_config
|
|
||||||
systemctl enable $app.service
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# NGINX CONFIGURATION
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# Create a dedicated nginx config
|
|
||||||
ynh_add_nginx_config
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE DEDICATED USER
|
# CREATE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Configuring system user..." --weight=1
|
||||||
|
|
||||||
# Create a system user
|
# 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_script_progression --message="Configuring a systemd service..." --weight=2
|
||||||
#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"
|
|
||||||
|
|
||||||
|
# Create a dedicated systemd config
|
||||||
|
ynh_add_systemd_config
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
|
@ -151,25 +96,27 @@ ynh_system_user_create $app
|
||||||
# SECURE FILES AND DIRECTORIES
|
# 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
|
# Set permissions to app files
|
||||||
chown -R admin:1007 $final_path
|
chown -R $app: $final_path
|
||||||
chmod +x $final_path/opentracker
|
chmod +x $final_path/$app
|
||||||
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SSOWAT
|
# INTEGRATE SERVICE IN YUNOHOST
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
||||||
|
|
||||||
|
yunohost service add $app --description="Bittorrent tracker" --log=systemd --needs_exposed_ports $port
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# 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"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# If app is public, add url to SSOWat conf as skipped_uris
|
ynh_script_progression --message="Installation of OpenTracker completed" --last
|
||||||
if [ $is_public -eq 1 ]; then
|
|
||||||
# unprotected_uris allows SSO credentials to be passed anyway.
|
|
||||||
ynh_app_setting_set "$app" unprotected_uris "/"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Reload services
|
|
||||||
systemctl start $app
|
|
||||||
systemctl reload nginx
|
|
||||||
|
|
|
@ -12,33 +12,31 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info "Loading installation settings..."
|
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
domain=$(ynh_app_setting_get $app domain)
|
#domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
port=$(ynh_app_setting_get $app port)
|
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||||
db_name=$(ynh_app_setting_get $app db_name)
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
db_user=$db_name
|
|
||||||
final_path=$(ynh_app_setting_get $app final_path)
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD REMOVE
|
# STANDARD REMOVE
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE SERVICE FROM ADMIN PANEL
|
# REMOVE SERVICE INTEGRATION IN YUNOHOST
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Remove a service from the admin panel, added by `yunohost service add`
|
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
|
||||||
if yunohost service status $app >/dev/null 2>&1
|
if ynh_exec_warn_less yunohost service status $app >/dev/null
|
||||||
then
|
then
|
||||||
ynh_print_info "Removing $app service"
|
ynh_script_progression --message="Removing $app service integration..." --weight=1
|
||||||
yunohost service remove $app
|
yunohost service remove $app
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STOP AND REMOVE SERVICE
|
# STOP AND REMOVE SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info "Stopping and removing the systemd service"
|
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=2
|
||||||
|
|
||||||
# Remove the dedicated systemd config
|
# Remove the dedicated systemd config
|
||||||
ynh_remove_systemd_config
|
ynh_remove_systemd_config
|
||||||
|
@ -46,7 +44,7 @@ ynh_remove_systemd_config
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE DEPENDENCIES
|
# REMOVE DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info "Removing dependencies"
|
ynh_script_progression --message="Removing dependencies..." --weight=2
|
||||||
|
|
||||||
# Remove metapackage and its dependencies
|
# Remove metapackage and its dependencies
|
||||||
ynh_remove_app_dependencies
|
ynh_remove_app_dependencies
|
||||||
|
@ -54,34 +52,10 @@ ynh_remove_app_dependencies
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE APP MAIN DIR
|
# REMOVE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info "Removing app main directory"
|
ynh_script_progression --message="Removing app main directory..." --weight=1
|
||||||
|
|
||||||
# Remove the app directory securely
|
# 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"
|
|
||||||
|
|
||||||
# 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
|
# CLOSE A PORT
|
||||||
|
@ -89,37 +63,22 @@ ynh_remove_logrotate
|
||||||
|
|
||||||
if yunohost firewall list | grep -q "\- $port$"
|
if yunohost firewall list | grep -q "\- $port$"
|
||||||
then
|
then
|
||||||
ynh_print_info "Closing port $port"
|
ynh_script_progression --message="Closing port $port..." --weight=1
|
||||||
ynh_exec_warn_less yunohost firewall disallow TCP $port
|
ynh_exec_warn_less yunohost firewall disallow Both $port
|
||||||
fi
|
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
|
# GENERIC FINALIZATION
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE DEDICATED USER
|
# REMOVE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info "Removing the dedicated system user"
|
ynh_script_progression --message="Removing the dedicated system user..." --weight=2
|
||||||
|
|
||||||
# Delete a system user
|
# Delete a system user
|
||||||
ynh_system_user_delete $app
|
ynh_system_user_delete --username=$app
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_print_info "Removal of $app completed"
|
ynh_script_progression --message="Removal of $app completed" --last
|
||||||
|
|
118
scripts/restore
118
scripts/restore
|
@ -1,52 +1,90 @@
|
||||||
#!/bin/bash
|
#!/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
|
source ../settings/scripts/_common.sh
|
||||||
set -eu
|
|
||||||
|
|
||||||
# See comments in install script
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
|
||||||
|
|
||||||
# Source YunoHost helpers
|
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
# Retrieve old app settings
|
#=================================================
|
||||||
domain=$(ynh_app_setting_get "$app" domain)
|
# MANAGE SCRIPT FAILURE
|
||||||
path_url=$(ynh_app_setting_get "$app" path_url)
|
#=================================================
|
||||||
|
|
||||||
# Check domain/path availability
|
ynh_clean_setup () {
|
||||||
sudo yunohost app checkurl "${domain}${path_url}" -a "$app" \
|
ynh_clean_check_starting
|
||||||
|| ynh_die "Path not available: ${domain}${path_url}"
|
}
|
||||||
|
# Exit if an error occurs during the execution of the script
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
# Restore sources & data
|
#=================================================
|
||||||
src_path="/var/www/${app}"
|
# LOAD SETTINGS
|
||||||
sudo cp -a ./sources "$src_path"
|
#=================================================
|
||||||
|
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||||
|
|
||||||
# Restore permissions to app files
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
# you may need to make some file and/or directory writeable by www-data (nginx user)
|
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||||
sudo chown -R root: "$src_path"
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
|
|
||||||
### MySQL (remove if not used) ###
|
#=================================================
|
||||||
# If a MySQL database is used:
|
# RESTORE THE APP MAIN DIR
|
||||||
# # Create and restore the database
|
#=================================================
|
||||||
# dbname=$app
|
ynh_script_progression --message="Restoring the app main directory..." --weight=2
|
||||||
# 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 ###
|
|
||||||
|
|
||||||
# Restore NGINX configuration
|
ynh_restore_file --origin_path="$final_path"
|
||||||
sudo cp -a ./nginx.conf "/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
|
||||||
|
|
||||||
### PHP (remove if not used) ###
|
#=================================================
|
||||||
# If a dedicated php-fpm process is used:
|
# RECREATE THE DEDICATED USER
|
||||||
# # Copy PHP-FPM pool configuration and reload the service
|
#=================================================
|
||||||
# sudo cp -a ./php-fpm.conf "/etc/php5/fpm/pool.d/${app}.conf"
|
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
|
||||||
# sudo service php5-fpm reload
|
|
||||||
### PHP end ###
|
|
||||||
|
|
||||||
# Restart webserver
|
# Create the dedicated user (if not existing)
|
||||||
sudo service nginx reload
|
ynh_system_user_create --username=$app
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RESTORE USER RIGHTS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Restore permissions on app files
|
||||||
|
chown -R $app: $final_path
|
||||||
|
chmod +x $final_path/$app
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SPECIFIC RESTORATION
|
||||||
|
#=================================================
|
||||||
|
# REINSTALL DEPENDENCIES
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Reinstalling dependencies..." --weight=2
|
||||||
|
|
||||||
|
# Define and install dependencies
|
||||||
|
ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RESTORE SYSTEMD
|
||||||
|
#=================================================
|
||||||
|
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
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# INTEGRATE SERVICE IN YUNOHOST
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Integrating service in YunoHost..." --weight=2
|
||||||
|
|
||||||
|
yunohost service add $app --description="Bittorrent tracker" --log=systemd --needs_exposed_ports $port
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# START SYSTEMD SERVICE
|
||||||
|
#=================================================
|
||||||
|
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"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Restoration completed for $app" --last
|
||||||
|
|
131
scripts/upgrade
131
scripts/upgrade
|
@ -1,56 +1,119 @@
|
||||||
#!/bin/bash
|
#!/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
|
source _common.sh
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
|
||||||
final_path=/opt/yunohost/$app
|
|
||||||
|
|
||||||
# Source YunoHost helpers
|
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
# Stop emby-server service
|
#=================================================
|
||||||
systemctl stop emby-server
|
# LOAD SETTINGS
|
||||||
|
#=================================================
|
||||||
|
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
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
upgrade_type=$(ynh_check_app_version_changed)
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1
|
||||||
|
|
||||||
|
# Backup the current version of the app
|
||||||
|
ynh_backup_before_upgrade
|
||||||
|
ynh_clean_setup () {
|
||||||
|
# Restore it if the upgrade fails
|
||||||
|
ynh_restore_upgradebackup
|
||||||
|
}
|
||||||
|
# Exit if an error occurs during the execution of the script
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# STANDARD UPGRADE STEPS
|
||||||
|
#=================================================
|
||||||
|
# STOP SYSTEMD SERVICE
|
||||||
|
#=================================================
|
||||||
|
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"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_app_setting_set $app final_path $final_path
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||||
# Download, check integrity, uncompress and patch the source from app.src
|
then
|
||||||
ynh_setup_source "$final_path"
|
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
|
||||||
# INSTALL PLEX
|
git clone git://erdgeist.org/opentracker "$final_path" --quiet
|
||||||
#==============================================
|
cp ../conf/Makefile $final_path/Makefile
|
||||||
|
cp ../conf/opentracker.conf.sample $final_path/opentracker.conf
|
||||||
dpkg --install $final_path/emby-server-deb*
|
pushd $final_path
|
||||||
|
ynh_exec_warn_less make
|
||||||
|
popd
|
||||||
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# NGINX CONFIGURATION
|
# UPGRADE DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Upgrading dependencies..." --weight=2
|
||||||
|
|
||||||
# Create a dedicated nginx config
|
ynh_install_app_dependencies $pkg_dependencies
|
||||||
#ynh_add_nginx_config
|
|
||||||
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# UPGRADE CONFIG
|
# CREATE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
#cp -a ../conf/loolwsd.xml /etc/loolwsd
|
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=5
|
||||||
#ynh_replace_string "__NEXTCLOUDDOMAIN__" "$nextcloud_domain" "/etc/loolwsd/loolwsd.xml"
|
|
||||||
#ynh_replace_string "__PASSWORD__" "$password" "/etc/loolwsd/loolwsd.xml"
|
|
||||||
#systemctl restart loolwsd
|
|
||||||
|
|
||||||
|
# Create a dedicated user (if not existing)
|
||||||
|
ynh_system_user_create --username=$app
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SETUP SYSTEMD
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
|
||||||
|
|
||||||
# If app is public, add url to SSOWat conf as skipped_uris
|
# Create a dedicated systemd config
|
||||||
#if [[ $is_public -eq 1 ]]; then
|
ynh_add_systemd_config
|
||||||
# See install script
|
|
||||||
# ynh_app_setting_set "$app" unprotected_uris "/"
|
|
||||||
#fi
|
|
||||||
|
|
||||||
# Start emby-server service
|
#=================================================
|
||||||
systemctl start emby-server
|
# GENERIC FINALIZATION
|
||||||
|
#=================================================
|
||||||
|
# SECURE FILES AND DIRECTORIES
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# 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="Bittorrent tracker" --log=systemd --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"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Upgrade of $app completed" --last
|
||||||
|
|
Loading…
Add table
Reference in a new issue