1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/yourls_ynh.git synced 2024-09-03 20:35:59 +02:00

Merge pull request #22 from YunoHost-Apps/testing

Testing
This commit is contained in:
Éric Gaspar 2022-03-01 12:30:48 +01:00 committed by GitHub
commit 8e85ca05da
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 627 additions and 425 deletions

55
.github/ISSUE_TEMPLATE.md vendored Normal file
View file

@ -0,0 +1,55 @@
---
name: Bug report
about: When creating a bug report, please use the following template to provide all the relevant information and help debugging efficiently.
---
**How to post a meaningful bug report**
1. *Read this whole template first.*
2. *Determine if you are on the right place:*
- *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change_url...), you are on the right place!*
- *Otherwise, the issue may be due to the app itself. Refer to its documentation or repository for help.*
- *When in doubt, post here and we will figure it out together.*
3. *Delete the italic comments as you write over them below, and remove this guide.*
---
### Describe the bug
*A clear and concise description of what the bug is.*
### Context
- Hardware: *VPS bought online / Old laptop or computer / Raspberry Pi at home / Internet Cube with VPN / Other ARM board / ...*
- YunoHost version: x.x.x
- I have access to my server: *Through SSH | through the webadmin | direct access via keyboard / screen | ...*
- Are you in a special context or did you perform some particular tweaking on your YunoHost instance?: *no / yes*
- If yes, please explain:
- Using, or trying to install package version/branch:
- If upgrading, current package version: *can be found in the admin, or with `yunohost app info $app_id`*
### Steps to reproduce
- *If you performed a command from the CLI, the command itself is enough. For example:*
```sh
sudo yunohost app install the_app
```
- *If you used the webadmin, please perform the equivalent command from the CLI first.*
- *If the error occurs in your browser, explain what you did:*
1. *Go to '...'*
2. *Click on '...'*
3. *Scroll down to '...'*
4. *See error*
### Expected behavior
*A clear and concise description of what you expected to happen. You can remove this section if the command above is enough to understand your intent.*
### Logs
*When an operation fails, YunoHost provides a simple way to share the logs.*
- *In the webadmin, the error message contains a link to the relevant log page. On that page, you will be able to 'Share with Yunopaste'. If you missed it, the logs of previous operations are also available under Tools > Logs.*
- *In command line, the command to share the logs is displayed at the end of the operation and looks like `yunohost log display [log name] --share`. If you missed it, you can find the log ID of a previous operation using `yunohost log list`.*
*After sharing the log, please copypaste directly the link provided by YunoHost (to help readability, no need to copypaste the entire content of the log here, just the link is enough...)*
*If applicable and useful, add screenshots to help explain your problem.*

16
.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View file

@ -0,0 +1,16 @@
## Problem
- *Description of why you made this PR*
## Solution
- *And how do you fix that problem*
## PR Status
- [ ] Code finished and ready to be reviewed/tested
- [ ] The fix/enhancement were manually tested (if applicable)
## Automatic tests
Automatic tests can be triggered on https://ci-apps-dev.yunohost.org/ *after creating the PR*, by commenting "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!". (N.B. : for this to work you need to be a member of the Yunohost-Apps organization)

View file

