diff --git a/README.md b/README.md index 3d877df..b190179 100644 --- a/README.md +++ b/README.md @@ -1,63 +1,48 @@ -# YOURLS for YunoHost + + +# 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 +### YOURLS Features + +- Free and open-source software, +- Private (your links only) or Public (everybody can create short links, fine for an intranet), +- Terrific Plugin architecture and 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 and more ! + + +**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 +54,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 \ No newline at end of file diff --git a/README_fr.md b/README_fr.md index 91cc124..76e6c16 100644 --- a/README_fr.md +++ b/README_fr.md @@ -1,63 +1,44 @@ -# 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). + +### YOURLS Features + +- Free and open-source software, +- Private (your links only) or Public (everybody can create short links, fine for an intranet), +- Terrific Plugin architecture and 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 and more ! + + +**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 +47,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 \ No newline at end of file diff --git a/check_process b/check_process index 432896c..3e2a0c5 100644 --- a/check_process +++ b/check_process @@ -1,25 +1,26 @@ -# 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" + is_public=1 + password="1Strong-Password" ; Checks pkg_linter=1 setup_sub_dir=1 setup_root=1 setup_nourl=0 - setup_private=0 + setup_private=1 setup_public=1 upgrade=1 + #upgrade=1 from_commit=CommitHash 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=CommitHash + name=Name and date of the commit. + manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666& diff --git a/conf/activate_plugins.sql b/conf/activate_plugins.sql deleted file mode 100644 index 93ea301..0000000 --- a/conf/activate_plugins.sql +++ /dev/null @@ -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";}'); - diff --git a/conf/app.src b/conf/app.src index 41cb246..8d2504e 100644 --- a/conf/app.src +++ b/conf/app.src @@ -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= diff --git a/conf/config-sample.php b/conf/config-sample.php new file mode 100644 index 0000000..f11c9ea --- /dev/null +++ b/conf/config-sample.php @@ -0,0 +1,91 @@ + '__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. + */ diff --git a/conf/config.php b/conf/config.php deleted file mode 100644 index 503af1a..0000000 --- a/conf/config.php +++ /dev/null @@ -1,93 +0,0 @@ - - + YOURLS -

-

Admin page

-
-
- +

Admin interface

+ \ No newline at end of file diff --git a/conf/nginx.conf b/conf/nginx.conf index ae41dca..ba5b6dc 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -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. diff --git a/conf/php-fpm.conf b/conf/php-fpm.conf index 1a1bfb6..ab1a471 100644 --- a/conf/php-fpm.conf +++ b/conf/php-fpm.conf @@ -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 %{}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 %{}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 diff --git a/conf/remove_sso_conf.py b/conf/remove_sso_conf.py deleted file mode 100644 index 4237b7d..0000000 --- a/conf/remove_sso_conf.py +++ /dev/null @@ -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)) diff --git a/doc/DESCRIPTION.md b/doc/DESCRIPTION.md new file mode 100644 index 0000000..3c160a3 --- /dev/null +++ b/doc/DESCRIPTION.md @@ -0,0 +1,11 @@ +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). + +### YOURLS Features + +- Free and open-source software, +- Private (your links only) or Public (everybody can create short links, fine for an intranet), +- Terrific Plugin architecture and 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 and more ! diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md new file mode 100644 index 0000000..e69de29 diff --git a/doc/screenshots/p4.png b/doc/screenshots/p4.png new file mode 100644 index 0000000..edf8073 Binary files /dev/null and b/doc/screenshots/p4.png differ diff --git a/manifest.json b/manifest.json index 409a9aa..d459ef5 100644 --- a/manifest.json +++ b/manifest.json @@ -6,22 +6,28 @@ "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/", "license": "MIT", + "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" + }, "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", @@ -32,8 +38,7 @@ "install" : [ { "name": "domain", - "type": "domain", - "example": "domain.org" + "type": "domain" }, { "name": "path", @@ -43,8 +48,16 @@ }, { "name": "admin", - "type": "user", - "example": "johndoe" + "type": "user" + }, + { + "name": "password", + "type": "password" + }, + { + "name": "is_public", + "type": "boolean", + "default": true } ] } diff --git a/scripts/_common.sh b/scripts/_common.sh index 168a47a..3a502cb 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -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}-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" #================================================= # PERSONAL HELPERS diff --git a/scripts/backup b/scripts/backup index fe1f3d0..742dee5 100644 --- a/scripts/backup +++ b/scripts/backup @@ -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)." diff --git a/scripts/change_url b/scripts/change_url new file mode 100644 index 0000000..283ffda --- /dev/null +++ b/scripts/change_url @@ -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 + +# Needed for helper "ynh_add_nginx_config" +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) + +#================================================= +# 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..." --time --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 diff --git a/scripts/install b/scripts/install index 5a3de2d..d779000 100644 --- a/scripts/install +++ b/scripts/install @@ -26,6 +26,9 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH admin=$YNH_APP_ARG_ADMIN +is_public=$YNH_APP_ARG_IS_PUBLIC +password="$YNH_APP_ARG_PASSWORD" +random=$(ynh_string_random --length=24) app=$YNH_APP_INSTANCE_NAME @@ -48,6 +51,22 @@ 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=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 +87,81 @@ 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" +# 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" +ynh_add_fpm_config phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) -# copy index file -cp ../conf/index.php $final_path/ +#================================================= +# ADD A CONFIGURATION +#================================================= +ynh_script_progression --message="Adding a configuration file..." --weight=1 + +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" #================================================= -# MODIFY A CONFIG FILE +# SETUP APPLICATION WITH CURL #================================================= -cp ../conf/config.php $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" -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" +# Installation with curl +ynh_script_progression --message="Finalizing installation..." --weight=1 +ynh_local_curl "admin/install.php" "install=dummy" -# Calculate and store the config file checksum into the app settings -ynh_store_file_checksum "$final_path/user/config.php" - -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= - -chown -R $app: $final_path -chmod 600 $final_path/user/config.php +# Remove the public access +ynh_permission_update --permission="main" --remove="visitors" #================================================= # 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" +# Make app public if necessary +if [ $is_public -eq 1 ] +then + # Everyone can access the app. + # The "main" permission is automatically created before the install script. + ynh_permission_update --permission="main" --add="visitors" +fi + +# 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 diff --git a/scripts/remove b/scripts/remove index 010c3f0..fa395fb 100644 --- a/scripts/remove +++ b/scripts/remove @@ -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 diff --git a/scripts/restore b/scripts/restore index 0b3848f..58eae03 100644 --- a/scripts/restore +++ b/scripts/restore @@ -38,19 +38,25 @@ 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" +#================================================= +# 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 --home_dir="$final_path" + #================================================= # RESTORE THE APP MAIN DIR #================================================= @@ -58,21 +64,9 @@ 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 - -#================================================= -# RESTORE USER RIGHTS -#================================================= - -# Restore permissions on app files -chown -R $app: $final_path -chmod 600 $final_path/user/config.php +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 diff --git a/scripts/upgrade b/scripts/upgrade index 3c98e9b..9a316ce 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -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,6 +30,20 @@ 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 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 + #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= @@ -52,63 +67,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 +117,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 +130,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