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 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.
|
||||
|
||||
[![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://serverIP:6969`
|
||||
|
||||
|
||||
### Upgrade this package:
|
||||
by default the tracker will run on 6969 port on both UDP and TCP.
|
||||
|
||||
$ 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 - [![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
|
||||
```
|
||||
|
|
71
README_fr.md
Normal file
71
README_fr.md
Normal file
|
@ -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 est un projet de tracker bittorrent ouvert et gratuit. Il vise une utilisation minimale des ressources.
|
||||
|
||||
**Version incluse :** 1.0
|
||||
|
||||
## Screenshots
|
||||
|
||||
![](Link to a screenshot of this app.)
|
||||
|
||||
## 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 - [![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
|
||||
```
|
|
@ -6,37 +6,18 @@
|
|||
;; Test complet
|
||||
; Manifest
|
||||
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_root=1
|
||||
setup_nourl=0
|
||||
setup_root=0
|
||||
setup_nourl=1
|
||||
setup_private=0
|
||||
setup_public=1
|
||||
setup_public=0
|
||||
upgrade=1
|
||||
backup_restore=1
|
||||
multi_instance=1
|
||||
incorrect_path=1
|
||||
multi_instance=0
|
||||
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
|
||||
|
|
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]
|
||||
Description=opentracker
|
||||
Description=OpenTracker: Bittorrent tracker
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
WorkingDirectory=/opt/opentracker
|
||||
User=admin
|
||||
Group=users
|
||||
User=__APP__
|
||||
Group=__APP__
|
||||
Type=simple
|
||||
UMask=000
|
||||
ExecStart=/opt/opentracker/opentracker &
|
||||
WorkingDirectory=__FINALPATH__
|
||||
ExecStart=__FINALPATH__/opentracker &
|
||||
RestartSec=15
|
||||
Restart=always
|
||||
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
"id": "opentracker",
|
||||
"packaging_format": 1,
|
||||
"description": {
|
||||
"en": "OpenTracker package for YunoHost.",
|
||||
"fr": "OpenTracker pour YunoHost."
|
||||
"en": "Bittorrent tracker",
|
||||
"fr": "Tracker Bittorrent"
|
||||
},
|
||||
"version": "2019",
|
||||
"version": "1.0~ynh1",
|
||||
"url": "http://erdgeist.org/arts/software/opentracker/",
|
||||
"license": "Beerware",
|
||||
"maintainer": {
|
||||
|
@ -14,45 +14,14 @@
|
|||
"email": "liberodark@gmail.com"
|
||||
},
|
||||
"requirements": {
|
||||
"yunohost": ">= 2.7.2"
|
||||
"yunohost": ">= 4.0.1"
|
||||
},
|
||||
"multi_instance": false,
|
||||
"services": [
|
||||
"nginx",
|
||||
"php5-fpm",
|
||||
"mysql"
|
||||
"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"
|
||||
},
|
||||
|
||||
{
|
||||
"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"
|
||||
}
|
||||
"install": [
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 make build-essential"
|
||||
|
||||
# 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
|
||||
#=================================================
|
||||
|
|
|
@ -1,33 +1,54 @@
|
|||
#!/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 () {
|
||||
ynh_clean_check_starting
|
||||
}
|
||||
# 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)
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
|
||||
#=================================================
|
||||
# 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 () {
|
||||
### 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
|
||||
|
@ -25,125 +24,71 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
|
||||
# Retrieve arguments
|
||||
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, ...
|
||||
#domain=$YNH_APP_ARG_DOMAIN
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
#=================================================
|
||||
# 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".
|
||||
### 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
|
||||
final_path=/opt/yunohost/$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
|
||||
|
||||
#=================================================
|
||||
# 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 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
|
||||
|
||||
#=================================================
|
||||
# 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="Finding an available port..." --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..." --weight=2
|
||||
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
#=================================================
|
||||
# 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
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source "$final_path"
|
||||
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
#=================================================
|
||||
|
||||
ynh_add_systemd_config
|
||||
systemctl enable $app.service
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config
|
||||
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
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring system user..." --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..." --weight=2
|
||||
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
|
@ -151,25 +96,27 @@ 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
|
||||
|
||||
chown -R $app: $final_path
|
||||
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
|
||||
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
|
||||
ynh_script_progression --message="Installation of OpenTracker completed" --last
|
||||
|
|
|
@ -12,33 +12,31 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_print_info "Loading installation settings..."
|
||||
ynh_script_progression --message="Loading installation settings..." --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..." --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..." --weight=2
|
||||
|
||||
# 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..." --weight=2
|
||||
|
||||
# Remove metapackage and its dependencies
|
||||
ynh_remove_app_dependencies
|
||||
|
@ -54,34 +52,10 @@ ynh_remove_app_dependencies
|
|||
#=================================================
|
||||
# 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
|
||||
ynh_secure_remove "$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
|
||||
ynh_secure_remove --file="$final_path"
|
||||
|
||||
#=================================================
|
||||
# CLOSE A PORT
|
||||
|
@ -89,37 +63,22 @@ ynh_remove_logrotate
|
|||
|
||||
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..." --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..." --weight=2
|
||||
|
||||
# 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" --last
|
||||
|
|
118
scripts/restore
118
scripts/restore
|
@ -1,52 +1,90 @@
|
|||
#!/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
|
||||
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 () {
|
||||
ynh_clean_check_starting
|
||||
}
|
||||
# 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..." --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
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
|
||||
### 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 ###
|
||||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the app main directory..." --weight=2
|
||||
|
||||
# Restore NGINX configuration
|
||||
sudo cp -a ./nginx.conf "/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
||||
ynh_restore_file --origin_path="$final_path"
|
||||
|
||||
### 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 ###
|
||||
#=================================================
|
||||
# RECREATE THE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
|
||||
|
||||
# Restart webserver
|
||||
sudo service nginx reload
|
||||
# Create the dedicated user (if not existing)
|
||||
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
|
||||
|
||||
# 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..." --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
|
||||
#=================================================
|
||||
|
||||
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"
|
||||
|
||||
#==============================================
|
||||
# INSTALL PLEX
|
||||
#==============================================
|
||||
|
||||
dpkg --install $final_path/emby-server-deb*
|
||||
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 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
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
# UPGRADE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading dependencies..." --weight=2
|
||||
|
||||
# Create a dedicated nginx config
|
||||
#ynh_add_nginx_config
|
||||
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
#=================================================
|
||||
# UPGRADE CONFIG
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
#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="Making sure dedicated system user exists..." --weight=5
|
||||
|
||||
# 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
|
||||
#if [[ $is_public -eq 1 ]]; then
|
||||
# See install script
|
||||
# ynh_app_setting_set "$app" unprotected_uris "/"
|
||||
#fi
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config
|
||||
|
||||
# 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…
Reference in a new issue