@ -1,63 +1,49 @@
# YOURLS for YunoHost
<!--
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.
-->
# Yourls for YunoHost
[![Integration level](https://dash.yunohost.org/integration/yourls.svg)](https://dash.yunohost.org/appci/app/yourls) ![](https://ci-apps.yunohost.org/ci/badges/yourls.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/yourls.maintain.svg)
[![Install YOURLS with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=yourls)
[![Install Yourls with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=yourls)
*[Lire ce readme en français.](./README_fr.md)*
> *This package allows you to install YOURLS quickly and simply on a YunoHost server.
> *This package allows you to install Yourls quickly and simply on a YunoHost server.
If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.*
## Overview
YOURLS stands for Your Own URL Shortener. It is a small set of PHP scripts that will allow you to run your own URL shortening service (a la TinyURL or bitly).
**Shipped version:** 1.8.1
Running your own URL shortener is fun, geeky and useful: you own your data and don't depend on third-party services. It's also a great way to add branding to your short URLs, instead of using the same public URL shortener everyone uses.
### YOURLS Features
- Private (your links only) or Public (everybody can create short links, fine for an intranet)
- Dozens of plugins to easily implement new features
- Handy bookmarklets to easily shorten and share links
- Awesome stats: historical click reports, referrers tracking, visitors geo-location
- Developer API to integrate YOURLS into other applications
- Sample files to create your own public interface
**Shipped version:** 1.8.2~ynh1
**Demo:** https://yourls.org/cookie+
## Screenshots
![](https://yourls.org/images/stats-anim.gif)
![](./doc/screenshots/p4.png)
## Demo
## Documentation and resources
* [Official demo](https://yourls.org/cookie+)
## Configuration
How to configure this app: From an admin panel, a plain file with SSH, or any other way.
## Documentation
* Official documentation: Link to the official documentation of this app
* YunoHost documentation: If specific documentation is needed, feel free to contribute.
## YunoHost specific features
#### Multi-user support
* Are LDAP and HTTP auth supported?
* Can the app be used by multiple users?
#### Supported architectures
* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/yourls%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/yourls/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/yourls%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/yourls/)
## Limitations
* Any known limitations.
## Additional information
* Other info you would like to add about this app.
## Links
* Report a bug: https://github.com/YunoHost-Apps/yourls_ynh/issues
* App website: https://yourls.org/
* Upstream app repository: https://github.com/YOURLS/YOURLS
* YunoHost website: https://yunohost.org/
---
* Official app website: https://yourls.org/
* Official admin documentation: https://github.com/YOURLS/YOURLS/wiki
* Upstream app code repository: https://github.com/YOURLS/YOURLS
* YunoHost documentation for this app: https://yunohost.org/app_yourls
* Report a bug: https://github.com/YunoHost-Apps/yourls_ynh/issues
## Developer info
@ -69,3 +55,5 @@ sudo yunohost app install https://github.com/YunoHost-Apps/yourls_ynh/tree/testi
or
sudo yunohost app upgrade yourls -u https://github.com/YunoHost-Apps/yourls_ynh/tree/testing --debug
```
**More info regarding app packaging:** https://yunohost.org/packaging_apps

View file

@ -1,63 +1,45 @@
# YOURLS pour YunoHost
# Yourls pour YunoHost
[![Niveau d'intégration](https://dash.yunohost.org/integration/yourls.svg)](https://dash.yunohost.org/appci/app/yourls) ![](https://ci-apps.yunohost.org/ci/badges/yourls.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/yourls.maintain.svg)
[![Installer YOURLS avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=yourls)
[![Installer Yourls avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=yourls)
*[Read this readme in english.](./README.md)*
*[Read this readme in english.](./README.md)*
*[Lire ce readme en français.](./README_fr.md)*
> *Ce package vous permet d'installer YOURLS rapidement et simplement sur un serveur YunoHost.
Si vous n'avez pas YunoHost, consultez [le guide](https://yunohost.org/#/install) pour apprendre comment l'installer.*
> *Ce package vous permet d'installer Yourls 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
YOURLS signifie Your Own URL Shortener. C'est un petit ensemble de scripts PHP qui vous permettront d'exécuter votre propre service de raccourcissement d'URL (à la TinyURL ou bitly).
**Version incluse :** 1.8.1
YOURLS stands for Your Own URL Shortener. It is a small set of PHP scripts that will allow you to run your own URL shortening service (a la TinyURL or bitly).
Running your own URL shortener is fun, geeky and useful: you own your data and don't depend on third-party services. It's also a great way to add branding to your short URLs, instead of using the same public URL shortener everyone uses.
### YOURLS Features
- Private (your links only) or Public (everybody can create short links, fine for an intranet)
- Dozens of plugins to easily implement new features
- Handy bookmarklets to easily shorten and share links
- Awesome stats: historical click reports, referrers tracking, visitors geo-location
- Developer API to integrate YOURLS into other applications
- Sample files to create your own public interface
**Version incluse :** 1.8.2~ynh1
**Démo :** https://yourls.org/cookie+
## Captures d'écran
![](https://yourls.org/images/stats-anim.gif)
![](./doc/screenshots/p4.png)
## Démo
## Documentations et ressources
* [Official demo](https://yourls.org/cookie+)
## Configuration
How to configure this app: From an admin panel, a plain file with SSH, or any other way.
## Documentation
* Documentation officielle : Lien vers la documentation officielle de cette application.
* Documentation YunoHost : Si une documentation spécifique est nécessaire, n'hésitez pas à contribuer.
## Caractéristiques spécifiques YunoHost
#### Support multi-utilisateur
* L'authentification LDAP et HTTP est-elle prise en charge ?
* L'application peut-elle être utilisée par plusieurs utilisateurs ?
#### Architectures supportées
* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/yourls%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/yourls/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/yourls%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/yourls/)
## Limitations
* Limitations connues.
## Informations additionnelles
* Autres informations que vous souhaitez ajouter sur cette application.
## Links
* Signaler un bug : https://github.com/YunoHost-Apps/yourls_ynh/issues
* Site de l'application : https://yourls.org/
* Dépôt de l'application principale : https://github.com/YOURLS/YOURLS
* Site web YunoHost : https://yunohost.org/
---
* Site officiel de l'app : https://yourls.org/
* Documentation officielle de l'admin : https://github.com/YOURLS/YOURLS/wiki
* Dépôt de code officiel de l'app : https://github.com/YOURLS/YOURLS
* Documentation YunoHost pour cette app : https://yunohost.org/app_yourls
* Signaler un bug : https://github.com/YunoHost-Apps/yourls_ynh/issues
## Informations pour les développeurs
@ -66,6 +48,8 @@ Merci de faire vos pull request sur la [branche testing](https://github.com/Yuno
Pour essayer la branche testing, procédez comme suit.
```
sudo yunohost app install https://github.com/YunoHost-Apps/yourls_ynh/tree/testing --debug
or
ou
sudo yunohost app upgrade yourls -u https://github.com/YunoHost-Apps/yourls_ynh/tree/testing --debug
```
**Plus d'infos sur le packaging d'applications :** https://yunohost.org/packaging_apps

View file

@ -1,13 +1,10 @@
# See here for more informations
# https://github.com/YunoHost/package_check#syntax-check_process-file
# Move this file from check_process.default to check_process when you have filled it.
;; Test complet
; Manifest
domain="domain.tld" (DOMAIN)
path="/path" (PATH)
admin="john" (USER)
domain="domain.tld"
path="/path"
admin="john"
language="fr_FR"
password="1Strong-Password"
; Checks
pkg_linter=1
setup_sub_dir=1
@ -16,10 +13,14 @@
setup_private=0
setup_public=1
upgrade=1
upgrade=1 from_commit=455317a9e0a55ffb2cb80f79f2a2f56af4d3d671
backup_restore=1
multi_instance=1
port_already_use=0
change_url=0
change_url=1
;;; Options
Email=anmol@datamol.org
Notification=change
Email=
Notification=none
;;; Upgrade options
; commit=455317a9e0a55ffb2cb80f79f2a2f56af4d3d671
name=Merge pull request #17
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666&

View file

@ -1,3 +0,0 @@
INSERT INTO `yourls_options` ( `option_name`, `option_value`) VALUES
('active_plugins', 'a:1:{i:0;s:29:"yourls-ldap-plugin/plugin.php";}');

View file

@ -1,6 +1,5 @@
SOURCE_URL=https://github.com/YOURLS/YOURLS/archive/1.8.1.zip
SOURCE_SUM=c67eb7bf717de677d8a03d8be2cc0a505810252a75bcc00c3d6717c4d0ad7123
SOURCE_URL=https://github.com/YOURLS/YOURLS/archive/1.8.2.zip
SOURCE_SUM=155e3e223b698bd3d0ab3f90d988b51c74f727fd46db144ca950a693d5dedba6
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=

93
conf/config-sample.php Normal file
View file

@ -0,0 +1,93 @@
<?php
/* This is a sample config file.
* Edit this file with your own settings and save it as "config.php"
*
* IMPORTANT: edit and save this file as plain ASCII text, using a text editor, for instance TextEdit on Mac OS or
* Notepad on Windows. Make sure there is no character before the opening <?php at the beginning of this file.
*/
/*
** MySQL settings - You can get this info from your web host
*/
/** MySQL database username */
define( 'YOURLS_DB_USER', '__DB_USER__' );
/** MySQL database password */
define( 'YOURLS_DB_PASS', '__DB_PWD__' );
/** The name of the database for YOURLS
** Use lower case letters [a-z], digits [0-9] and underscores [_] only */
define( 'YOURLS_DB_NAME', '__DB_NAME__' );
/** MySQL hostname.
** If using a non standard port, specify it like 'hostname:port', e.g. 'localhost:9999' or '127.0.0.1:666' */
define( 'YOURLS_DB_HOST', 'localhost' );
/** MySQL tables prefix
** YOURLS will create tables using this prefix (eg `yourls_url`, `yourls_options`, ...)
** Use lower case letters [a-z], digits [0-9] and underscores [_] only */
define( 'YOURLS_DB_PREFIX', 'yourls_' );
/*
** Site options
*/
/** YOURLS installation URL
** All lowercase, no trailing slash at the end.
** If you define it to "http://sho.rt", don't use "http://www.sho.rt" in your browser (and vice-versa)
** To use an IDN domain (eg http://héhé.com), write its ascii form here (eg http://xn--hh-bjab.com) */
define( 'YOURLS_SITE', 'http://__DOMAIN____PATH__' );
define('YOURLS_ADMIN_SSL', true);
/** YOURLS language
** Change this setting to use a translation file for your language, instead of the default English.
** That translation file (a .mo file) must be installed in the user/language directory.
** See http://yourls.org/translations for more information */
define( 'YOURLS_LANG', '__LANGUAGE__' );
/** Allow multiple short URLs for a same long URL
** Set to true to have only one pair of shortURL/longURL (default YOURLS behavior)
** Set to false to allow multiple short URLs pointing to the same long URL (bit.ly behavior) */
define( 'YOURLS_UNIQUE_URLS', true );
/** Private means the Admin area will be protected with login/pass as defined below.
** Set to false for public usage (eg on a restricted intranet or for test setups)
** Read http://yourls.org/privatepublic for more details if you're unsure */
define( 'YOURLS_PRIVATE', true );
/** A random secret hash used to encrypt cookies. You don't have to remember it, make it long and complicated
** Hint: copy from http://yourls.org/cookie */
define( 'YOURLS_COOKIEKEY', '__RANDOM__' );
/** Username(s) and password(s) allowed to access the site. Passwords either in plain text or as encrypted hashes
** YOURLS will auto encrypt plain text passwords in this file
** Read http://yourls.org/userpassword for more information */
$yourls_user_passwords = [
'__ADMIN__' => '__PASSWORD__',
// 'username2' => 'password2',
// You can have one or more 'login'=>'password' lines
];
/** URL shortening method: either 36 or 62
** 36: generates all lowercase keywords (ie: 13jkm)
** 62: generates mixed case keywords (ie: 13jKm or 13JKm)
** For more information, see https://yourls.org/urlconvert */
define( 'YOURLS_URL_CONVERT', 36 );
/** Debug mode to output some internal information
** Default is false for live site. Enable when coding or before submitting a new issue */
define( 'YOURLS_DEBUG', false );
/**
* Reserved keywords (so that generated URLs won't match them)
* Define here negative, unwanted or potentially misleading keywords.
*/
$yourls_reserved_URL = [
'porn', 'faggot', 'sex', 'nigger', 'fuck', 'cunt', 'dick',
];
/*
** Personal settings would go after here.
*/

View file

@ -1,93 +0,0 @@
<?php
/* This is a sample config file.
* Edit this file with your own settings and save it as "config.php"
*/
/*
** MySQL settings - You can get this info from your web host
*/
/** MySQL database username */
define('YOURLS_DB_USER', '__DB_NAME__');
/** MySQL database password */
define('YOURLS_DB_PASS', '__DB_PWD__');
/** The name of the database for YOURLS */
define('YOURLS_DB_NAME', '__DB_NAME__');
/** MySQL hostname.
** If using a non standard port, specify it like 'hostname:port', eg. 'localhost:9999' or '127.0.0.1:666' */
define('YOURLS_DB_HOST', 'localhost');
/** MySQL tables prefix */
define('YOURLS_DB_PREFIX', '__DB_NAME___');
/*
** Site options
*/
/** YOURLS installation URL -- all lowercase and with no trailing slash.
** If you define it to "http://site.com", don't use "http://www.site.com" in your browser (and vice-versa) */
define('YOURLS_SITE', 'https://__DOMAIN____PATH__');
/** Timezone GMT offset */
define('YOURLS_HOURS_OFFSET', 0);
/** YOURLS language or "locale".
** Change this setting to "localize" YOURLS (use a translation instead of the default English). A corresponding .mo file
** must be installed in the user/language directory.
** See http://yourls.org/translations for more information */
define('YOURLS_LANG', '');
/** Allow multiple short URLs for a same long URL
** Set to true to have only one pair of shortURL/longURL (default YOURLS behavior)
** Set to false to allow multiple short URLs pointing to the same long URL (bit.ly behavior) */
define('YOURLS_UNIQUE_URLS', true);
/** Private means the Admin area will be protected with login/pass as defined below.
** Set to false for public usage (eg on a restricted intranet or for test setups)
** Read http://yourls.org/privatepublic for more details if you're unsure */
define('YOURLS_PRIVATE', false);
/** A random secret hash used to encrypt cookies. You don't have to remember it, make it long and complicated. Hint: copy from http://yourls.org/cookie **/
define('YOURLS_COOKIEKEY', '__RANDOM__');
/** Username(s) and password(s) allowed to access the site. Passwords either in plain text or as encrypted hashes
** YOURLS will auto encrypt plain text passwords in this file
** Read http://yourls.org/userpassword for more information */
$yourls_user_passwords = array();
/** Debug mode to output some internal information
** Default is false for live site. Enable when coding or before submitting a new issue */
define('YOURLS_DEBUG', false);
/*
** URL Shortening settings
*/
/** URL shortening method: 36 or 62 */
define('YOURLS_URL_CONVERT', 36);
/*
* 36: generates all lowercase keywords (ie: 13jkm)
* 62: generates mixed case keywords (ie: 13jKm or 13JKm)
* Stick to one setting. It's best not to change after you've started creating links.
*/
/**
* Reserved keywords (so that generated URLs won't match them)
* Define here negative, unwanted or potentially misleading keywords.
*/
$yourls_reserved_URL = array(
'porn', 'faggot', 'sex', 'nigger', 'fuck', 'cunt', 'dick', 'gay',
);
/*
** Personal settings would go after here.
*/
//define( 'LDAPAUTH_HOST', 'localhost' );
//define( 'LDAPAUTH_PORT', '389' );
//define( 'LDAPAUTH_BASE', 'dc=yunohost,dc=org' );
//define( 'LDAPAUTH_USERNAME_FIELD', 'uid');
require_once(dirname(__DIR__) . '/includes/functions-auth.php');

5
conf/fr.src Normal file
View file

@ -0,0 +1,5 @@
SOURCE_URL=https://github.com/ozh/YOURLS-fr_FR/archive/refs/tags/1.8.zip
SOURCE_SUM=ef9c0e71d4559994b9df0cd0a558f6faf11eba185c4793ba0e30f3500dab1b04
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=true

View file

@ -2,16 +2,13 @@
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title></title>
<title>YOURLS Your Own URL Shortener</title>
<link rel="stylesheet" href="css/style.css"/>
</head>
<body>
<div id="wrap">
<div id="login">
<p><img src="images/yourls-logo.png" alt=""></p>
<p><a href="admin">Admin page</a></p>
</div>
</div>
<p><a href="admin">Administration interface</a></p>
</div>
</body>
</html>

View file

@ -1,26 +1,22 @@
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
location __PATH__/ {
# Path to source
alias __FINALPATH__/;
# Force usage of https
if ($scheme = http) {
rewrite ^ https://$server_name$request_uri? permanent;
}
try_files $uri $uri/ __FINALPATH__/yourls-loader.php;
index index.php index.html index.htm;
try_files $uri $uri/ __PATH__/yourls-loader.php;
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_pass unix:/var/run/php__PHPVERSION__-fpm-__NAME__.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param REMOTE_USER $remote_user;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param REMOTE_USER $remote_user;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $request_filename;
}
# Include SSOWAT user panel.

View file

@ -1,10 +1,11 @@
; 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)
[__NAMETOCHANGE__]
; Per pool prefix
; It only applies on the following directives:
; - 'access.log'
; - 'slowlog'
; - 'listen' (unixsocket)
; - 'chroot'
@ -24,28 +25,35 @@ group = __USER__
; The address on which to accept FastCGI requests.
; 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;
; 'port' - to listen on a TCP socket to all addresses on a
; specific port;
; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
; 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.
; Note: This value is mandatory.
listen = /var/run/php__PHPVERSION__-fpm-__NAMETOCHANGE__.sock
listen = /var/run/php/php__PHPVERSION__-fpm-__NAMETOCHANGE__.sock
; Set listen(2) backlog. A value of '-1' means unlimited.
; Default Value: 128 (-1 on FreeBSD and OpenBSD)
;listen.backlog = 128
; Set listen(2) backlog.
; Default Value: 511 (-1 on FreeBSD and OpenBSD)
;listen.backlog = 511
; 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.
; 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
; List of ipv4 addresses of FastCGI clients which are allowed to connect.
; 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
; 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
@ -59,7 +67,13 @@ listen.group = www-data
; - The pool processes will inherit the master process priority
; unless it specified otherwise
; Default Value: no set
; priority = -19
; process.priority = -19
; Set the process dumpable flag (PR_SET_DUMPABLE prctl) even if the process user
; or group is differrent than the master process user. It allows to create process
; core dump and ptrace the process for the pool user.
; Default Value: no
; process.dumpable = yes
; Choose how the process manager will control the number of child processes.
; Possible Values:
@ -96,7 +110,7 @@ pm = 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.
pm.max_children = 10
pm.max_children = 5
; The number of child processes created on startup.
; Note: Used only when pm is set to 'dynamic'
@ -117,12 +131,12 @@ pm.max_spare_servers = 3
; 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.
; 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.
; 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
; recognized as a status page. It shows the following informations:
@ -170,7 +184,7 @@ pm.max_requests = 500
;
; By default the status page only outputs short status. Passing 'full' in the
; query string will also return status for each pool process.
; Example:
; Example:
; http://www.foo.bar/status?full
; http://www.foo.bar/status?json&full
; http://www.foo.bar/status?html&full
@ -215,7 +229,7 @@ pm.max_requests = 500
; last request memory: 0
;
; Note: There is a real-time FPM status monitoring sample web page available
; It's available in: ${prefix}/share/fpm/status.html
; 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
; anything, but it may not be a good idea to use the .php extension or it
@ -275,7 +289,7 @@ pm.max_requests = 500
; - %{megabytes}M
; - %{mega}M
; %n: pool name
; %o: ouput header
; %o: output header
; it must be associated with embraces to specify the name of the header:
; - %{Content-Type}o
; - %{X-Powered-By}o
@ -283,7 +297,7 @@ pm.max_requests = 500
; - ....
; %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 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
@ -291,47 +305,51 @@ pm.max_requests = 500
; %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 = /var/log/nginx/__NAMETOCHANGE__.slow.log
;slowlog = log/$pool.log.slow
; 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'.
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0
request_slowlog_timeout = 5s
;request_slowlog_timeout = 0
; The timeout for serving a single request after which the worker process will
; be killed. This option should be used when the 'max_execution_time' ini option
; does not stop script execution for some reason. A value of '0' means 'off'.
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0
request_terminate_timeout = 1d
; Set open file descriptor rlimit.
; Default Value: system defined value
;rlimit_files = 1024
; Set max core size rlimit.
; Possible Values: 'unlimited' or an integer greater or equal to 0
; Default Value: system defined value
;rlimit_core = 0
; 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.
; Note: you can prefix with '$prefix' to chroot to the pool prefix or one
; of its subdirectories. If the pool prefix is not set, the global prefix
; will be used instead.
; Note: chrooting is a great security feature and should be used whenever
; Note: chrooting is a great security feature and should be used whenever
; possible. However, all PHP paths will be relative to the chroot
; (error_log, sessions.save_path, ...).
; Default Value: not set
@ -347,16 +365,25 @@ chdir = __FINALPATH__
; Note: on highloaded environement, this can cause some delay in the page
; process time (several ms).
; 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
; exectute php code.
; execute php code.
; Note: set an empty value to allow all extensions.
; Default Value: .php
;security.limit_extensions = .php .php3 .php4 .php5
;security.limit_extensions = .php .php3 .php4 .php5 .php7
; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from
; the current environment.
; Default Value: clean env
@ -370,7 +397,7 @@ catch_workers_output = yes
; overwrite the values previously defined in the php.ini. The directives are the
; same as the PHP SAPI:
; php_value/php_flag - you can set classic ini defines which can
; be overwritten from PHP call 'ini_set'.
; be overwritten from PHP call 'ini_set'.
; php_admin_value/php_admin_flag - these directives won't be overwritten by
; PHP call 'ini_set'
; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no.
@ -391,14 +418,13 @@ catch_workers_output = yes
;php_admin_flag[log_errors] = on
;php_admin_value[memory_limit] = 32M
; Common values to change to increase file upload limit
; upload_max_filesize = 50M
; post_max_size = 50M
; mail.add_x_header = Off
; php_admin_value[upload_max_filesize] = 50M
; php_admin_value[post_max_size] = 50M
; php_admin_flag[mail.add_x_header] = Off
; Other common parameters
; max_execution_time = 600
; max_input_time = 300
; memory_limit = 256M
; short_open_tag = On
; 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

View file

@ -1,8 +0,0 @@
import json
with open("/etc/ssowat/conf.json.persistent", "r", encoding='utf-8') as jsonFile:
data = json.load(jsonFile)
data["protected_urls"].remove("__DOMAIN____PATH__/admin")
with open("/etc/ssowat/conf.json.persistent", "w", encoding='utf-8') as jsonFile:
jsonFile.write(json.dumps(data, indent=4, sort_keys=True))

12
doc/DESCRIPTION.md Normal file
View file

@ -0,0 +1,12 @@
YOURLS stands for Your Own URL Shortener. It is a small set of PHP scripts that will allow you to run your own URL shortening service (a la TinyURL or bitly).
Running your own URL shortener is fun, geeky and useful: you own your data and don't depend on third-party services. It's also a great way to add branding to your short URLs, instead of using the same public URL shortener everyone uses.
### YOURLS Features
- Private (your links only) or Public (everybody can create short links, fine for an intranet)
- Dozens of plugins to easily implement new features
- Handy bookmarklets to easily shorten and share links
- Awesome stats: historical click reports, referrers tracking, visitors geo-location
- Developer API to integrate YOURLS into other applications
- Sample files to create your own public interface

0
doc/DISCLAIMER.md Normal file
View file

BIN
doc/screenshots/p4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 KiB

View file

@ -6,34 +6,39 @@
"en": "URL shortening service",
"fr": "Service de raccourcisseur d'URL"
},
"version": "1.8.1~ynh1",
"url": "https://github.com/YOURLS/YOURLS",
"version": "1.8.2~ynh1",
"url": "https://yourls.org/",
"upstream": {
"license": "MIT",
"website": "https://yourls.org/",
"demo": "https://yourls.org/cookie+",
"admindoc": "https://github.com/YOURLS/YOURLS/wiki",
"code": "https://github.com/YOURLS/YOURLS"
},
"license": "MIT",
"maintainer": {
"name": "Anmol Sharma",
"email": "anmol@datamol.org",
"url": ""
},
"requirements": {
"yunohost": ">= 4.1.7"
"email": "anmol@datamol.org"
},
"previous_maintainers": {
"name": "courgette",
"email": "courgette@farcie.fr",
"url": "http://thomaslebeau.fr"
},
"requirements": {
"yunohost": ">= 4.3.0"
},
"multi_instance": true,
"services": [
"nginx",
"php7.3-fpm",
"php7.4-fpm",
"mysql"
],
"arguments": {
"install" : [
{
"name": "domain",
"type": "domain",
"example": "domain.org"
"type": "domain"
},
{
"name": "path",
@ -43,8 +48,21 @@
},
{
"name": "admin",
"type": "user",
"example": "johndoe"
"type": "user"
},
{
"name": "password",
"type": "password"
},
{
"name": "language",
"type": "string",
"ask": {
"en": "Choose the application language",
"fr": "Choisissez la langue de l'application"
},
"choices": ["fr_FR", "en_US"],
"default": "fr_FR"
}
]
}

View file

@ -4,10 +4,10 @@
# COMMON VARIABLES
#=================================================
YNH_PHP_VERSION="7.3"
YNH_PHP_VERSION="7.4"
# dependencies used by the app
extra_php_dependencies="php${YNH_PHP_VERSION}-gmp php${YNH_PHP_VERSION}-bcmath php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-cli php${YNH_PHP_VERSION}-json php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-xml php-pear"
pkg_dependencies="php${YNH_PHP_VERSION}-gmp php${YNH_PHP_VERSION}-bcmath php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-json php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-xml"
#=================================================
# PERSONAL HELPERS

View file

@ -63,4 +63,4 @@ ynh_mysql_dump_db --database="$db_name" > db.sql
# END OF SCRIPT
#=================================================
ynh_print_info --message="Backup script completed for YOURLS. (YunoHost will then actually copy those files to the archive)."
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

123
scripts/change_url Normal file
View file

@ -0,0 +1,123 @@
#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# RETRIEVE ARGUMENTS
#=================================================
old_domain=$YNH_APP_OLD_DOMAIN
old_path=$YNH_APP_OLD_PATH
new_domain=$YNH_APP_NEW_DOMAIN
new_path=$YNH_APP_NEW_PATH
app=$YNH_APP_INSTANCE_NAME
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
admin=$(ynh_app_setting_get --app=$app --key=admin)
random=$(ynh_app_setting_get --app=$app --key=random)
password=$(ynh_app_setting_get --app=$app --key=password)
language=$(ynh_app_setting_get --app=$app --key=language)
#=================================================
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# CHECK WHICH PARTS SHOULD BE CHANGED
#=================================================
change_domain=0
if [ "$old_domain" != "$new_domain" ]
then
change_domain=1
fi
change_path=0
if [ "$old_path" != "$new_path" ]
then
change_path=1
fi
#=================================================
# MODIFY URL IN NGINX CONF
#=================================================
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
# Change the path in the NGINX config file
if [ $change_path -eq 1 ]
then
# Make a backup of the original NGINX config file if modified
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
# Set global variables for NGINX helper
domain="$old_domain"
path_url="$new_path"
# Create a dedicated NGINX config
ynh_add_nginx_config
fi
# Change the domain for NGINX
if [ $change_domain -eq 1 ]
then
# Delete file checksum for the old conf file location
ynh_delete_file_checksum --file="$nginx_conf_path"
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
# Store file checksum for the new config file location
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
fi
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=1
domain=$new_domain
path=$new_path
ynh_add_config --template="../conf/config-sample.php" --destination="$final_path/user/config.php"
chmod 600 "$final_path/user/config.php"
chown $app:$app "$final_path/user/config.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="Change of URL completed for $app" --last

View file

@ -26,6 +26,10 @@ ynh_abort_if_errors
domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH
admin=$YNH_APP_ARG_ADMIN
password="$YNH_APP_ARG_PASSWORD"
random=$(ynh_string_random --length=24)
language=$YNH_APP_ARG_LANGUAGE
phpversion=$YNH_PHP_VERSION
app=$YNH_APP_INSTANCE_NAME
@ -48,6 +52,24 @@ ynh_script_progression --message="Storing installation settings..." --weight=1
ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url
ynh_app_setting_set --app=$app --key=admin --value=$admin
ynh_app_setting_set --app=$app --key=random --value=$random
ynh_app_setting_set --app=$app --key=language --value=$language
ynh_app_setting_set --app=$app --key=password --value="$password"
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..." --weight=1
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --weight=1
# Create a system user
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# CREATE A MYSQL DATABASE
@ -68,82 +90,72 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path"
# Install French language
ynh_setup_source --dest_dir="$final_path/user/languages" --source_id="fr"
# copy index file
cp ../conf/index.php $final_path/
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring NGINX web server..." --weight=2
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --weight=1
# Create a system user
ynh_system_user_create --username=$app
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring PHP-FPM..." --weight=2
# Create a dedicated php-fpm config
ynh_add_fpm_config --package="$extra_php_dependencies"
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
# copy index file
cp ../conf/index.php $final_path/
# Create a dedicated PHP-FPM config
ynh_add_fpm_config
#=================================================
# MODIFY A CONFIG FILE
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=1
cp ../conf/config.php $final_path/user/config.php
ynh_add_config --template="../conf/config-sample.php" --destination="$final_path/user/config.php"
ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$final_path/user/config.php"
ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$final_path/user/config.php"
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/user/config.php"
ynh_replace_string --match_string="__PATH__" --replace_string="${path_url%/}" --target_file="$final_path/user/config.php"
ynh_replace_string --match_string="__RANDOM__" --replace_string="$(ynh_string_random 24)" --target_file="$final_path/user/config.php"
# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum "$final_path/user/config.php"
chmod 600 "$final_path/user/config.php"
chown $app:$app "$final_path/user/config.php"
#=================================================
# SECURE FILES AND DIRECTORIES
# SETUP APPLICATION WITH CURL
#=================================================
chown -R $app: $final_path
chmod 600 $final_path/user/config.php
# Set the app as temporarily public for curl call
ynh_script_progression --message="Configuring SSOwat..." --weight=1
# Making the app public for curl
ynh_permission_update --permission="main" --add="visitors"
# Installation with curl
ynh_script_progression --message="Finalizing installation..." --weight=1
ynh_local_curl "admin/install.php" "install=dummy"
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Configuring permissions..." --time --weight=1
ynh_script_progression --message="Configuring permissions..." --weight=1
# unprotected_uris allows SSO credentials to be passed anyway.
ynh_permission_update --permission="main" --add="visitors"
# Only the admin can access the admin panel of the app (if the app has an admin panel)
ynh_permission_create --permission="admin" --url="/admin" --allowed=$admin
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=3
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
sleep 10
# Start YOURLS install (database table creation)
ynh_local_curl "admin/install.php" "install=dummy"
sleep 10
#=================================================
# SETUP SSOWAT
#=================================================
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of YOURLS completed" --last
ynh_script_progression --message="Installation of $app completed" --last

View file

@ -18,6 +18,7 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
@ -31,14 +32,7 @@ ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
#=================================================
# REMOVE APP MAIN DIR
#=================================================
# Remove the protected_urls
python3 $final_path/remove_sso_conf.py
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_script_progression --message="Removing YOURLS main directory..." --weight=4
ynh_script_progression --message="Removing app main directory..." --weight=4
# Remove the app directory securely
ynh_secure_remove --file="$final_path"
@ -59,6 +53,14 @@ ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=2
# Remove the dedicated PHP-FPM config
ynh_remove_fpm_config
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=1
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#=================================================
# GENERIC FINALIZATION
#=================================================
@ -73,4 +75,4 @@ ynh_system_user_delete --username=$app
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Removal of YOURLS completed" --last
ynh_script_progression --message="Removal of $app completed" --last

View file

@ -38,41 +38,35 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#=================================================
ynh_script_progression --message="Validating restoration parameters..." --weight=1
ynh_webpath_available --domain=$domain --path_url=$path_url \
|| ynh_die --message="Path not available: ${domain}${path_url}"
test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path "
test ! -d $final_path || ynh_die --message="There is already a directory: $final_path "
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX configuration..." --weight=1
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring YOURLS main directory..." --weight=3
ynh_restore_file --origin_path="$final_path"
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# RESTORE USER RIGHTS
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=3
# Restore permissions on app files
chown -R $app: $final_path
chmod 600 $final_path/user/config.php
ynh_restore_file --origin_path="$final_path"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#=================================================
# RESTORE THE PHP-FPM CONFIGURATION
@ -81,6 +75,16 @@ ynh_script_progression --message="Reconfiguring PHP-FPM..." --weight=10
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
#=================================================
# SPECIFIC RESTORATION
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=1
# Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# RESTORE THE MYSQL DATABASE
#=================================================
@ -104,4 +108,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Restoration completed for YOURLS" --last
ynh_script_progression --message="Restoration completed for $app" --last

View file

@ -20,6 +20,7 @@ path_url=$(ynh_app_setting_get --app=$app --key=path)
admin=$(ynh_app_setting_get --app=$app --key=admin)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
@ -29,9 +30,24 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# If db_name doesn't exist, create it
if [ -z "$db_name" ]; then
@ -52,63 +68,49 @@ if ynh_legacy_permissions_exists; then
ynh_app_setting_delete --app=$app --key=is_public
fi
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up YOURLS before upgrading (may take a while)..." --weight=1
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
if ! ynh_permission_exists --permission="admin"; then
# Create the required permissions
ynh_permission_create --permission="admin" --url="/admin" --allowed=$admin
fi
#=================================================
# STANDARD UPGRADE STEPS
# 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
#=================================================
# Download, check integrity, uncompress and patch the source from app.src
# Create a temporary directory along with /user/plugin sub directory in it
tmpdir="$(mktemp -d)"
mkdir -p "$tmpdir/user/"
# Backup the app files in the temp dir
cp -a "$final_path/index.php" "$tmpdir"
cp -a "$final_path/.htaccess" "$tmpdir"
cp -a "$final_path/user/config.php" "$tmpdir/user"
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading source files..." --weight=1
# Remove the app directory securely
ynh_secure_remove --file="$final_path"
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path" --keep="$final_path/user/config.php"
fi
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path"
# Copy the app files from tmp to final_path
cp -a "$tmpdir/index.php" "$final_path"
cp -a "$tmpdir/.htaccess" "$final_path"
cp -a "$tmpdir/user/config.php" "$final_path/user"
#remove tmp dir
ynh_secure_remove "$tmpdir"
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
#=================================================
# CREATE DEDICATED USER
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=3
ynh_script_progression --message="Upgrading dependencies..." --weight=1
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# PHP-FPM CONFIGURATION
@ -116,34 +118,7 @@ ynh_system_user_create --username=$app
ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=4
# Create a dedicated PHP-FPM config
ynh_add_fpm_config --package="$extra_php_dependencies"
#=================================================
# MODIFY A CONFIG FILE
#=================================================
ynh_script_progression --message="Modifying a config file..." --weight=2
# Verify the checksum and backup the file if it's different
ynh_backup_if_checksum_is_different --file="$final_path/user/config.php"
cp ../conf/config.php $final_path/user/config.php
ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$final_path/user/config.php"
ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$final_path/user/config.php"
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/user/config.php"
ynh_replace_string --match_string="__PATH__" --replace_string="${path_url%/}" --target_file="$final_path/user/config.php"
ynh_replace_string --match_string="__RANDOM__" --replace_string="$(ynh_string_random 24)" --target_file="$final_path/user/config.php"
# Recalculate and store the config file checksum into the app settings
ynh_store_file_checksum --file="$final_path/user/config.php"
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
# Restore permissions on app files
chown -R $app: $final_path
chmod 600 $final_path/user/config.php
ynh_add_fpm_config
#=================================================
# RELOAD NGINX
@ -156,4 +131,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of YOURLS completed" --last
ynh_script_progression --message="Upgrade of $app completed" --last