mirror of
https://github.com/YunoHost-Apps/cops_ynh.git
synced 2024-09-03 18:25:57 +02:00
commit
1a2f90e408
23 changed files with 17434 additions and 674 deletions
48
README.md
48
README.md
|
@ -1,16 +1,50 @@
|
||||||
|
<!--
|
||||||
|
N.B.: This README was automatically generated by https://github.com/YunoHost/apps/tree/master/tools/README-generator
|
||||||
|
It shall NOT be edited by hand.
|
||||||
|
-->
|
||||||
|
|
||||||
# COPS for YunoHost
|
# COPS for YunoHost
|
||||||
|
|
||||||
[![Integration level](https://dash.yunohost.org/integration/cops.svg)](https://dash.yunohost.org/appci/app/cops) ![](https://ci-apps.yunohost.org/ci/badges/cops.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/cops.maintain.svg)
|
[![Integration level](https://dash.yunohost.org/integration/cops.svg)](https://dash.yunohost.org/appci/app/cops) ![](https://ci-apps.yunohost.org/ci/badges/cops.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/cops.maintain.svg)
|
||||||
|
[![Install COPS with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=cops)
|
||||||
|
|
||||||
* You need to indicate the true path of your calibre library and make sure COPS runs under the same user as were the files are located
|
*[Lire ce readme en français.](./README_fr.md)*
|
||||||
|
|
||||||
* Designed to work best with OwnCloud or NextCloud
|
> *This package allows you to install COPS 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.*
|
||||||
|
|
||||||
* Creates an OPDS and HTML server based on a Calibre folder stored in Owncloud or NextCloud
|
## Overview
|
||||||
|
|
||||||
Packaged version : 1.0.1
|
Calibre OPDS (and HTML) PHP Server
|
||||||
|
|
||||||
|
**Shipped version:** 1.1.3~ynh1
|
||||||
|
|
||||||
|
**Demo:** http://cops-demo.slucas.fr/index.php
|
||||||
|
|
||||||
|
## Disclaimers / important information
|
||||||
|
|
||||||
|
You need to indicate the true path of your calibre library and make sure COPS runs under the same user as were the files are located
|
||||||
|
|
||||||
|
Designed to work best with OwnCloud or NextCloud
|
||||||
|
|
||||||
|
Creates an OPDS and HTML server based on a Calibre folder stored in NextCloud
|
||||||
|
|
||||||
|
## Documentation and resources
|
||||||
|
|
||||||
|
* Official app website: https://blog.slucas.fr/projects/calibre-opds-php-server/
|
||||||
|
* Upstream app code repository: https://github.com/seblucas/cops
|
||||||
|
* YunoHost documentation for this app: https://yunohost.org/app_cops
|
||||||
* Report a bug: https://github.com/YunoHost-Apps/cops_ynh/issues
|
* Report a bug: https://github.com/YunoHost-Apps/cops_ynh/issues
|
||||||
* App website: http://blog.slucas.fr/fr/oss/calibre-opds-php-server
|
|
||||||
* Upstream app repository: https://github.com/seblucas/cops
|
## Developer info
|
||||||
* YunoHost website: https://yunohost.org/
|
|
||||||
|
Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/cops_ynh/tree/testing).
|
||||||
|
|
||||||
|
To try the testing branch, please proceed like that.
|
||||||
|
```
|
||||||
|
sudo yunohost app install https://github.com/YunoHost-Apps/cops_ynh/tree/testing --debug
|
||||||
|
or
|
||||||
|
sudo yunohost app upgrade cops -u https://github.com/YunoHost-Apps/cops_ynh/tree/testing --debug
|
||||||
|
```
|
||||||
|
|
||||||
|
**More info regarding app packaging:** https://yunohost.org/packaging_apps
|
46
README_fr.md
Normal file
46
README_fr.md
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
# COPS pour YunoHost
|
||||||
|
|
||||||
|
[![Niveau d'intégration](https://dash.yunohost.org/integration/cops.svg)](https://dash.yunohost.org/appci/app/cops) ![](https://ci-apps.yunohost.org/ci/badges/cops.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/cops.maintain.svg)
|
||||||
|
[![Installer COPS avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=cops)
|
||||||
|
|
||||||
|
*[Read this readme in english.](./README.md)*
|
||||||
|
*[Lire ce readme en français.](./README_fr.md)*
|
||||||
|
|
||||||
|
> *Ce package vous permet d'installer COPS rapidement et simplement sur un serveur YunoHost.
|
||||||
|
Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.*
|
||||||
|
|
||||||
|
## Vue d'ensemble
|
||||||
|
|
||||||
|
Calibre OPDS (et HTML) PHP Serveur
|
||||||
|
|
||||||
|
**Version incluse :** 1.1.3~ynh1
|
||||||
|
|
||||||
|
**Démo :** http://cops-demo.slucas.fr/index.php
|
||||||
|
|
||||||
|
## Avertissements / informations importantes
|
||||||
|
|
||||||
|
You need to indicate the true path of your calibre library and make sure COPS runs under the same user as were the files are located
|
||||||
|
|
||||||
|
Designed to work best with OwnCloud or NextCloud
|
||||||
|
|
||||||
|
Creates an OPDS and HTML server based on a Calibre folder stored in NextCloud
|
||||||
|
|
||||||
|
## Documentations et ressources
|
||||||
|
|
||||||
|
* Site officiel de l'app : https://blog.slucas.fr/projects/calibre-opds-php-server/
|
||||||
|
* Dépôt de code officiel de l'app : https://github.com/seblucas/cops
|
||||||
|
* Documentation YunoHost pour cette app : https://yunohost.org/app_cops
|
||||||
|
* Signaler un bug : https://github.com/YunoHost-Apps/cops_ynh/issues
|
||||||
|
|
||||||
|
## Informations pour les développeurs
|
||||||
|
|
||||||
|
Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/cops_ynh/tree/testing).
|
||||||
|
|
||||||
|
Pour essayer la branche testing, procédez comme suit.
|
||||||
|
```
|
||||||
|
sudo yunohost app install https://github.com/YunoHost-Apps/cops_ynh/tree/testing --debug
|
||||||
|
ou
|
||||||
|
sudo yunohost app upgrade cops -u https://github.com/YunoHost-Apps/cops_ynh/tree/testing --debug
|
||||||
|
```
|
||||||
|
|
||||||
|
**Plus d'infos sur le packaging d'applications :** https://yunohost.org/packaging_apps
|
|
@ -1,18 +1,10 @@
|
||||||
;; master
|
;; Test complet
|
||||||
auto_remove=1
|
|
||||||
# Commentaire ignoré
|
|
||||||
; Manifest
|
; Manifest
|
||||||
domain="$DOMAIN" (DOMAIN)
|
domain="domain.tld"
|
||||||
path="/path" (PATH)
|
path="/path"
|
||||||
|
admin="john"
|
||||||
language="fr"
|
language="fr"
|
||||||
runninguser="www-data"
|
is_public=1
|
||||||
calibre="/home/yunohost.app/owncloud/johndoe/"
|
|
||||||
is_public="Yes" (PUBLIC|public=Yes|private=No)
|
|
||||||
basicauthcreate="Yes"
|
|
||||||
basicauthname="Gutenberg"
|
|
||||||
basicauthpass="hiyjgvhfgvhgbjh"
|
|
||||||
# password="$PASSWORD" (PASSWORD)
|
|
||||||
# port="666" (PORT)
|
|
||||||
; Checks
|
; Checks
|
||||||
pkg_linter=1
|
pkg_linter=1
|
||||||
setup_sub_dir=1
|
setup_sub_dir=1
|
||||||
|
@ -21,12 +13,14 @@
|
||||||
setup_private=1
|
setup_private=1
|
||||||
setup_public=1
|
setup_public=1
|
||||||
upgrade=1
|
upgrade=1
|
||||||
|
#upgrade=1 from_commit=CommitHash
|
||||||
backup_restore=1
|
backup_restore=1
|
||||||
multi_instance=1
|
multi_instance=1
|
||||||
wrong_user=0
|
change_url=0
|
||||||
wrong_path=1
|
;;; Options
|
||||||
incorrect_path=1
|
Email=
|
||||||
corrupt_source=0
|
Notification=none
|
||||||
fail_download_source=0
|
;;; Upgrade options
|
||||||
port_already_use=0 (XXXX)
|
; commit=CommitHash
|
||||||
final_path_already_use=0
|
name=Name and date of the commit.
|
||||||
|
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666&
|
||||||
|
|
5
conf/app.src
Normal file
5
conf/app.src
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
SOURCE_URL=https://github.com/seblucas/cops/releases/download/1.1.3/cops-1.1.3.zip
|
||||||
|
SOURCE_SUM=68c9efb340ab30989cd89a19a173c45872d33ed85dd02674f8af08b7748cbc77
|
||||||
|
SOURCE_SUM_PRG=sha256sum
|
||||||
|
SOURCE_FORMAT=zip
|
||||||
|
SOURCE_IN_SUBDIR=false
|
|
@ -2,12 +2,20 @@
|
||||||
if (!isset($config))
|
if (!isset($config))
|
||||||
$config = array();
|
$config = array();
|
||||||
|
|
||||||
|
/*
|
||||||
|
***************************************************
|
||||||
|
* Please read config_default.php for all possible
|
||||||
|
* configuration items
|
||||||
|
***************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The directory containing calibre's metadata.db file, with sub-directories
|
* The directory containing calibre's metadata.db file, with sub-directories
|
||||||
* containing all the formats.
|
* containing all the formats.
|
||||||
* BEWARE : it has to end with a /
|
* BEWARE : it has to end with a /
|
||||||
*/
|
*/
|
||||||
$config['calibre_directory'] = 'CALIBRETOCHANGE/';
|
$config['calibre_directory'] = '__CALIBRE_DIR__/';
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Catalog's title
|
* Catalog's title
|
||||||
|
@ -20,15 +28,17 @@
|
||||||
* 1 : enable
|
* 1 : enable
|
||||||
* 0 : disable
|
* 0 : disable
|
||||||
*/
|
*/
|
||||||
$config['cops_use_url_rewriting'] = "0";
|
$config['cops_use_url_rewriting'] = "1";
|
||||||
|
|
||||||
$config['cops_recentbooks_limit'] = '10';
|
|
||||||
|
|
||||||
$config['default_timezone'] = "TIMEZONETOCHANGE";
|
|
||||||
|
|
||||||
$config['cops_template'] = 'default';
|
|
||||||
|
|
||||||
$config['cops_style'] = 'iphone';
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set language code to force a language (see lang/ directory for available languages).
|
||||||
|
* When empty it will auto detect the language.
|
||||||
|
*/
|
||||||
|
$config['cops_language'] = '__LANGUAGE__';
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Default timezone
|
||||||
|
* Check following link for other timezones :
|
||||||
|
* http://www.php.net/manual/en/timezones.php
|
||||||
|
*/
|
||||||
|
$config['default_timezone'] = '__TIMEZONE__';
|
||||||
|
|
|
@ -5,7 +5,7 @@ Standards-Version: 1.0.1
|
||||||
|
|
||||||
Package: cops-deps
|
Package: cops-deps
|
||||||
Version: 1.2-1
|
Version: 1.2-1
|
||||||
Depends: php5-gd, php5-sqlite, php5-json, php5-intl
|
Depends: php7.3-gd, php7.3-sqlite3, php7.3-json, php7.3-intl
|
||||||
Architecture: all
|
Architecture: all
|
||||||
Description: meta package for cops dependencies
|
Description: meta package for cops dependencies
|
||||||
COPS stands for Calibre OPDS (and HTML) Php Server.
|
COPS stands for Calibre OPDS (and HTML) Php Server.
|
||||||
|
|
16512
conf/metadata.db.empty
Normal file
16512
conf/metadata.db.empty
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,20 +1,19 @@
|
||||||
location PATHTOCHANGE {
|
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
|
||||||
alias ALIASTOCHANGE;
|
location __PATH__/ {
|
||||||
|
|
||||||
# auth_basic "Reason for being private";
|
# Path to source
|
||||||
# auth_basic_user_file /path/to/htpasswd;
|
alias __FINALPATH__/ ;
|
||||||
|
|
||||||
|
index index.php feed.php;
|
||||||
|
|
||||||
if ($scheme = http) {
|
# Common parameter to increase upload size limit in conjunction with dedicated php-fpm file
|
||||||
rewrite ^ https://$server_name$request_uri? permanent;
|
#client_max_body_size 50M;
|
||||||
}
|
|
||||||
|
|
||||||
client_max_body_size 10G;
|
|
||||||
index index.php;
|
|
||||||
try_files $uri $uri/ index.php;
|
try_files $uri $uri/ index.php;
|
||||||
location ~ [^/]\.php(/|$) {
|
location ~ [^/]\.php(/|$) {
|
||||||
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
|
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
|
||||||
fastcgi_pass unix:/var/run/php5-fpm-NAMETOCHANGE.sock;
|
fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock;
|
||||||
|
|
||||||
fastcgi_index index.php;
|
fastcgi_index index.php;
|
||||||
include fastcgi_params;
|
include fastcgi_params;
|
||||||
fastcgi_param REMOTE_USER $remote_user;
|
fastcgi_param REMOTE_USER $remote_user;
|
||||||
|
@ -22,6 +21,6 @@ location PATHTOCHANGE {
|
||||||
fastcgi_param SCRIPT_FILENAME $request_filename;
|
fastcgi_param SCRIPT_FILENAME $request_filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Include SSOWAT user panel.
|
||||||
include conf.d/yunohost_panel.conf.inc;
|
include conf.d/yunohost_panel.conf.inc;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
; Start a new pool named 'www'.
|
; Start a new pool named 'www'.
|
||||||
; the variable $pool can we used in any directive and will be replaced by the
|
; the variable $pool can be used in any directive and will be replaced by the
|
||||||
; pool name ('www' here)
|
; pool name ('www' here)
|
||||||
[NAMETOCHANGE]
|
[__NAMETOCHANGE__]
|
||||||
|
|
||||||
; Per pool prefix
|
; Per pool prefix
|
||||||
; It only applies on the following directives:
|
; It only applies on the following directives:
|
||||||
|
; - 'access.log'
|
||||||
; - 'slowlog'
|
; - 'slowlog'
|
||||||
; - 'listen' (unixsocket)
|
; - 'listen' (unixsocket)
|
||||||
; - 'chroot'
|
; - 'chroot'
|
||||||
|
@ -16,21 +17,43 @@
|
||||||
; Default Value: none
|
; Default Value: none
|
||||||
;prefix = /path/to/pools/$pool
|
;prefix = /path/to/pools/$pool
|
||||||
|
|
||||||
|
; Unix user/group of processes
|
||||||
|
; Note: The user is mandatory. If the group is not set, the default user's group
|
||||||
|
; will be used.
|
||||||
|
user = __USER__
|
||||||
|
group = __USER__
|
||||||
|
|
||||||
; The address on which to accept FastCGI requests.
|
; The address on which to accept FastCGI requests.
|
||||||
; Valid syntaxes are:
|
; Valid syntaxes are:
|
||||||
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific address on
|
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on
|
||||||
; a specific port;
|
; a specific port;
|
||||||
; 'port' - to listen on a TCP socket to all addresses on a
|
; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
|
||||||
; specific port;
|
; a specific port;
|
||||||
|
; 'port' - to listen on a TCP socket to all addresses
|
||||||
|
; (IPv6 and IPv4-mapped) on a specific port;
|
||||||
; '/path/to/unix/socket' - to listen on a unix socket.
|
; '/path/to/unix/socket' - to listen on a unix socket.
|
||||||
; Note: This value is mandatory.
|
; Note: This value is mandatory.
|
||||||
listen = /var/run/php5-fpm-NAMETOCHANGE.sock
|
listen = /var/run/php/php__PHPVERSION__-fpm-__NAMETOCHANGE__.sock
|
||||||
|
|
||||||
; Set listen(2) backlog. A value of '-1' means unlimited.
|
; Set listen(2) backlog.
|
||||||
; Default Value: 128 (-1 on FreeBSD and OpenBSD)
|
; Default Value: 511 (-1 on FreeBSD and OpenBSD)
|
||||||
;listen.backlog = -1
|
;listen.backlog = 511
|
||||||
|
|
||||||
; List of ipv4 addresses of FastCGI clients which are allowed to connect.
|
; Set permissions for unix socket, if one is used. In Linux, read/write
|
||||||
|
; permissions must be set in order to allow connections from a web server. Many
|
||||||
|
; BSD-derived systems allow connections regardless of permissions.
|
||||||
|
; Default Values: user and group are set as the running user
|
||||||
|
; mode is set to 0660
|
||||||
|
listen.owner = www-data
|
||||||
|
listen.group = www-data
|
||||||
|
;listen.mode = 0660
|
||||||
|
; When POSIX Access Control Lists are supported you can set them using
|
||||||
|
; these options, value is a comma separated list of user/group names.
|
||||||
|
; When set, listen.owner and listen.group are ignored
|
||||||
|
;listen.acl_users =
|
||||||
|
;listen.acl_groups =
|
||||||
|
|
||||||
|
; List of addresses (IPv4/IPv6) of FastCGI clients which are allowed to connect.
|
||||||
; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original
|
; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original
|
||||||
; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address
|
; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address
|
||||||
; must be separated by a comma. If this value is left blank, connections will be
|
; must be separated by a comma. If this value is left blank, connections will be
|
||||||
|
@ -38,26 +61,26 @@ listen = /var/run/php5-fpm-NAMETOCHANGE.sock
|
||||||
; Default Value: any
|
; Default Value: any
|
||||||
;listen.allowed_clients = 127.0.0.1
|
;listen.allowed_clients = 127.0.0.1
|
||||||
|
|
||||||
; Set permissions for unix socket, if one is used. In Linux, read/write
|
; Specify the nice(2) priority to apply to the pool processes (only if set)
|
||||||
; permissions must be set in order to allow connections from a web server. Many
|
; The value can vary from -19 (highest priority) to 20 (lower priority)
|
||||||
; BSD-derived systems allow connections regardless of permissions.
|
; Note: - It will only work if the FPM master process is launched as root
|
||||||
; Default Values: user and group are set as the running user
|
; - The pool processes will inherit the master process priority
|
||||||
; mode is set to 0666
|
; unless it specified otherwise
|
||||||
listen.owner = www-data
|
; Default Value: no set
|
||||||
listen.group = www-data
|
; process.priority = -19
|
||||||
listen.mode = 0600
|
|
||||||
|
|
||||||
; Unix user/group of processes
|
; Set the process dumpable flag (PR_SET_DUMPABLE prctl) even if the process user
|
||||||
; Note: The user is mandatory. If the group is not set, the default user's group
|
; or group is differrent than the master process user. It allows to create process
|
||||||
; will be used.
|
; core dump and ptrace the process for the pool user.
|
||||||
user = USERTOCHANGE
|
; Default Value: no
|
||||||
group = USERTOCHANGE
|
; process.dumpable = yes
|
||||||
|
|
||||||
; Choose how the process manager will control the number of child processes.
|
; Choose how the process manager will control the number of child processes.
|
||||||
; Possible Values:
|
; Possible Values:
|
||||||
; static - a fixed number (pm.max_children) of child processes;
|
; static - a fixed number (pm.max_children) of child processes;
|
||||||
; dynamic - the number of child processes are set dynamically based on the
|
; dynamic - the number of child processes are set dynamically based on the
|
||||||
; following directives:
|
; following directives. With this process management, there will be
|
||||||
|
; always at least 1 children.
|
||||||
; pm.max_children - the maximum number of children that can
|
; pm.max_children - the maximum number of children that can
|
||||||
; be alive at the same time.
|
; be alive at the same time.
|
||||||
; pm.start_servers - the number of children created on startup.
|
; pm.start_servers - the number of children created on startup.
|
||||||
|
@ -69,73 +92,150 @@ group = USERTOCHANGE
|
||||||
; state (waiting to process). If the number
|
; state (waiting to process). If the number
|
||||||
; of 'idle' processes is greater than this
|
; of 'idle' processes is greater than this
|
||||||
; number then some children will be killed.
|
; number then some children will be killed.
|
||||||
|
; ondemand - no children are created at startup. Children will be forked when
|
||||||
|
; new requests will connect. The following parameter are used:
|
||||||
|
; pm.max_children - the maximum number of children that
|
||||||
|
; can be alive at the same time.
|
||||||
|
; pm.process_idle_timeout - The number of seconds after which
|
||||||
|
; an idle process will be killed.
|
||||||
; Note: This value is mandatory.
|
; Note: This value is mandatory.
|
||||||
pm = dynamic
|
pm = dynamic
|
||||||
|
|
||||||
; The number of child processes to be created when pm is set to 'static' and the
|
; The number of child processes to be created when pm is set to 'static' and the
|
||||||
; maximum number of child processes to be created when pm is set to 'dynamic'.
|
; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.
|
||||||
; This value sets the limit on the number of simultaneous requests that will be
|
; This value sets the limit on the number of simultaneous requests that will be
|
||||||
; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
|
; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
|
||||||
; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
|
; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
|
||||||
; CGI.
|
; CGI. The below defaults are based on a server without much resources. Don't
|
||||||
; Note: Used when pm is set to either 'static' or 'dynamic'
|
; forget to tweak pm.* to fit your needs.
|
||||||
|
; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
|
||||||
; Note: This value is mandatory.
|
; Note: This value is mandatory.
|
||||||
pm.max_children = 6
|
pm.max_children = 5
|
||||||
|
|
||||||
; The number of child processes created on startup.
|
; The number of child processes created on startup.
|
||||||
; Note: Used only when pm is set to 'dynamic'
|
; Note: Used only when pm is set to 'dynamic'
|
||||||
; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
|
; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
|
||||||
pm.start_servers = 3
|
pm.start_servers = 2
|
||||||
|
|
||||||
; The desired minimum number of idle server processes.
|
; The desired minimum number of idle server processes.
|
||||||
; Note: Used only when pm is set to 'dynamic'
|
; Note: Used only when pm is set to 'dynamic'
|
||||||
; Note: Mandatory when pm is set to 'dynamic'
|
; Note: Mandatory when pm is set to 'dynamic'
|
||||||
pm.min_spare_servers = 3
|
pm.min_spare_servers = 1
|
||||||
|
|
||||||
; The desired maximum number of idle server processes.
|
; The desired maximum number of idle server processes.
|
||||||
; Note: Used only when pm is set to 'dynamic'
|
; Note: Used only when pm is set to 'dynamic'
|
||||||
; Note: Mandatory when pm is set to 'dynamic'
|
; Note: Mandatory when pm is set to 'dynamic'
|
||||||
pm.max_spare_servers = 5
|
pm.max_spare_servers = 3
|
||||||
|
|
||||||
|
; The number of seconds after which an idle process will be killed.
|
||||||
|
; Note: Used only when pm is set to 'ondemand'
|
||||||
|
; Default Value: 10s
|
||||||
|
;pm.process_idle_timeout = 10s;
|
||||||
|
|
||||||
; The number of requests each child process should execute before respawning.
|
; The number of requests each child process should execute before respawning.
|
||||||
; This can be useful to work around memory leaks in 3rd party libraries. For
|
; This can be useful to work around memory leaks in 3rd party libraries. For
|
||||||
; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
|
; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
|
||||||
; Default Value: 0
|
; Default Value: 0
|
||||||
pm.max_requests = 500
|
;pm.max_requests = 500
|
||||||
|
|
||||||
; The URI to view the FPM status page. If this value is not set, no URI will be
|
; The URI to view the FPM status page. If this value is not set, no URI will be
|
||||||
; recognized as a status page. By default, the status page shows the following
|
; recognized as a status page. It shows the following informations:
|
||||||
; information:
|
|
||||||
; accepted conn - the number of request accepted by the pool;
|
|
||||||
; pool - the name of the pool;
|
; pool - the name of the pool;
|
||||||
; process manager - static or dynamic;
|
; process manager - static, dynamic or ondemand;
|
||||||
|
; start time - the date and time FPM has started;
|
||||||
|
; start since - number of seconds since FPM has started;
|
||||||
|
; accepted conn - the number of request accepted by the pool;
|
||||||
|
; listen queue - the number of request in the queue of pending
|
||||||
|
; connections (see backlog in listen(2));
|
||||||
|
; max listen queue - the maximum number of requests in the queue
|
||||||
|
; of pending connections since FPM has started;
|
||||||
|
; listen queue len - the size of the socket queue of pending connections;
|
||||||
; idle processes - the number of idle processes;
|
; idle processes - the number of idle processes;
|
||||||
; active processes - the number of active processes;
|
; active processes - the number of active processes;
|
||||||
; total processes - the number of idle + active processes.
|
; total processes - the number of idle + active processes;
|
||||||
|
; max active processes - the maximum number of active processes since FPM
|
||||||
|
; has started;
|
||||||
; max children reached - number of times, the process limit has been reached,
|
; max children reached - number of times, the process limit has been reached,
|
||||||
; when pm tries to start more children (works only for
|
; when pm tries to start more children (works only for
|
||||||
; pm 'dynamic')
|
; pm 'dynamic' and 'ondemand');
|
||||||
; The values of 'idle processes', 'active processes' and 'total processes' are
|
; Value are updated in real time.
|
||||||
; updated each second. The value of 'accepted conn' is updated in real time.
|
|
||||||
; Example output:
|
; Example output:
|
||||||
; accepted conn: 12073
|
|
||||||
; pool: www
|
; pool: www
|
||||||
; process manager: static
|
; process manager: static
|
||||||
; idle processes: 35
|
; start time: 01/Jul/2011:17:53:49 +0200
|
||||||
; active processes: 65
|
; start since: 62636
|
||||||
; total processes: 100
|
; accepted conn: 190460
|
||||||
; max children reached: 1
|
; listen queue: 0
|
||||||
|
; max listen queue: 1
|
||||||
|
; listen queue len: 42
|
||||||
|
; idle processes: 4
|
||||||
|
; active processes: 11
|
||||||
|
; total processes: 15
|
||||||
|
; max active processes: 12
|
||||||
|
; max children reached: 0
|
||||||
|
;
|
||||||
; By default the status page output is formatted as text/plain. Passing either
|
; By default the status page output is formatted as text/plain. Passing either
|
||||||
; 'html' or 'json' as a query string will return the corresponding output
|
; 'html', 'xml' or 'json' in the query string will return the corresponding
|
||||||
; syntax. Example:
|
; output syntax. Example:
|
||||||
; http://www.foo.bar/status
|
; http://www.foo.bar/status
|
||||||
; http://www.foo.bar/status?json
|
; http://www.foo.bar/status?json
|
||||||
; http://www.foo.bar/status?html
|
; http://www.foo.bar/status?html
|
||||||
|
; http://www.foo.bar/status?xml
|
||||||
|
;
|
||||||
|
; By default the status page only outputs short status. Passing 'full' in the
|
||||||
|
; query string will also return status for each pool process.
|
||||||
|
; Example:
|
||||||
|
; http://www.foo.bar/status?full
|
||||||
|
; http://www.foo.bar/status?json&full
|
||||||
|
; http://www.foo.bar/status?html&full
|
||||||
|
; http://www.foo.bar/status?xml&full
|
||||||
|
; The Full status returns for each process:
|
||||||
|
; pid - the PID of the process;
|
||||||
|
; state - the state of the process (Idle, Running, ...);
|
||||||
|
; start time - the date and time the process has started;
|
||||||
|
; start since - the number of seconds since the process has started;
|
||||||
|
; requests - the number of requests the process has served;
|
||||||
|
; request duration - the duration in µs of the requests;
|
||||||
|
; request method - the request method (GET, POST, ...);
|
||||||
|
; request URI - the request URI with the query string;
|
||||||
|
; content length - the content length of the request (only with POST);
|
||||||
|
; user - the user (PHP_AUTH_USER) (or '-' if not set);
|
||||||
|
; script - the main script called (or '-' if not set);
|
||||||
|
; last request cpu - the %cpu the last request consumed
|
||||||
|
; it's always 0 if the process is not in Idle state
|
||||||
|
; because CPU calculation is done when the request
|
||||||
|
; processing has terminated;
|
||||||
|
; last request memory - the max amount of memory the last request consumed
|
||||||
|
; it's always 0 if the process is not in Idle state
|
||||||
|
; because memory calculation is done when the request
|
||||||
|
; processing has terminated;
|
||||||
|
; If the process is in Idle state, then informations are related to the
|
||||||
|
; last request the process has served. Otherwise informations are related to
|
||||||
|
; the current request being served.
|
||||||
|
; Example output:
|
||||||
|
; ************************
|
||||||
|
; pid: 31330
|
||||||
|
; state: Running
|
||||||
|
; start time: 01/Jul/2011:17:53:49 +0200
|
||||||
|
; start since: 63087
|
||||||
|
; requests: 12808
|
||||||
|
; request duration: 1250261
|
||||||
|
; request method: GET
|
||||||
|
; request URI: /test_mem.php?N=10000
|
||||||
|
; content length: 0
|
||||||
|
; user: -
|
||||||
|
; script: /home/fat/web/docs/php/test_mem.php
|
||||||
|
; last request cpu: 0.00
|
||||||
|
; last request memory: 0
|
||||||
|
;
|
||||||
|
; Note: There is a real-time FPM status monitoring sample web page available
|
||||||
|
; It's available in: /usr/share/php/7.0/fpm/status.html
|
||||||
|
;
|
||||||
; Note: The value must start with a leading slash (/). The value can be
|
; Note: The value must start with a leading slash (/). The value can be
|
||||||
; anything, but it may not be a good idea to use the .php extension or it
|
; anything, but it may not be a good idea to use the .php extension or it
|
||||||
; may conflict with a real PHP file.
|
; may conflict with a real PHP file.
|
||||||
; Default Value: not set
|
; Default Value: not set
|
||||||
pm.status_path = /fpm-status
|
;pm.status_path = /status
|
||||||
|
|
||||||
; The ping URI to call the monitoring page of FPM. If this value is not set, no
|
; The ping URI to call the monitoring page of FPM. If this value is not set, no
|
||||||
; URI will be recognized as a ping page. This could be used to test from outside
|
; URI will be recognized as a ping page. This could be used to test from outside
|
||||||
|
@ -147,39 +247,102 @@ pm.status_path = /fpm-status
|
||||||
; anything, but it may not be a good idea to use the .php extension or it
|
; anything, but it may not be a good idea to use the .php extension or it
|
||||||
; may conflict with a real PHP file.
|
; may conflict with a real PHP file.
|
||||||
; Default Value: not set
|
; Default Value: not set
|
||||||
ping.path = /ping
|
;ping.path = /ping
|
||||||
|
|
||||||
; This directive may be used to customize the response of a ping request. The
|
; This directive may be used to customize the response of a ping request. The
|
||||||
; response is formatted as text/plain with a 200 response code.
|
; response is formatted as text/plain with a 200 response code.
|
||||||
; Default Value: pong
|
; Default Value: pong
|
||||||
;ping.response = pong
|
;ping.response = pong
|
||||||
|
|
||||||
; The timeout for serving a single request after which the worker process will
|
; The access log file
|
||||||
; be killed. This option should be used when the 'max_execution_time' ini option
|
; Default: not set
|
||||||
; does not stop script execution for some reason. A value of '0' means 'off'.
|
;access.log = log/$pool.access.log
|
||||||
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
|
|
||||||
; Default Value: 0
|
; The access log format.
|
||||||
request_terminate_timeout = 120s
|
; The following syntax is allowed
|
||||||
|
; %%: the '%' character
|
||||||
|
; %C: %CPU used by the request
|
||||||
|
; it can accept the following format:
|
||||||
|
; - %{user}C for user CPU only
|
||||||
|
; - %{system}C for system CPU only
|
||||||
|
; - %{total}C for user + system CPU (default)
|
||||||
|
; %d: time taken to serve the request
|
||||||
|
; it can accept the following format:
|
||||||
|
; - %{seconds}d (default)
|
||||||
|
; - %{miliseconds}d
|
||||||
|
; - %{mili}d
|
||||||
|
; - %{microseconds}d
|
||||||
|
; - %{micro}d
|
||||||
|
; %e: an environment variable (same as $_ENV or $_SERVER)
|
||||||
|
; it must be associated with embraces to specify the name of the env
|
||||||
|
; variable. Some exemples:
|
||||||
|
; - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e
|
||||||
|
; - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e
|
||||||
|
; %f: script filename
|
||||||
|
; %l: content-length of the request (for POST request only)
|
||||||
|
; %m: request method
|
||||||
|
; %M: peak of memory allocated by PHP
|
||||||
|
; it can accept the following format:
|
||||||
|
; - %{bytes}M (default)
|
||||||
|
; - %{kilobytes}M
|
||||||
|
; - %{kilo}M
|
||||||
|
; - %{megabytes}M
|
||||||
|
; - %{mega}M
|
||||||
|
; %n: pool name
|
||||||
|
; %o: output header
|
||||||
|
; it must be associated with embraces to specify the name of the header:
|
||||||
|
; - %{Content-Type}o
|
||||||
|
; - %{X-Powered-By}o
|
||||||
|
; - %{Transfert-Encoding}o
|
||||||
|
; - ....
|
||||||
|
; %p: PID of the child that serviced the request
|
||||||
|
; %P: PID of the parent of the child that serviced the request
|
||||||
|
; %q: the query string
|
||||||
|
; %Q: the '?' character if query string exists
|
||||||
|
; %r: the request URI (without the query string, see %q and %Q)
|
||||||
|
; %R: remote IP address
|
||||||
|
; %s: status (response code)
|
||||||
|
; %t: server time the request was received
|
||||||
|
; it can accept a strftime(3) format:
|
||||||
|
; %d/%b/%Y:%H:%M:%S %z (default)
|
||||||
|
; The strftime(3) format must be encapsuled in a %{<strftime_format>}t tag
|
||||||
|
; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t
|
||||||
|
; %T: time the log has been written (the request has finished)
|
||||||
|
; it can accept a strftime(3) format:
|
||||||
|
; %d/%b/%Y:%H:%M:%S %z (default)
|
||||||
|
; The strftime(3) format must be encapsuled in a %{<strftime_format>}t tag
|
||||||
|
; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t
|
||||||
|
; %u: remote user
|
||||||
|
;
|
||||||
|
; Default: "%R - %u %t \"%m %r\" %s"
|
||||||
|
;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%"
|
||||||
|
|
||||||
|
; The log file for slow requests
|
||||||
|
; Default Value: not set
|
||||||
|
; Note: slowlog is mandatory if request_slowlog_timeout is set
|
||||||
|
;slowlog = log/$pool.log.slow
|
||||||
|
|
||||||
; The timeout for serving a single request after which a PHP backtrace will be
|
; The timeout for serving a single request after which a PHP backtrace will be
|
||||||
; dumped to the 'slowlog' file. A value of '0s' means 'off'.
|
; dumped to the 'slowlog' file. A value of '0s' means 'off'.
|
||||||
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
|
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
|
||||||
; Default Value: 0
|
; Default Value: 0
|
||||||
request_slowlog_timeout = 5s
|
;request_slowlog_timeout = 0
|
||||||
|
|
||||||
; The log file for slow requests
|
; The timeout for serving a single request after which the worker process will
|
||||||
; Default Value: not set
|
; be killed. This option should be used when the 'max_execution_time' ini option
|
||||||
; Note: slowlog is mandatory if request_slowlog_timeout is set
|
; does not stop script execution for some reason. A value of '0' means 'off'.
|
||||||
slowlog = /var/log/nginx/NAMETOCHANGE.slow.log
|
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
|
||||||
|
; Default Value: 0
|
||||||
|
request_terminate_timeout = 1d
|
||||||
|
|
||||||
; Set open file descriptor rlimit.
|
; Set open file descriptor rlimit.
|
||||||
; Default Value: system defined value
|
; Default Value: system defined value
|
||||||
rlimit_files = 4096
|
;rlimit_files = 1024
|
||||||
|
|
||||||
; Set max core size rlimit.
|
; Set max core size rlimit.
|
||||||
; Possible Values: 'unlimited' or an integer greater or equal to 0
|
; Possible Values: 'unlimited' or an integer greater or equal to 0
|
||||||
; Default Value: system defined value
|
; Default Value: system defined value
|
||||||
rlimit_core = 0
|
;rlimit_core = 0
|
||||||
|
|
||||||
; Chroot to this directory at the start. This value must be defined as an
|
; Chroot to this directory at the start. This value must be defined as an
|
||||||
; absolute path. When this value is not set, chroot is not used.
|
; absolute path. When this value is not set, chroot is not used.
|
||||||
|
@ -195,14 +358,31 @@ rlimit_core = 0
|
||||||
; Chdir to this directory at the start.
|
; Chdir to this directory at the start.
|
||||||
; Note: relative path can be used.
|
; Note: relative path can be used.
|
||||||
; Default Value: current directory or / when chroot
|
; Default Value: current directory or / when chroot
|
||||||
chdir = FOLDERTOCHANGE
|
chdir = __FINALPATH__
|
||||||
|
|
||||||
; Redirect worker stdout and stderr into main error log. If not set, stdout and
|
; Redirect worker stdout and stderr into main error log. If not set, stdout and
|
||||||
; stderr will be redirected to /dev/null according to FastCGI specs.
|
; stderr will be redirected to /dev/null according to FastCGI specs.
|
||||||
; Note: on highloaded environement, this can cause some delay in the page
|
; Note: on highloaded environement, this can cause some delay in the page
|
||||||
; process time (several ms).
|
; process time (several ms).
|
||||||
; Default Value: no
|
; Default Value: no
|
||||||
catch_workers_output = yes
|
;catch_workers_output = yes
|
||||||
|
|
||||||
|
; Clear environment in FPM workers
|
||||||
|
; Prevents arbitrary environment variables from reaching FPM worker processes
|
||||||
|
; by clearing the environment in workers before env vars specified in this
|
||||||
|
; pool configuration are added.
|
||||||
|
; Setting to "no" will make all environment variables available to PHP code
|
||||||
|
; via getenv(), $_ENV and $_SERVER.
|
||||||
|
; Default Value: yes
|
||||||
|
;clear_env = no
|
||||||
|
|
||||||
|
; Limits the extensions of the main script FPM will allow to parse. This can
|
||||||
|
; prevent configuration mistakes on the web server side. You should only limit
|
||||||
|
; FPM to .php extensions to prevent malicious users to use other extensions to
|
||||||
|
; execute php code.
|
||||||
|
; Note: set an empty value to allow all extensions.
|
||||||
|
; Default Value: .php
|
||||||
|
;security.limit_extensions = .php .php3 .php4 .php5 .php7
|
||||||
|
|
||||||
; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from
|
; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from
|
||||||
; the current environment.
|
; the current environment.
|
||||||
|
@ -238,6 +418,13 @@ catch_workers_output = yes
|
||||||
;php_admin_flag[log_errors] = on
|
;php_admin_flag[log_errors] = on
|
||||||
;php_admin_value[memory_limit] = 32M
|
;php_admin_value[memory_limit] = 32M
|
||||||
|
|
||||||
php_value[upload_max_filesize] = 10G
|
; Common values to change to increase file upload limit
|
||||||
php_value[post_max_size] = 10G
|
; php_admin_value[upload_max_filesize] = 50M
|
||||||
php_value[mail.add_x_header] = Off
|
; php_admin_value[post_max_size] = 50M
|
||||||
|
; php_admin_flag[mail.add_x_header] = Off
|
||||||
|
|
||||||
|
; Other common parameters
|
||||||
|
; php_admin_value[max_execution_time] = 600
|
||||||
|
; php_admin_value[max_input_time] = 300
|
||||||
|
; php_admin_value[memory_limit] = 256M
|
||||||
|
; php_admin_flag[short_open_tag] = On
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
User-agent: *
|
|
||||||
Disallow: /
|
|
0
doc/DESCRIPTION.md
Normal file
0
doc/DESCRIPTION.md
Normal file
5
doc/DISCLAIMER.md
Normal file
5
doc/DISCLAIMER.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
You need to indicate the true path of your calibre library and make sure COPS runs under the same user as were the files are located
|
||||||
|
|
||||||
|
Designed to work best with OwnCloud or NextCloud
|
||||||
|
|
||||||
|
Creates an OPDS and HTML server based on a Calibre folder stored in NextCloud
|
|
@ -6,8 +6,15 @@
|
||||||
"en": "Calibre OPDS (and HTML) PHP Server",
|
"en": "Calibre OPDS (and HTML) PHP Server",
|
||||||
"fr": "Calibre OPDS (et HTML) PHP Serveur"
|
"fr": "Calibre OPDS (et HTML) PHP Serveur"
|
||||||
},
|
},
|
||||||
"url": "https://github.com/YunoHost-Apps/cops_ynh",
|
"version": "1.1.3~ynh1",
|
||||||
"license": "free",
|
"url": "https://blog.slucas.fr/projects/calibre-opds-php-server/",
|
||||||
|
"upstream": {
|
||||||
|
"license": "GPL-2.0",
|
||||||
|
"website": "https://blog.slucas.fr/projects/calibre-opds-php-server/",
|
||||||
|
"demo": "http://cops-demo.slucas.fr/index.php",
|
||||||
|
"code": "https://github.com/seblucas/cops"
|
||||||
|
},
|
||||||
|
"license": "GPL-2.0",
|
||||||
"maintainer": {
|
"maintainer": {
|
||||||
"name": "polytan02",
|
"name": "polytan02",
|
||||||
"email": "polytan02@mcgva.org"
|
"email": "polytan02@mcgva.org"
|
||||||
|
@ -15,77 +22,37 @@
|
||||||
"multi_instance": true,
|
"multi_instance": true,
|
||||||
"services": [
|
"services": [
|
||||||
"nginx",
|
"nginx",
|
||||||
"php5-fpm"
|
"php7.3-fpm"
|
||||||
],
|
],
|
||||||
"requirements": {
|
"requirements": {
|
||||||
"yunohost": ">= 2.4.0"
|
"yunohost": ">= 4.3.0"
|
||||||
},
|
},
|
||||||
"arguments": {
|
"arguments": {
|
||||||
"install" : [
|
"install" : [
|
||||||
{
|
{
|
||||||
"name": "domain",
|
"name": "domain",
|
||||||
"type": "domain",
|
"type": "domain"
|
||||||
"ask": {
|
|
||||||
"en": "Choose a domain for COPS library",
|
|
||||||
"fr": "Choisissez un domaine pour votre bibliotheque COPS"
|
|
||||||
},
|
|
||||||
"example": "domain.tld"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "path",
|
"name": "path",
|
||||||
"type": "path",
|
"type": "path",
|
||||||
"ask": {
|
|
||||||
"en": "Choose a path to access your COPS library",
|
|
||||||
"fr": "Choisissez un chemin pour acceder a votre bibliotheque COPS"
|
|
||||||
},
|
|
||||||
"example": "/cops",
|
"example": "/cops",
|
||||||
"default": "/cops"
|
"default": "/cops"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "calibre",
|
"name": "language",
|
||||||
|
"type": "string",
|
||||||
"ask": {
|
"ask": {
|
||||||
"en": "Indicate the location of Calibre library. DON'T store it in your /var/www/cops or it will be removed on next upgrade !!",
|
"en": "Choose the application language",
|
||||||
"fr": "Indiquez le chemin de votre bibliotheque Calibre. Ne la mettez pas dans /var/www/cops ou elle sera supprimée à la prochaine upgrade !!!"
|
"fr": "Choisissez la langue de l'application"
|
||||||
},
|
},
|
||||||
"example": "/home/yunohost.app/owncloud/data/johndoe/files/eBooks",
|
"choices": ["fr", "en"],
|
||||||
"default": "/home/yunohost.app/owncloud/data/johndoe/files/eBooks"
|
"default": "fr"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "is_public",
|
"name": "is_public",
|
||||||
"ask": {
|
"type": "boolean",
|
||||||
"en": "Is it a public website ?",
|
"default": true
|
||||||
"fr": "Est-ce un site publique ?"
|
|
||||||
},
|
|
||||||
"choices": ["Yes", "No"],
|
|
||||||
"default": "Yes"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "basicauthcreate",
|
|
||||||
"ask": {
|
|
||||||
"en": "Create a basic auth access (only taken into account for a Public app) ? This is required if the app is public so that ereaders to access the OPDS server, for example",
|
|
||||||
"fr": "Créer un accès par authentification basique (Uniquement pris en compte pour une app Publique) ? Ceci est requis si votre bibliothèque est publique et que vous voulez accéder au serveur OPDS avec votre liseuse ou application mobile"
|
|
||||||
},
|
|
||||||
"choices": ["Yes", "No"],
|
|
||||||
"default": "Yes"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "basicauthname",
|
|
||||||
"ask": {
|
|
||||||
"en": "Choose the login name to access the OPDS/HTML server (UNRELATED to YunoHost users)",
|
|
||||||
"fr": "Indiquez le nom d'utilisateur pour accéder au serveur OPDS/HTML (NON lié lié aux utilisateurs YunoHost)"
|
|
||||||
},
|
|
||||||
"example": "Gutenberg",
|
|
||||||
"default": "Gutenberg"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "basicauthpass",
|
|
||||||
"type": "password",
|
|
||||||
"ask": {
|
|
||||||
"en": "Choose the password to access the OPDS/HTML server",
|
|
||||||
"fr": "Renseignez le mot de passe pour accéder au serveur OPDS/HTML"
|
|
||||||
},
|
|
||||||
"example": "knowledge is power",
|
|
||||||
"default": "knowledge is power"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,97 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
EXIT_PROPERLY () { # Provoque l'arrêt du script en cas d'erreur. Et nettoye les résidus.
|
|
||||||
exit_code=$?
|
|
||||||
if [ "$exit_code" -eq 0 ]; then
|
|
||||||
exit 0 # Quitte sans erreur si le script se termine correctement.
|
|
||||||
fi
|
|
||||||
trap '' EXIT
|
|
||||||
set +eu
|
|
||||||
echo -e "\e[91m \e[1m" # Shell in light red bold
|
|
||||||
echo -e "!!\n $app install's script has encountered an error. Installation was cancelled.\n!!" >&2
|
|
||||||
|
|
||||||
if type -t CLEAN_SETUP > /dev/null; then # Vérifie l'existance de la fonction avant de l'exécuter.
|
|
||||||
CLEAN_SETUP # Appel la fonction de nettoyage spécifique du script install.
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Compense le bug de ssowat qui ne supprime pas l'entrée de l'app en cas d'erreur d'installation.
|
|
||||||
sudo sed -i "\@\"$domain$path/\":@d" /etc/ssowat/conf.json
|
|
||||||
|
|
||||||
ynh_die
|
|
||||||
}
|
|
||||||
|
|
||||||
TRAP_ON () { # Activate signal capture
|
|
||||||
set -eu # Exit if a command fail, and if a variable is used unset.
|
|
||||||
trap EXIT_PROPERLY EXIT # Capturing exit signals on shell script
|
|
||||||
}
|
|
||||||
|
|
||||||
# We check variables are not empty
|
|
||||||
CHECK_VAR () { # Vérifie que la variable n'est pas vide.
|
|
||||||
# $1 = Variable à vérifier
|
|
||||||
# $2 = Texte à afficher en cas d'erreur
|
|
||||||
test -n "$1" || (echo "$2" >&2 && false)
|
|
||||||
}
|
|
||||||
|
|
||||||
# Check the path value and correct it (adds / at begining and removes it at the end)
|
|
||||||
CHECK_PATH () { # Vérifie la présence du / en début de path. Et son absence à la fin.
|
|
||||||
if [ "${path:0:1}" != "/" ]; then # Si le premier caractère n'est pas un /
|
|
||||||
path="/$path" # Ajoute un / en début de path
|
|
||||||
fi
|
|
||||||
if [ "${path:${#path}-1}" == "/" ] && [ ${#path} -gt 1 ]; then # Si le dernier caractère est un / et que ce n'est pas l$
|
|
||||||
path="${path:0:${#path}-1}" # Supprime le dernier caractère
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Check domain and path availibility
|
|
||||||
CHECK_DOMAINPATH () { # Vérifie la disponibilité du path et du domaine.
|
|
||||||
sudo yunohost app checkurl $domain$path -a $app
|
|
||||||
}
|
|
||||||
|
|
||||||
# Check destination folder is not used already
|
|
||||||
CHECK_FINALPATH () { # Vérifie que le dossier de destination n'est pas déjà utilisé.
|
|
||||||
final_path=/var/www/$app
|
|
||||||
if [ -e "$final_path" ]
|
|
||||||
then
|
|
||||||
echo "This path already contains a folder" >&2
|
|
||||||
false
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# We check that calibre path is correct
|
|
||||||
CHECK_CALIBRE () { # Vérifie la présence du / en début de path. Et son absence à la fin.
|
|
||||||
if [ "${calibre:0:1}" != "/" ]; then # Si le premier caractère n'est pas un /
|
|
||||||
calibre="/$calibre" # Ajoute un / en début de path
|
|
||||||
fi
|
|
||||||
if [ "${calibre:${#calibre}-1}" == "/" ] && [ ${#calibre} -gt 1 ]; then # Si le dernier caractère est un / $
|
|
||||||
calibre="${calibre:0:${#calibre}-1}" # Supprime le dernier caractère
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
SECURE_REMOVE () { # Suppression de dossier avec vérification des variables
|
|
||||||
chaine="$1" # L'argument doit être donné entre quotes simple '', pour éviter d'interpréter les variables.
|
|
||||||
no_var=0
|
|
||||||
while (echo "$chaine" | grep -q '\$') # Boucle tant qu'il y a des $ dans la chaine
|
|
||||||
do
|
|
||||||
no_var=1
|
|
||||||
global_var=$(echo "$chaine" | cut -d '$' -f 2) # Isole la première variable trouvée.
|
|
||||||
only_var=\$$(expr "$global_var" : '\([A-Za-z0-9_]*\)') # Isole complètement la variable en ajoutant le $ au début et en gardant uniquement le nom de la variable. Se débarrasse surtout du / et d'un éventuel chemin derrière.
|
|
||||||
real_var=$(eval "echo ${only_var}") # `eval "echo ${var}` permet d'interpréter une variable contenue dans une variable.
|
|
||||||
if test -z "$real_var" || [ "$real_var" = "/" ]; then
|
|
||||||
echo "Variable $only_var is empty, suppression of $chaine cancelled." >&2
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
chaine=$(echo "$chaine" | sed "s@$only_var@$real_var@") # remplace la variable par sa valeur dans la chaine.
|
|
||||||
done
|
|
||||||
if [ "$no_var" -eq 1 ]
|
|
||||||
then
|
|
||||||
if [ -e "$chaine" ]; then
|
|
||||||
echo "Delete directory $chaine"
|
|
||||||
sudo rm -r "$chaine"
|
|
||||||
fi
|
|
||||||
return 0
|
|
||||||
else
|
|
||||||
echo "No detected variable." >&2
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
22
scripts/_common.sh
Normal file
22
scripts/_common.sh
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# COMMON VARIABLES
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
YNH_PHP_VERSION="7.3"
|
||||||
|
|
||||||
|
# dependencies used by the app
|
||||||
|
pkg_dependencies="php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-sqlite3 php${YNH_PHP_VERSION}-json php${YNH_PHP_VERSION}-intl"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# PERSONAL HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# EXPERIMENTAL HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# FUTURE OFFICIAL HELPERS
|
||||||
|
#=================================================
|
|
@ -1,22 +1,64 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -eu
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
|
||||||
|
|
||||||
# Source YunoHost helpers
|
#=================================================
|
||||||
|
# GENERIC START
|
||||||
|
#=================================================
|
||||||
|
# IMPORT GENERIC HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||||
|
source ../settings/scripts/_common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
final_path=$(ynh_app_setting_get $app final_path)
|
#=================================================
|
||||||
finalnginxconf=$(ynh_app_setting_get $app finalnginxconf)
|
# MANAGE SCRIPT FAILURE
|
||||||
finalphpconf=$(ynh_app_setting_get $app finalphpconf)
|
#=================================================
|
||||||
|
|
||||||
# Backup sources & data
|
# Exit if an error occurs during the execution of the script
|
||||||
# Note: the last argument is where to save this path, see the restore script.
|
ynh_abort_if_errors
|
||||||
ynh_backup "$final_path" "sources"
|
|
||||||
|
|
||||||
# Copy NGINX configuration
|
#=================================================
|
||||||
ynh_backup "$finalnginxconf" "nginx.conf"
|
# LOAD SETTINGS
|
||||||
|
#=================================================
|
||||||
|
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 "$finalphpconf" "php-fpm.conf"
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
|
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||||
|
#=================================================
|
||||||
|
ynh_print_info --message="Declaring files to be backed up..."
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BACKUP THE APP MAIN DIR
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_backup --src_path="$final_path"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BACKUP THE DATA DIR
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
#ynh_backup --src_path="$calibre_dir" --is_big
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BACKUP THE NGINX CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BACKUP THE PHP-FPM CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
||||||
|
|
248
scripts/install
248
scripts/install
|
@ -1,162 +1,150 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#set -eu
|
|
||||||
|
|
||||||
# Charge les fonctions génériques habituellement utilisées dans le script
|
#=================================================
|
||||||
source .fonctions
|
# GENERIC START
|
||||||
|
#=================================================
|
||||||
|
# IMPORT GENERIC HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Active trap pour arrêter le script si une erreur est détectée.
|
source _common.sh
|
||||||
TRAP_ON
|
|
||||||
|
|
||||||
# Source app helpers
|
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
# Retrieve arguments
|
#=================================================
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
# MANAGE SCRIPT FAILURE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Exit if an error occurs during the execution of the script
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||||||
|
#=================================================
|
||||||
|
|
||||||
domain=$YNH_APP_ARG_DOMAIN
|
domain=$YNH_APP_ARG_DOMAIN
|
||||||
path=$YNH_APP_ARG_PATH
|
path_url=$YNH_APP_ARG_PATH
|
||||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||||
calibre=$YNH_APP_ARG_CALIBRE
|
language=$YNH_APP_ARG_LANGUAGE
|
||||||
|
timezone="$(cat /etc/timezone)"
|
||||||
|
phpversion=$YNH_PHP_VERSION
|
||||||
|
|
||||||
# No basic auth if app is private
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
if [ "$is_public" = "Yes" ];
|
|
||||||
then
|
|
||||||
basicauthcreate=$YNH_APP_ARG_BASICAUTHCREATE
|
|
||||||
basicauthname=$YNH_APP_ARG_BASICAUTHNAME
|
|
||||||
basicauthpass=$YNH_APP_ARG_BASICAUTHPASS
|
|
||||||
else
|
|
||||||
basicauthcreate="No"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# We check variables are not empty
|
#=================================================
|
||||||
CHECK_VAR "$app" "app name not set"
|
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||||
|
#=================================================
|
||||||
# Check the path value and correct it (adds / at begining and removes it at the end)
|
ynh_script_progression --message="Validating installation parameters..." --weight=1
|
||||||
CHECK_PATH;
|
|
||||||
|
|
||||||
# Check domain and path availibility
|
|
||||||
CHECK_DOMAINPATH
|
|
||||||
|
|
||||||
# Check destination folder is not used already
|
|
||||||
CHECK_FINALPATH
|
|
||||||
|
|
||||||
# We check that calibre path is correct
|
|
||||||
CHECK_CALIBRE;
|
|
||||||
|
|
||||||
final_path=/var/www/$app
|
final_path=/var/www/$app
|
||||||
|
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
||||||
|
|
||||||
# Define variables and Save app settings
|
# Register (book) web path
|
||||||
ynh_app_setting_set "$app" domain "$domain"
|
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
||||||
ynh_app_setting_set "$app" is_public "$is_public"
|
|
||||||
ynh_app_setting_set "$app" final_path "$final_path"
|
|
||||||
ynh_app_setting_set "$app" calibre "$calibre"
|
|
||||||
ynh_app_setting_set "$app" basicauthcreate "$basicauthcreate"
|
|
||||||
|
|
||||||
finalnginxconf="/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
#=================================================
|
||||||
ynh_app_setting_set "$app" finalnginxconf "$finalnginxconf"
|
# STORE SETTINGS FROM MANIFEST
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Storing installation settings..." --weight=1
|
||||||
|
|
||||||
finalphpconf="/etc/php5/fpm/pool.d/${app}.conf"
|
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
||||||
ynh_app_setting_set "$app" finalphpconf "$finalphpconf"
|
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
||||||
|
ynh_app_setting_set --app=$app --key=language --value=$language
|
||||||
|
|
||||||
# Install dependencies using Helpers
|
#=================================================
|
||||||
ynh_package_install_from_equivs ../conf/cops-deps.control \
|
# INSTALL DEPENDENCIES
|
||||||
|| ynh_die "Unable to install dependencies"
|
#=================================================
|
||||||
|
ynh_script_progression --message="Installing dependencies..." --weight=1
|
||||||
|
|
||||||
|
ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
# Creation of folder
|
#=================================================
|
||||||
sudo mkdir -p $final_path
|
# CREATE DEDICATED USER
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Configuring system user..." --weight=1
|
||||||
|
|
||||||
# We download the sources and check the md5sum
|
# Create a system user
|
||||||
cops_file=`sudo cat ../sources/source_file`;
|
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||||
sudo wget -nv -i ../sources/source_url -O $cops_file
|
|
||||||
sudo md5sum -c ../sources/source_md5 --status || (echo "Corrupt source" >&2 && false)
|
|
||||||
sudo unzip ${cops_file} -d $final_path
|
|
||||||
|
|
||||||
# Site adjustments
|
#=================================================
|
||||||
sed -i "s@CALIBRETOCHANGE@$calibre@g" ../conf/config_local.php
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
timezone=`sudo cat /etc/timezone`;
|
#=================================================
|
||||||
sed -i "s@TIMEZONETOCHANGE@$timezone@g" ../conf/config_local.php
|
ynh_script_progression --message="Setting up source files..." --weight=1
|
||||||
|
|
||||||
sudo cp ../conf/config_local.php $final_path
|
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||||
sudo cp ../conf/robots.txt $final_path
|
# Download, check integrity, uncompress and patch the source from app.src
|
||||||
|
ynh_setup_source --dest_dir="$final_path"
|
||||||
|
|
||||||
# Create cops user and join nextcloud/owncloud/www-data groups
|
chmod 750 "$final_path"
|
||||||
runninguser="${app}-ynh"
|
chmod -R o-rwx "$final_path"
|
||||||
# 1. Create the user
|
chown -R $app:www-data "$final_path"
|
||||||
# Create a system account for COPS if it doesn't already exists
|
|
||||||
if ! ynh_system_user_exists "$runninguser" ;
|
#=================================================
|
||||||
then
|
# NGINX CONFIGURATION
|
||||||
echo "The user $runninguser does not exist, we can create it"
|
#=================================================
|
||||||
sudo useradd -c "$runninguser system account" \
|
ynh_script_progression --message="Configuring NGINX web server..." --weight=1
|
||||||
-d $final_path --system --user-group $runninguser \
|
|
||||||
|| ynh_die "Unable to create $runninguser system account"
|
# Create a dedicated NGINX config
|
||||||
else
|
ynh_add_nginx_config
|
||||||
echo "The user $runninguser exists, no need to create it"
|
|
||||||
|
#=================================================
|
||||||
|
# PHP-FPM CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Configuring PHP-FPM..." --weight=1
|
||||||
|
|
||||||
|
# Create a dedicated PHP-FPM config
|
||||||
|
ynh_add_fpm_config
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CREATE DATA DIRECTORY
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Creating a calibre directory..." --weight=1
|
||||||
|
|
||||||
|
#build multimedia directory
|
||||||
|
ynh_multimedia_build_main_dir
|
||||||
|
ynh_multimedia_addaccess $app
|
||||||
|
|
||||||
|
calibre_dir=/home/yunohost.multimedia/share/eBook
|
||||||
|
ynh_app_setting_set --app=$app --key=calibre_dir --value=$calibre_dir
|
||||||
|
|
||||||
|
#Check if metadata.db file exists. If not create it (empty library)
|
||||||
|
if [ ! -e "$calibre_dir"/metadata.db ]; then
|
||||||
|
cp -a ../conf/metadata.db.empty $calibre_dir/metadata.db
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ynh_app_setting_set "$app" runninguser "$runninguser"
|
chmod 750 "$calibre_dir"
|
||||||
|
chmod 775 "$calibre_dir/metadata.db"
|
||||||
|
chmod -R o-rwx "$calibre_dir"
|
||||||
|
chown -R $app:www-data "$calibre_dir"
|
||||||
|
|
||||||
# 2. Add cops-ynh to groups www-data and nextcloud/owncloud if they exist
|
#=================================================
|
||||||
sudo usermod -a -G www-data $runninguser
|
# ADD A CONFIGURATION
|
||||||
for filesharing in "nextcloud" "owncloud"; do
|
#=================================================
|
||||||
app_id=$(sudo yunohost app list --installed -f "$filesharing" \
|
ynh_script_progression --message="Adding a configuration file..." --weight=1
|
||||||
--output-as json | grep -Po '"id":[ ]?"\K.*?(?=")' | head -1)
|
|
||||||
[[ -z "$app_id" ]] || {
|
|
||||||
sudo usermod -a -G $filesharing $runninguser
|
|
||||||
}
|
|
||||||
done
|
|
||||||
|
|
||||||
# Set permissions
|
ynh_add_config --template="../conf/config_local.php" --destination="$final_path/config_local.php"
|
||||||
sudo chmod ug+rw -R $final_path
|
|
||||||
sudo chown -hR $runninguser:$runninguser $final_path
|
|
||||||
|
|
||||||
# Add basic auth if requested
|
chmod 600 "$final_path/config_local.php"
|
||||||
if [ "$basicauthcreate" = "Yes" ];
|
chown $app "$final_path/config_local.php"
|
||||||
then
|
|
||||||
ynh_app_setting_set "$app" basicauthname "$basicauthname"
|
|
||||||
ynh_app_setting_set "$app" basicauthpass "$basicauthpass"
|
|
||||||
|
|
||||||
# Generation of the htpasswd file according https://www.nginx.com/resources/wiki/community/faq/
|
#=================================================
|
||||||
SALT="$(openssl rand -base64 3)"
|
# SETUP SSOWAT
|
||||||
(SHA1=$(printf "$basicauthpass$SALT" |
|
#=================================================
|
||||||
openssl dgst -binary -sha1 | xxd -ps |
|
ynh_script_progression --message="Configuring permissions..." --weight=1
|
||||||
sed 's#$#'"`echo -n $SALT | xxd -ps`"'#' |
|
|
||||||
xxd -r -ps |
|
|
||||||
base64);printf "$basicauthname:{SSHA}$SHA1\n" >> ../sources/htpasswd)
|
|
||||||
sudo cp ../sources/htpasswd $final_path
|
|
||||||
sudo chmod 440 $final_path/htpasswd
|
|
||||||
sudo chown www-data:www-data $final_path/htpasswd
|
|
||||||
|
|
||||||
# Modif nginx
|
|
||||||
sed -i "s|^.*\bauth_basic\b.*$| auth_basic \"Private Library\";|" ../conf/nginx.conf;
|
|
||||||
sed -i "s|^.*\bauth_basic_user_file\b.*$| auth_basic_user_file $final_path/htpasswd;|" ../conf/nginx.conf;
|
|
||||||
else
|
|
||||||
echo "No basic auth";
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Modify Nginx configuration file and copy it to Nginx conf.d directory
|
|
||||||
sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf
|
|
||||||
sed -i "s@ALIASTOCHANGE@$final_path/@g" ../conf/nginx.conf
|
|
||||||
sed -i "s@NAMETOCHANGE@$app@g" ../conf/nginx.conf
|
|
||||||
sudo cp ../conf/nginx.conf $finalnginxconf
|
|
||||||
|
|
||||||
# Modify php-fpm configuration file and copy it to php-fpm pool.d directory
|
|
||||||
sed -i "s@NAMETOCHANGE@$app@g" ../conf/php-fpm.conf
|
|
||||||
sed -i "s@FOLDERTOCHANGE@$final_path@g" ../conf/php-fpm.conf
|
|
||||||
sed -i "s@USERTOCHANGE@$runninguser@g" ../conf/php-fpm.conf
|
|
||||||
sudo cp ../conf/php-fpm.conf $finalphpconf
|
|
||||||
sudo chown root: $finalphpconf
|
|
||||||
sudo chmod 644 $finalphpconf
|
|
||||||
|
|
||||||
# Make app public if necessary
|
# Make app public if necessary
|
||||||
is_public=$(ynh_app_setting_get $app is_public)
|
if [ $is_public -eq 1 ]
|
||||||
if [ "$is_public" = "Yes" ];
|
|
||||||
then
|
then
|
||||||
ynh_app_setting_set $app skipped_uris "/"
|
ynh_permission_update --permission="main" --add="visitors"
|
||||||
else
|
|
||||||
ynh_app_setting_set $app protected_uris "/"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Reload Nginx and regenerate SSOwat conf
|
#=================================================
|
||||||
sudo service php5-fpm reload
|
# RELOAD NGINX
|
||||||
sudo service nginx reload
|
#=================================================
|
||||||
sudo yunohost app ssowatconf
|
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
||||||
|
|
||||||
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Installation of $app completed" --last
|
||||||
|
|
123
scripts/remove
123
scripts/remove
|
@ -1,80 +1,69 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -u
|
|
||||||
|
|
||||||
# Charge les fonctions génériques habituellement utilisées dans le script
|
#=================================================
|
||||||
SECURE_REMOVE () { # Suppression de dossier avec vérification des variables
|
# GENERIC START
|
||||||
chaine="$1" # L'argument doit être donné entre quotes simple '', pour éviter d'interpréter les variables.
|
#=================================================
|
||||||
no_var=0
|
# IMPORT GENERIC HELPERS
|
||||||
while (echo "$chaine" | grep -q '\$') # Boucle tant qu'il y a des $ dans la chaine
|
#=================================================
|
||||||
do
|
|
||||||
no_var=1
|
|
||||||
global_var=$(echo "$chaine" | cut -d '$' -f 2) # Isole la première variable trouvée.
|
|
||||||
only_var=\$$(expr "$global_var" : '\([A-Za-z0-9_]*\)') # Isole complètement la variable en ajoutant le $ au début et en gardant uniquement le nom de la variable. Se débarrasse$
|
|
||||||
real_var=$(eval "echo ${only_var}") # `eval "echo ${var}` permet d'interpréter une variable contenue dans une variable.
|
|
||||||
if test -z "$real_var" || [ "$real_var" = "/" ]; then
|
|
||||||
echo "Variable $only_var is empty, suppression of $chaine cancelled." >&2
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
chaine=$(echo "$chaine" | sed "s@$only_var@$real_var@") # remplace la variable par sa valeur dans la chaine.
|
|
||||||
done
|
|
||||||
if [ "$no_var" -eq 1 ]
|
|
||||||
then
|
|
||||||
if [ -e "$chaine" ]; then
|
|
||||||
echo "Delete directory $chaine"
|
|
||||||
sudo rm -r "$chaine"
|
|
||||||
fi
|
|
||||||
return 0
|
|
||||||
else
|
|
||||||
echo "No detected variable." >&2
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
REMOVE_SYS_USER () { # Supprime l'utilisateur système dédié à l'app
|
source _common.sh
|
||||||
if ynh_system_user_exists "$1" # Test l'existence de l'utilisateur
|
|
||||||
then
|
|
||||||
sudo userdel $1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Active trap pour arrêter le script si une erreur est détectée.
|
|
||||||
|
|
||||||
# Source app helpers
|
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
# We retrieve app parameters
|
#=================================================
|
||||||
|
# LOAD SETTINGS
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
final_path=$(ynh_app_setting_get $app final_path)
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
finalnginxconf=$(ynh_app_setting_get $app finalnginxconf)
|
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||||
finalphpconf=$(ynh_app_setting_get $app finalphpconf)
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
runninguser=$app-ynh
|
|
||||||
|
|
||||||
# Suppression du dossier de la webapp
|
#=================================================
|
||||||
SECURE_REMOVE '$final_path'
|
# REMOVE DEPENDENCIES
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Removing dependencies..." --weight=1
|
||||||
|
|
||||||
# Suppression de la config nginx de la webapp
|
# Remove metapackage and its dependencies
|
||||||
if [ -e "$finalnginxconf" ]; then # Delete nginx config
|
ynh_remove_app_dependencies
|
||||||
echo "Delete nginx config"
|
|
||||||
sudo rm $finalnginxconf
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -e "$finalphpconf" ]; then # Delete nginx config
|
#=================================================
|
||||||
echo "Delete php-fpm config"
|
# REMOVE APP MAIN DIR
|
||||||
sudo rm $finalphpconf
|
#=================================================
|
||||||
fi
|
ynh_script_progression --message="Removing app main directory..." --weight=1
|
||||||
|
|
||||||
# Remove app dependencies
|
# Remove the app directory securely
|
||||||
if ynh_package_is_installed "cops-deps"; then
|
ynh_secure_remove --file="$final_path"
|
||||||
ynh_package_autoremove "cops-deps"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Remove the user account~
|
#=================================================
|
||||||
#id "$runninguser" >/dev/null 2>&1 \
|
# REMOVE NGINX CONFIGURATION
|
||||||
#&& sudo deluser --quiet "$runninguser" >/dev/null
|
#=================================================
|
||||||
REMOVE_SYS_USER "$runninguser"
|
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
|
||||||
|
|
||||||
# We reload the services
|
# Remove the dedicated NGINX config
|
||||||
sudo service php5-fpm reload
|
ynh_remove_nginx_config
|
||||||
sudo service nginx reload
|
|
||||||
sudo yunohost app ssowatconf
|
#=================================================
|
||||||
|
# REMOVE PHP-FPM CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=1
|
||||||
|
|
||||||
|
# Remove the dedicated PHP-FPM config
|
||||||
|
ynh_remove_fpm_config
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC FINALIZATION
|
||||||
|
#=================================================
|
||||||
|
# REMOVE DEDICATED USER
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Removing the dedicated system user..." --weight=1
|
||||||
|
|
||||||
|
# Delete a system user
|
||||||
|
ynh_system_user_delete --username=$app
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Removal of $app completed" --last
|
||||||
|
|
166
scripts/restore
166
scripts/restore
|
@ -1,89 +1,113 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -eu
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
|
||||||
|
|
||||||
# Source YunoHost helpers
|
#=================================================
|
||||||
|
# GENERIC START
|
||||||
|
#=================================================
|
||||||
|
# IMPORT GENERIC HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||||
|
source ../settings/scripts/_common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
# Retrieve old app settings
|
#=================================================
|
||||||
final_path=$(ynh_app_setting_get $app final_path)
|
# MANAGE SCRIPT FAILURE
|
||||||
is_public=$(ynh_app_setting_get $app is_public)
|
#=================================================
|
||||||
finalnginxconf=$(ynh_app_setting_get $app finalnginxconf)
|
|
||||||
finalphpconf=$(ynh_app_setting_get $app finalphpconf)
|
|
||||||
runninguser=$(ynh_app_setting_get $app runninguser)
|
|
||||||
basicauthcreate=$(ynh_app_setting_get $app basicauthcreate)
|
|
||||||
|
|
||||||
# We install dependencies
|
# Exit if an error occurs during the execution of the script
|
||||||
sudo apt-get update -y
|
ynh_abort_if_errors
|
||||||
sudo apt-get install php5-gd php5-sqlite php5-json php5-intl -y
|
|
||||||
|
|
||||||
# Install dependencies using Helpers
|
#=================================================
|
||||||
#ynh_package_install_from_equivs ../conf/cops-deps.control \
|
# LOAD SETTINGS
|
||||||
#|| ynh_die "Unable to install dependencies"
|
#=================================================
|
||||||
|
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||||
|
|
||||||
# Restore sources & data
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
sudo mkdir -p $final_path
|
|
||||||
sudo cp -a ./sources/* $final_path/
|
|
||||||
|
|
||||||
# Create cops user and join nextcloud/owncloud/www-data groups
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
runninguser="${app}-ynh"
|
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||||
# 1. Create the user
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
# Create a system account for COPS if it doesn't already exists
|
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||||
if ! ynh_system_user_exists "$runninguser" ;
|
calibre_dir=$(ynh_app_setting_get --app=$app --key=calibre_dir)
|
||||||
then
|
|
||||||
echo "The user $runninguser does not exist, we can create it"
|
|
||||||
sudo useradd -c "$runninguser system account" \
|
|
||||||
-d $final_path --system --user-group $runninguser \
|
|
||||||
|| ynh_die "Unable to create $runninguser system account"
|
|
||||||
else
|
|
||||||
echo "The user $runninguser exists, no need to create it"
|
|
||||||
fi
|
|
||||||
|
|
||||||
ynh_app_setting_set "$app" runninguser "$runninguser"
|
#=================================================
|
||||||
|
# CHECK IF THE APP CAN BE RESTORED
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Validating restoration parameters..." --weight=1
|
||||||
|
|
||||||
# 2. Add cops-ynh to groups www-data and nextcloud/owncloud if they exist
|
test ! -d $final_path || ynh_die --message="There is already a directory: $final_path "
|
||||||
sudo usermod -a -G www-data $runninguser
|
|
||||||
for filesharing in "nextcloud" "owncloud"; do
|
|
||||||
app_id=$(sudo yunohost app list --installed -f "$filesharing" \
|
|
||||||
--output-as json | grep -Po '"id":[ ]?"\K.*?(?=")' | head -1)
|
|
||||||
[[ -z "$app_id" ]] || {
|
|
||||||
sudo usermod -a -G $filesharing $runninguser
|
|
||||||
}
|
|
||||||
done
|
|
||||||
|
|
||||||
# Restore permissions to app files
|
#=================================================
|
||||||
# you may need to make some file and/or directory writeable by www-data (nginx user)
|
# STANDARD RESTORATION STEPS
|
||||||
sudo chown -R $runninguser:$runninguser $final_path
|
#=================================================
|
||||||
|
# RESTORE THE NGINX CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Restoring the NGINX configuration..." --weight=1
|
||||||
|
|
||||||
if [ "$basicauthcreate" = "Yes" ];
|
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
then
|
|
||||||
sudo chmod 440 $final_path/htpasswd
|
|
||||||
sudo chown www-data:www-data $final_path/htpasswd
|
|
||||||
else
|
|
||||||
echo "Nothing to do"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Restore NGINX configuration
|
#=================================================
|
||||||
sudo cp -a ./nginx.conf $finalnginxconf
|
# RECREATE THE DEDICATED USER
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
|
||||||
|
|
||||||
### PHP (remove if not used) ###
|
# Create the dedicated user (if not existing)
|
||||||
# If a dedicated php-fpm process is used:
|
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||||
# # Copy PHP-FPM pool configuration and reload the service
|
|
||||||
sudo cp -a ./php-fpm.conf $finalphpconf
|
|
||||||
### PHP end ###
|
|
||||||
|
|
||||||
# Make app public if necessary
|
#=================================================
|
||||||
is_public=$(ynh_app_setting_get $app is_public)
|
# RESTORE THE APP MAIN DIR
|
||||||
if [ "$is_public" = "Yes" ];
|
#=================================================
|
||||||
then
|
ynh_script_progression --message="Restoring the app main directory..." --weight=1
|
||||||
ynh_app_setting_set $app skipped_uris "/"
|
|
||||||
else
|
|
||||||
ynh_app_setting_set $app protected_uris "/"
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
ynh_restore_file --origin_path="$final_path"
|
||||||
|
|
||||||
# Restart webserver
|
chmod 750 "$final_path"
|
||||||
sudo service nginx reload
|
chmod -R o-rwx "$final_path"
|
||||||
sudo service php5-fpm reload
|
chown -R $app:www-data "$final_path"
|
||||||
sudo yunohost app ssowatconf
|
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RESTORE THE DATA DIRECTORY
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Creating a calibre directory..." --weight=1
|
||||||
|
|
||||||
|
#build multimedia directory
|
||||||
|
ynh_multimedia_build_main_dir
|
||||||
|
ynh_multimedia_addaccess $app
|
||||||
|
|
||||||
|
calibre_dir=/home/yunohost.multimedia/share/eBook
|
||||||
|
ynh_app_setting_set --app=$app --key=calibre_dir --value=$calibre_dir
|
||||||
|
|
||||||
|
chmod 750 "$calibre_dir"
|
||||||
|
chmod -R o-rwx "$calibre_dir"
|
||||||
|
chown -R $app:www-data "$calibre_dir"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RESTORE THE PHP-FPM CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Restoring the PHP-FPM configuration..." --weight=1
|
||||||
|
|
||||||
|
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# REINSTALL DEPENDENCIES
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Reinstalling dependencies..." --weight=1
|
||||||
|
|
||||||
|
# Define and install dependencies
|
||||||
|
ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC FINALIZATION
|
||||||
|
#=================================================
|
||||||
|
# RELOAD NGINX AND PHP-FPM
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=1
|
||||||
|
|
||||||
|
ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
|
||||||
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Restoration completed for $app" --last
|
||||||
|
|
252
scripts/upgrade
252
scripts/upgrade
|
@ -1,127 +1,165 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -eu
|
|
||||||
|
|
||||||
# We retrieve app parameters
|
#=================================================
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
# GENERIC START
|
||||||
|
#=================================================
|
||||||
|
# IMPORT GENERIC HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Source app helpers
|
source _common.sh
|
||||||
source .fonctions
|
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
# We check variables are not empty
|
#=================================================
|
||||||
CHECK_VAR "$app" "app name not set"
|
# LOAD SETTINGS
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||||
|
|
||||||
path=$(ynh_app_setting_get $app path)
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
domain=$(ynh_app_setting_get $app domain)
|
|
||||||
final_path=$(ynh_app_setting_get $app final_path)
|
|
||||||
finalnginxconf=$(ynh_app_setting_get $app finalnginxconf)
|
|
||||||
finalphpconf=$(ynh_app_setting_get $app finalphpconf)
|
|
||||||
calibre=$(ynh_app_setting_get $app calibre)
|
|
||||||
basicauthcreate=$(ynh_app_setting_get $app basicauthcreate)
|
|
||||||
|
|
||||||
# We check that calibre path is correct
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
CHECK_CALIBRE
|
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||||
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
|
language=$(ynh_app_setting_get --app=$app --key=language)
|
||||||
|
calibre_dir=$(ynh_app_setting_get --app=$app --key=calibre_dir)
|
||||||
|
timezone="$(cat /etc/timezone)"
|
||||||
|
|
||||||
# Install dependencies using Helpers
|
#=================================================
|
||||||
ynh_package_install_from_equivs ../conf/cops-deps.control \
|
# CHECK VERSION
|
||||||
|| ynh_die "Unable to install dependencies"
|
#=================================================
|
||||||
|
|
||||||
# Removal of old folder and restart from fresh
|
upgrade_type=$(ynh_check_app_version_changed)
|
||||||
SECURE_REMOVE '$final_path'
|
|
||||||
sudo mkdir -p $final_path
|
|
||||||
|
|
||||||
# We download the sources and check the md5sum
|
#=================================================
|
||||||
cops_file=`sudo cat ../sources/source_file`;
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||||
sudo wget -nv -i ../sources/source_url -O $cops_file
|
#=================================================
|
||||||
sudo md5sum -c ../sources/source_md5 --status || (echo "Corrupt source" >&2 && false)
|
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1
|
||||||
sudo unzip ${cops_file} -d $final_path
|
|
||||||
|
|
||||||
# Site adjustments
|
# Backup the current version of the app
|
||||||
sed -i "s@CALIBRETOCHANGE@$calibre@g" ../conf/config_local.php
|
ynh_backup_before_upgrade
|
||||||
timezone=`sudo cat /etc/timezone`;
|
ynh_clean_setup () {
|
||||||
sed -i "s@TIMEZONETOCHANGE@$timezone@g" ../conf/config_local.php
|
# Restore it if the upgrade fails
|
||||||
|
ynh_restore_upgradebackup
|
||||||
sudo cp ../conf/config_local.php $final_path
|
|
||||||
sudo cp ../conf/robots.txt $final_path
|
|
||||||
|
|
||||||
# Create cops user and join nextcloud/owncloud/www-data groups
|
|
||||||
runninguser="${app}-ynh"
|
|
||||||
# 1. Create the user
|
|
||||||
# Create a system account for COPS if it doesn't already exists
|
|
||||||
if ! ynh_system_user_exists "$runninguser" ;
|
|
||||||
then
|
|
||||||
echo "The user $runninguser does not exist, we can create it"
|
|
||||||
sudo useradd -c "$runninguser system account" \
|
|
||||||
-d $final_path --system --user-group $runninguser \
|
|
||||||
|| ynh_die "Unable to create $runninguser system account"
|
|
||||||
else
|
|
||||||
echo "The user $runninguser exists, no need to create it"
|
|
||||||
fi
|
|
||||||
|
|
||||||
ynh_app_setting_set "$app" runninguser "$runninguser"
|
|
||||||
|
|
||||||
# 2. Add cops-ynh to groups www-data and nextcloud/owncloud if they exist
|
|
||||||
sudo usermod -a -G www-data $runninguser
|
|
||||||
for filesharing in "nextcloud" "owncloud"; do
|
|
||||||
app_id=$(sudo yunohost app list --installed -f "$filesharing" \
|
|
||||||
--output-as json | grep -Po '"id":[ ]?"\K.*?(?=")' | head -1)
|
|
||||||
[[ -z "$app_id" ]] || {
|
|
||||||
sudo usermod -a -G $filesharing $runninguser
|
|
||||||
}
|
}
|
||||||
done
|
# Exit if an error occurs during the execution of the script
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
# Set permissions
|
#=================================================
|
||||||
sudo chmod ug+rw -R $final_path
|
# STANDARD UPGRADE STEPS
|
||||||
sudo chown -hR $runninguser:$runninguser $final_path
|
#=================================================
|
||||||
|
# STOP SYSTEMD SERVICE
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Stopping a systemd service..." --weight=1
|
||||||
|
|
||||||
# Add basic auth if requested
|
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
|
||||||
if [ "$basicauthcreate" = "Yes" ];
|
|
||||||
then
|
|
||||||
basicauthname=$(ynh_app_setting_get $app basicauthname)
|
|
||||||
basicauthpass=$(ynh_app_setting_get $app basicauthpass)
|
|
||||||
|
|
||||||
# Generation of the htpasswd file according https://www.nginx.com/resources/wiki/community/faq/
|
#=================================================
|
||||||
SALT="$(openssl rand -base64 3)"
|
# ENSURE DOWNWARD COMPATIBILITY
|
||||||
(SHA1=$(printf "$basicauthpass$SALT" |
|
#=================================================
|
||||||
openssl dgst -binary -sha1 | xxd -ps |
|
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
||||||
sed 's#$#'"`echo -n $SALT | xxd -ps`"'#' |
|
|
||||||
xxd -r -ps |
|
|
||||||
base64);printf "$basicauthname:{SSHA}$SHA1\n" >> ../sources/htpasswd)
|
|
||||||
sudo cp ../sources/htpasswd $final_path
|
|
||||||
sudo chmod 440 $final_path/htpasswd
|
|
||||||
sudo chown www-data:www-data $final_path/htpasswd
|
|
||||||
|
|
||||||
# Modif nginx
|
if [ ! -e "$calibre_dir" ]; then
|
||||||
sed -i "s|^.*\bauth_basic\b.*$| auth_basic \"Private Library\";|" ../conf/nginx.conf;
|
ynh_print_info "Create calibre library folder $calibre_dir"
|
||||||
sed -i "s|^.*\bauth_basic_user_file\b.*$| auth_basic_user_file $final_path/htpasswd;|" ../conf/nginx.conf;
|
ynh_multimedia_build_main_dir
|
||||||
else
|
ynh_multimedia_addaccess $app
|
||||||
echo "No basic auth";
|
calibre_dir=/home/yunohost.multimedia/share/eBook
|
||||||
|
chown -R $app:www-data $calibre_dir
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Modify Nginx configuration file and copy it to Nginx conf.d directory
|
#Check if metadata.db file exists. If not create it (empty library)
|
||||||
sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf
|
if [ ! -e "$calibre_dir"/metadata.db ]; then
|
||||||
sed -i "s@ALIASTOCHANGE@$final_path/@g" ../conf/nginx.conf
|
cp -a ../conf/metadata.db.empty $calibre_dir/metadata.db
|
||||||
sed -i "s@NAMETOCHANGE@$app@g" ../conf/nginx.conf
|
chown $app:www-data $calibre_dir/*
|
||||||
sudo cp ../conf/nginx.conf $finalnginxconf
|
|
||||||
|
|
||||||
# Modify php-fpm configuration file and copy it to php-fpm pool.d directory
|
|
||||||
sed -i "s@NAMETOCHANGE@$app@g" ../conf/php-fpm.conf
|
|
||||||
sed -i "s@FOLDERTOCHANGE@$final_path@g" ../conf/php-fpm.conf
|
|
||||||
sed -i "s@USERTOCHANGE@$runninguser@g" ../conf/php-fpm.conf
|
|
||||||
sudo cp ../conf/php-fpm.conf $finalphpconf
|
|
||||||
sudo chown root: $finalphpconf
|
|
||||||
sudo chmod 644 $finalphpconf
|
|
||||||
|
|
||||||
# Make app public if necessary
|
|
||||||
is_public=$(ynh_app_setting_get $app is_public)
|
|
||||||
if [ "$is_public" = "Yes" ];
|
|
||||||
then
|
|
||||||
ynh_app_setting_set $app skipped_uris "/"
|
|
||||||
else
|
|
||||||
ynh_app_setting_set $app protected_uris "/"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Reload Nginx and regenerate SSOwat conf
|
# Cleaning legacy permissions
|
||||||
sudo service php5-fpm reload
|
if ynh_legacy_permissions_exists; then
|
||||||
sudo service nginx reload
|
ynh_legacy_permissions_delete_all
|
||||||
sudo yunohost app ssowatconf
|
|
||||||
|
ynh_app_setting_delete --app=$app --key=is_public
|
||||||
|
fi
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CREATE DEDICATED USER
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
|
||||||
|
|
||||||
|
# Create a dedicated user (if not existing)
|
||||||
|
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||||
|
then
|
||||||
|
ynh_script_progression --message="Upgrading source files..." --weight=1
|
||||||
|
|
||||||
|
# Download, check integrity, uncompress and patch the source from app.src
|
||||||
|
ynh_setup_source --dest_dir="$final_path"
|
||||||
|
fi
|
||||||
|
|
||||||
|
chmod 750 "$final_path"
|
||||||
|
chmod -R o-rwx "$final_path"
|
||||||
|
chown -R $app:www-data "$final_path"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# NGINX CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
|
||||||
|
|
||||||
|
# Create a dedicated NGINX config
|
||||||
|
ynh_add_nginx_config
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# UPGRADE DEPENDENCIES
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Upgrading dependencies..." --weight=1
|
||||||
|
|
||||||
|
ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# PHP-FPM CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=1
|
||||||
|
|
||||||
|
# Create a dedicated PHP-FPM config
|
||||||
|
ynh_add_fpm_config
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RESTORE THE DATA DIRECTORY
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Creating a calibre directory..." --weight=1
|
||||||
|
|
||||||
|
#build multimedia directory
|
||||||
|
ynh_multimedia_build_main_dir
|
||||||
|
ynh_multimedia_addaccess $app
|
||||||
|
|
||||||
|
calibre_dir="/home/yunohost.multimedia/share/eBook"
|
||||||
|
ynh_app_setting_set --app=$app --key=calibre_dir --value=$calibre_dir
|
||||||
|
|
||||||
|
chmod 750 "$calibre_dir"
|
||||||
|
chmod -R o-rwx "$calibre_dir"
|
||||||
|
chown -R $app:www-data "$calibre_dir"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# UPDATE A CONFIG FILE
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Updating a configuration file..." --weight=1
|
||||||
|
|
||||||
|
ynh_add_config --template="../conf/config_local.php" --destination="$final_path/config_local.php"
|
||||||
|
|
||||||
|
chmod 400 "$final_path/config_local.php"
|
||||||
|
chown $app "$final_path/config_local.php"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RELOAD NGINX
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
||||||
|
|
||||||
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Upgrade of $app completed" --last
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
cops-1.0.1.zip
|
|
|
@ -1 +0,0 @@
|
||||||
a688dfd66d31674637106f8430ca1103 cops-1.0.1.zip
|
|
|
@ -1 +0,0 @@
|
||||||
https://github.com/seblucas/cops/releases/download/1.0.1/cops-1.0.1.zip
|
|
Loading…
Reference in a new issue