From 7b8586906113ff94137cb4c9a7a436c65ad994ba Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 12 Dec 2020 08:56:05 +0100 Subject: [PATCH 1/9] Fix linter warnings --- README.md | 8 ++-- check_process | 12 ------ conf/nginx.conf | 3 +- conf/php-fpm.conf | 104 +++++++++++++++++++++++++++++++-------------- manifest.json | 14 +++--- scripts/_common.sh | 33 ++++++++------ scripts/backup | 23 +++++++--- scripts/change_url | 31 ++++++++++---- scripts/install | 65 ++++++++++++++-------------- scripts/remove | 18 ++++++-- scripts/restore | 23 +++++++--- scripts/upgrade | 43 +++++++++---------- 12 files changed, 230 insertions(+), 147 deletions(-) diff --git a/README.md b/README.md index 4dcd4fe..7eb3cfa 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # LibreTo for YunoHost -[![Integration level](https://dash.yunohost.org/integration/libreto.svg)](https://dash.yunohost.org/appci/app/libreto) +[![Integration level](https://dash.yunohost.org/integration/libreto.svg)](https://dash.yunohost.org/appci/app/libreto) ![](https://ci-apps.yunohost.org/ci/badges/libreto.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/libreto.maintain.svg) [![Install LibreTo with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=libreto) > *This package allow you to install LibreTo quickly and simply on a YunoHost server. @@ -36,7 +36,7 @@ Libreto has no user management, but YunoHost allow you to decide if this app is #### Supported architectures -* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/libreto%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/libreto/) +* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/libreto%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/libreto/) * ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/libreto%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/libreto/) ## Limitations @@ -47,12 +47,12 @@ Only app instances with a valid certificate and allowing to be included in Frame * Report a bug: https://github.com/YunoHost-Apps/libreto_ynh/issues * App website: http://libreto.net/ + * Upstream app repository: https://github.com/Ventricule/libreto * YunoHost website: https://yunohost.org/ --- -Developers info ----------------- +## Developers info Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/libreto_ynh/tree/testing). diff --git a/check_process b/check_process index 0569c6c..5770b70 100644 --- a/check_process +++ b/check_process @@ -14,20 +14,8 @@ upgrade=1 backup_restore=1 multi_instance=1 - incorrect_path=1 port_already_use=0 change_url=0 -;;; Levels - Level 1=auto - Level 2=auto - Level 3=auto - Level 4=na - Level 5=auto - Level 6=auto - Level 7=auto - Level 8=0 - Level 9=0 - Level 10=0 ;;; Options Email=ljf+libreto_ynh@reflexlibre.net Notification=down diff --git a/conf/nginx.conf b/conf/nginx.conf index f42b7ab..3a93921 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -21,8 +21,9 @@ location __PATH__/ { # Include SSOWAT user panel. include conf.d/yunohost_panel.conf.inc; } + location @libreto { - fastcgi_pass unix:/var/run/php5-fpm-__NAME__.sock; + fastcgi_pass unix:/var/run/php__PHPVERSION__-fpm-__NAME__.sock; fastcgi_index index.php; include fastcgi_params; diff --git a/conf/php-fpm.conf b/conf/php-fpm.conf index 8affbc2..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/php5-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. @@ -390,3 +417,14 @@ catch_workers_output = yes ;php_admin_value[error_log] = /var/log/fpm-php.www.log ;php_admin_flag[log_errors] = on ;php_admin_value[memory_limit] = 32M + +; Common values to change to increase file upload limit +; 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 +; 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/manifest.json b/manifest.json index bc78224..ac62d32 100644 --- a/manifest.json +++ b/manifest.json @@ -3,8 +3,8 @@ "id": "libreto", "packaging_format": 1, "description": { - "en": "Libreto aggregate your pads to create a wiki.", - "fr": "Libreto agrége vos pads pour créer un wiki." + "en": "Aggregate your pads to create a wiki.", + "fr": "Agréger vos pads pour créer un wiki." }, "version": "0.0.20180605~ynh2", "url": "https://libreto.net", @@ -28,8 +28,8 @@ "name": "domain", "type": "domain", "ask": { - "en": "Choose a domain name for libreto", - "fr": "Choisissez un nom de domaine pour libreto" + "en": "Choose a domain name for Libreto", + "fr": "Choisissez un nom de domaine pour Libreto" }, "example": "example.com" }, @@ -37,11 +37,11 @@ "name": "etherpad_instance", "ask": { "en": "Choose etherpad URL Libreto should use?", - "fr": "Choisissez l'url de l'instance etherpad que Libreto utilisera ?" + "fr": "Choisissez l'URL de l'instance etherpad que Libreto utilisera ?" }, "help": { - "en": "Libreto need an etherpad instance, you should install before the package etherpad. You need a valid certificate.", - "fr": "Libreto a besoin d'une instance etherpad, vous devriez installer le paquet Libreto avant. Vous devez avoir un certificat valide." + "en": "Libreto need an Etherpad instance, you should install before the package etherpad. You need a valid certificate.", + "fr": "Libreto a besoin d'une instance Etherpad, vous devriez installer le paquet Libreto avant. Vous devez avoir un certificat valide." }, "optional": true, "example": "https://annuel2.framapad.org", diff --git a/scripts/_common.sh b/scripts/_common.sh index 7477241..7be08fc 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,14 +1,23 @@ #!/bin/bash -COMMIT="76408f5e98a68156afa47996e670d110a1c6106d" -# ============= FUTURE YUNOHOST HELPER ============= -# Delete a file checksum from the app settings -# -# $app should be defined when calling this helper -# -# usage: ynh_remove_file_checksum file -# | arg: file - The file for which the checksum will be deleted -ynh_delete_file_checksum () { - local checksum_setting_name=checksum_${1//[\/ ]/_} # Replace all '/' and ' ' by '_' - ynh_app_setting_delete $app $checksum_setting_name -} +#================================================= +# COMMON VARIABLES +#================================================= + +YNH_PHP_VERSION="7.3" + +#COMMIT="76408f5e98a68156afa47996e670d110a1c6106d" + +COMMIT="da3f312fec0a829cc3df1191113e93b49fb4786e" + +#================================================= +# PERSONAL HELPERS +#================================================= + +#================================================= +# EXPERIMENTAL HELPERS +#================================================= + +#================================================= +# FUTURE OFFICIAL HELPERS +#================================================= \ No newline at end of file diff --git a/scripts/backup b/scripts/backup index f29c0b6..886fc15 100755 --- a/scripts/backup +++ b/scripts/backup @@ -19,28 +19,39 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= +ynh_print_info --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME -final_path=$(ynh_app_setting_get $app final_path) -domain=$(ynh_app_setting_get $app domain) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) +domain=$(ynh_app_setting_get --app=$app --key=domain) +phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= -# STANDARD BACKUP STEPS +# DECLARE DATA AND CONF FILES TO BACKUP +#================================================= +ynh_print_info --message="Declaring files to be backed up..." + #================================================= # BACKUP THE APP MAIN DIR #================================================= -ynh_backup "$final_path" +ynh_backup --src_path="$final_path" #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= -ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # BACKUP THE PHP-FPM CONFIGURATION #================================================= -ynh_backup "/etc/php5/fpm/pool.d/$app.conf" +ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/change_url b/scripts/change_url index a4eed15..dcc468b 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -24,18 +24,27 @@ 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 final_path) #================================================= -# CHECK THE SYNTAX OF THE PATHS +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= +ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=3 -test -n "$old_path" || old_path="/" -test -n "$new_path" || new_path="/" -new_path=$(ynh_normalize_url_path $new_path) -old_path=$(ynh_normalize_url_path $old_path) +# 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 @@ -58,6 +67,7 @@ fi #================================================= # MODIFY URL IN NGINX CONF #================================================= +ynh_script_progression --message="Updating NGINX web server configuration..." --weight=2 nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf @@ -83,10 +93,15 @@ then ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf" fi -#================================================= -# GENERIC FINALISATION #================================================= # RELOAD NGINX #================================================= +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 -systemctl reload nginx +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 4e4652f..2f87852 100755 --- a/scripts/install +++ b/scripts/install @@ -35,48 +35,44 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= +ynh_script_progression --message="Validating installation parameters..." --weight=1 final_path=/var/www/$app test ! -e "$final_path" || ynh_die "This path already contains a folder" -# Normalize the url path syntax -path_url=$(ynh_normalize_url_path $path_url) - -# Check web path availability -ynh_webpath_available $domain $path_url # Register (book) web path -ynh_webpath_register $app $domain $path_url +ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_app_setting_set $app domain "$domain" -ynh_app_setting_set $app path "$path_url" -ynh_app_setting_set $app etherpad_instance "$etherpad_instance" -ynh_app_setting_set $app is_public $is_public -ynh_app_setting_set $app creation_open $creation_open +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=etherpad_instance --value=$etherpad_instance +ynh_app_setting_set --app=$app --key=is_public --value=$is_public +ynh_app_setting_set --app=$app --key=creation_open --value=$creation_open #================================================= # STANDARD MODIFICATIONS -#================================================= - - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= +ynh_script_progression --message="Setting up source files..." --weight=4 -ynh_app_setting_set $app final_path $final_path +ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Note: We use git instead of ynh_setup_source, cause this repo use submodules git clone https://github.com/zamentur/libreto.git "$final_path" --quiet + pushd "$final_path" -git checkout $COMMIT --quiet -git submodule update --init --recursive --quiet + git checkout $COMMIT --quiet + git submodule update --init --recursive --quiet popd #================================================= # NGINX CONFIGURATION #================================================= +ynh_script_progression --message="Configuring NGINX web server..." --weight=2 # Create a dedicated nginx config ynh_add_nginx_config @@ -84,35 +80,34 @@ ynh_add_nginx_config #================================================= # CREATE DEDICATED USER #================================================= +ynh_script_progression --message="Configuring system user..." --weight=1 # Create a system user -ynh_system_user_create $app +ynh_system_user_create --username=$app #================================================= # PHP-FPM CONFIGURATION #================================================= - +ynh_script_progression --message="Configuring PHP-FPM..." --weight=2 # Create a dedicated php-fpm config ynh_add_fpm_config -ynh_replace_string "__INSTANCE__" "$etherpad_instance" "/etc/nginx/conf.d/$domain.d/$app.conf" +phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) - -#================================================= -# SPECIFIC SETUP -#================================================= -cp "../conf/config.dist.php" "$final_path/config.php" -#================================================= +ynh_replace_string --match_string="__INSTANCE__" --replace_string="$etherpad_instance" --target_file="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # MODIFY A CONFIG FILE #================================================= + +cp "../conf/config.dist.php" "$final_path/config.php" + provider="${domain%%.*}" if [ "$etherpad_instance" != "https://annuel2.framapad.org" ]; then - ynh_replace_string "// CUSTOM_PROVIDER" "" "$final_path/config.php" - ynh_replace_string "__PROVIDER__" "$provider" "$final_path/config.php" - ynh_replace_string "__INSTANCE__" "$etherpad_instance" "$final_path/config.php" + ynh_replace_string --match_string="// CUSTOM_PROVIDER" --replace_string="" --target_file="$final_path/config.php" + ynh_replace_string --match_string="__PROVIDER__" --replace_string="$provider" --target_file="$final_path/config.php" + ynh_replace_string --match_string="__INSTANCE__" --replace_string="$etherpad_instance" --target_file="$final_path/config.php" else - ynh_replace_string "__PROVIDER__" "framapad" "$final_path/config.php" + ynh_replace_string --match_string="__PROVIDER__" --replace_string="framapad" --target_file="$final_path/config.php" fi #================================================= @@ -134,6 +129,7 @@ chown -R root: $final_path #================================================= # SETUP SSOWAT #================================================= +ynh_script_progression --message="Configuring SSOwat..." --weight=1 # Make app public if necessary if [ $is_public -eq 1 ] @@ -149,5 +145,12 @@ fi #================================================= # RELOAD NGINX #================================================= +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 -systemctl reload nginx +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Installation of $app completed" --last diff --git a/scripts/remove b/scripts/remove index 9ccfc1b..433234e 100755 --- a/scripts/remove +++ b/scripts/remove @@ -12,6 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= +ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME @@ -20,18 +21,18 @@ final_path=$(ynh_app_setting_get $app final_path) #================================================= # STANDARD REMOVE -#================================================= - #================================================= # REMOVE APP MAIN DIR #================================================= +ynh_script_progression --message="Removing app main directory..." --weight=3 # Remove the app directory securely -ynh_secure_remove "$final_path" +ynh_secure_remove --file="$final_path" #================================================= # REMOVE NGINX CONFIGURATION #================================================= +ynh_script_progression --message="Removing NGINX web server configuration..." --weight=2 # Remove the dedicated nginx config ynh_remove_nginx_config @@ -39,6 +40,7 @@ ynh_remove_nginx_config #================================================= # REMOVE PHP-FPM CONFIGURATION #================================================= +ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=1 # Remove the dedicated php-fpm config ynh_remove_fpm_config @@ -46,6 +48,7 @@ ynh_remove_fpm_config #================================================= # REMOVE LOGROTATE CONFIGURATION #================================================= +ynh_script_progression --message="Removing logrotate configuration..." --weight=1 # Remove the app-specific logrotate config ynh_remove_logrotate @@ -55,6 +58,13 @@ ynh_remove_logrotate #================================================= # REMOVE DEDICATED USER #================================================= +ynh_script_progression --message="Removing the dedicated system user..." --weight=1 # Delete a system user -ynh_system_user_delete $app +ynh_system_user_delete --username=$app + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Removal of $app completed" --last diff --git a/scripts/restore b/scripts/restore index c2e783b..4cf92a5 100755 --- a/scripts/restore +++ b/scripts/restore @@ -23,16 +23,19 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= +ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get $app domain) -path_url=$(ynh_app_setting_get $app path) -final_path=$(ynh_app_setting_get $app final_path) +domain=$(ynh_app_setting_get --app=$app --key=domain) +path_url=$(ynh_app_setting_get --app=$app --key=path) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) +phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= +ynh_script_progression --message="Validating restoration parameters..." --weight=2 ynh_webpath_available $domain $path_url \ || ynh_die "Path not available: ${domain}${path_url}" @@ -50,9 +53,10 @@ ynh_restore #================================================= # 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 $app +ynh_system_user_create --username=$app #================================================= # RESTORE USER RIGHTS @@ -66,6 +70,13 @@ chown -R root: $final_path #================================================= # RELOAD NGINX AND PHP-FPM #================================================= +ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=1 -systemctl reload php5-fpm -systemctl reload nginx +ynh_systemd_action --service_name=php$phpversion-fpm --action=reload +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Restoration completed for $app" --last diff --git a/scripts/upgrade b/scripts/upgrade index 9e04451..e04469d 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -22,11 +22,6 @@ final_path=$(ynh_app_setting_get $app final_path) etherpad_instance=$(ynh_app_setting_get $app etherpad_instance) creation_open=$(ynh_app_setting_get $app creation_open) -#================================================= -# ENSURE DOWNWARD COMPATIBILITY -#================================================= - - #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -40,53 +35,47 @@ ynh_clean_setup () { # Exit if an error occurs during the execution of the script ynh_abort_if_errors -#================================================= -# CHECK THE PATH -#================================================= - -# Normalize the URL path syntax -path_url=$(ynh_normalize_url_path $path_url) - #================================================= # STANDARD UPGRADE STEPS #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= +ynh_script_progression --message="Upgrading source files..." --weight=5 # Download, check integrity, uncompress and patch the source from app.src pushd "$final_path" -git checkout master -git pull --quiet -git checkout $COMMIT --quiet -git submodule update --init --recursive --quiet + git checkout master + git pull --quiet + git checkout $COMMIT --quiet + git submodule update --init --recursive --quiet popd #================================================= # NGINX CONFIGURATION #================================================= +ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2 -# Create a dedicated nginx config +# Create a dedicated NGINX config ynh_add_nginx_config #================================================= # 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 $app +ynh_system_user_create --username=$app #================================================= # PHP-FPM CONFIGURATION #================================================= - +ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=2 # Create a dedicated php-fpm config ynh_add_fpm_config #================================================= # SPECIFIC UPGRADE #================================================= -# ... -#================================================= ### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. ### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it. @@ -94,7 +83,6 @@ ynh_backup_if_checksum_is_different "$final_path/config.php" # Recalculate and store the checksum of the file for the next upgrade. ynh_store_file_checksum "$final_path/config.php" - #================================================= # GENERIC FINALIZATION #================================================= @@ -107,6 +95,7 @@ chown -R root: $final_path #================================================= # SETUP SSOWAT #================================================= +ynh_script_progression --message="Upgrading SSOwat configuration..." --weight=1 # Make app public if necessary if [ $is_public -eq 1 ] @@ -122,5 +111,13 @@ fi #================================================= # RELOAD NGINX #================================================= +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 + +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Upgrade of $app completed" --last -systemctl reload nginx From d41938bad61b26f1aaddee081cb1b436d9b257ec Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 12 Dec 2020 09:01:58 +0100 Subject: [PATCH 2/9] Fix --- manifest.json | 1 + scripts/_common.sh | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/manifest.json b/manifest.json index ac62d32..8caaa14 100644 --- a/manifest.json +++ b/manifest.json @@ -35,6 +35,7 @@ }, { "name": "etherpad_instance", + "type": "domain", "ask": { "en": "Choose etherpad URL Libreto should use?", "fr": "Choisissez l'URL de l'instance etherpad que Libreto utilisera ?" diff --git a/scripts/_common.sh b/scripts/_common.sh index 7be08fc..26b65ae 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -6,9 +6,7 @@ YNH_PHP_VERSION="7.3" -#COMMIT="76408f5e98a68156afa47996e670d110a1c6106d" - -COMMIT="da3f312fec0a829cc3df1191113e93b49fb4786e" +COMMIT="76408f5e98a68156afa47996e670d110a1c6106d" #================================================= # PERSONAL HELPERS From 669acde1db39452e11ec70b058f1befdf22eec56 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 12 Dec 2020 09:03:53 +0100 Subject: [PATCH 3/9] Update manifest.json --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 8caaa14..e9abad4 100644 --- a/manifest.json +++ b/manifest.json @@ -35,7 +35,7 @@ }, { "name": "etherpad_instance", - "type": "domain", + "type": "string", "ask": { "en": "Choose etherpad URL Libreto should use?", "fr": "Choisissez l'URL de l'instance etherpad que Libreto utilisera ?" From 6f8f0bc325cafaa7284663543a30e896fed18639 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 12 Dec 2020 09:04:52 +0100 Subject: [PATCH 4/9] Update manifest.json --- manifest.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/manifest.json b/manifest.json index e9abad4..3da2cde 100644 --- a/manifest.json +++ b/manifest.json @@ -55,6 +55,10 @@ "en": "Is it a public application?", "fr": "Est-ce une application publique ?" }, + "help": { + "en": "If enabled, Libreto will be accessible by people who do not have an account. This can be changed later via the webadmin.", + "fr": "Si cette case est cochée, Libreto sera accessible aux personnes n’ayant pas de compte. Vous pourrez changer ceci plus tard via la webadmin." + }, "default": true }, { From 4a31c0463de1d4bd87842a01a779e59b5c4751e1 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 12 Dec 2020 09:13:57 +0100 Subject: [PATCH 5/9] Update manifest.json --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 3da2cde..d0dd526 100644 --- a/manifest.json +++ b/manifest.json @@ -20,7 +20,7 @@ "multi_instance": true, "services": [ "nginx", - "php5-fpm" + "php7.0-fpm" ], "arguments": { "install" : [ From b4209ca4942dc9f6ba88eb25dc23d31bb11af71d Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 12 Dec 2020 09:24:23 +0100 Subject: [PATCH 6/9] Update nginx.conf --- conf/nginx.conf | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 3a93921..29739e9 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -10,23 +10,23 @@ location __PATH__/ { } index index.php; - # Common parameter to increase upload size limit in conjunction with dedicated php-fpm file - #client_max_body_size 50M; - - try_files "" @libreto; location __PATH__/libreto/assets/ { alias __FINALPATH__/libreto/assets/; } - # Include SSOWAT user panel. - include conf.d/yunohost_panel.conf.inc; -} -location @libreto { - fastcgi_pass unix:/var/run/php__PHPVERSION__-fpm-__NAME__.sock; + try_files $uri $uri/ index.php; + location ~ [^/]\.php(/|$) { + 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 SCRIPT_FILENAME __FINALPATH__/index.php; + fastcgi_param REMOTE_USER $remote_user; + fastcgi_param PATH_INFO $fastcgi_path_info; + fastcgi_param SCRIPT_FILENAME $request_filename; + } + + # Include SSOWAT user panel. + include conf.d/yunohost_panel.conf.inc; } From 8f7e0a02d3ab80e44387dfbe685f07036dac1ee1 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 12 Dec 2020 09:34:04 +0100 Subject: [PATCH 7/9] Fix --- README.md | 8 ++++---- check_process | 2 +- scripts/change_url | 10 +++++----- scripts/install | 3 ++- scripts/remove | 4 ++-- scripts/upgrade | 5 +---- 6 files changed, 15 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 7eb3cfa..f47f066 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,13 @@ -# LibreTo for YunoHost +# Libreto for YunoHost [![Integration level](https://dash.yunohost.org/integration/libreto.svg)](https://dash.yunohost.org/appci/app/libreto) ![](https://ci-apps.yunohost.org/ci/badges/libreto.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/libreto.maintain.svg) -[![Install LibreTo with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=libreto) +[![Install Libreto with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=libreto) -> *This package allow you to install LibreTo quickly and simply on a YunoHost server. +> *This package allow you to install Libreto quickly and simply on a YunoHost server. If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.* ## Overview -Libreto let you aggregate your pad (etherpad lite) to create a kind of wiki easily. +Libreto let you aggregate your pad (Etherpad lite) to create a kind of wiki easily. **Shipped version:** 0.0.20180605 diff --git a/check_process b/check_process index 5770b70..10ea98e 100644 --- a/check_process +++ b/check_process @@ -15,7 +15,7 @@ backup_restore=1 multi_instance=1 port_already_use=0 - change_url=0 + change_url=1 ;;; Options Email=ljf+libreto_ynh@reflexlibre.net Notification=down diff --git a/scripts/change_url b/scripts/change_url index dcc468b..876fb11 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -71,19 +71,19 @@ ynh_script_progression --message="Updating NGINX web server configuration..." -- nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf -# Change the path in the nginx config file +# 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 + # Make a backup of the original NGINX config file if modified ynh_backup_if_checksum_is_different "$nginx_conf_path" - # Set global variables for nginx helper + # Set global variables for NGINX helper domain="$old_domain" path_url="$new_path" - # Create a dedicated nginx config + # Create a dedicated NGINX config ynh_add_nginx_config fi -# Change the domain for nginx +# Change the domain for NGINX if [ $change_domain -eq 1 ] then # Delete file checksum for the old conf file location diff --git a/scripts/install b/scripts/install index 2f87852..9e305d1 100755 --- a/scripts/install +++ b/scripts/install @@ -89,7 +89,8 @@ ynh_system_user_create --username=$app # PHP-FPM CONFIGURATION #================================================= ynh_script_progression --message="Configuring PHP-FPM..." --weight=2 -# Create a dedicated php-fpm config + +# Create a dedicated PHP-FPM config ynh_add_fpm_config phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) diff --git a/scripts/remove b/scripts/remove index 433234e..d460e90 100755 --- a/scripts/remove +++ b/scripts/remove @@ -34,7 +34,7 @@ ynh_secure_remove --file="$final_path" #================================================= ynh_script_progression --message="Removing NGINX web server configuration..." --weight=2 -# Remove the dedicated nginx config +# Remove the dedicated NGINX config ynh_remove_nginx_config #================================================= @@ -42,7 +42,7 @@ ynh_remove_nginx_config #================================================= ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=1 -# Remove the dedicated php-fpm config +# Remove the dedicated PHP-FPM config ynh_remove_fpm_config #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index e04469d..fb1abfe 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -70,15 +70,13 @@ ynh_system_user_create --username=$app # PHP-FPM CONFIGURATION #================================================= ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=2 -# Create a dedicated php-fpm config +# Create a dedicated PHP-FPM config ynh_add_fpm_config #================================================= # SPECIFIC UPGRADE #================================================= -### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. -### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it. ynh_backup_if_checksum_is_different "$final_path/config.php" # Recalculate and store the checksum of the file for the next upgrade. ynh_store_file_checksum "$final_path/config.php" @@ -120,4 +118,3 @@ ynh_systemd_action --service_name=nginx --action=reload #================================================= ynh_script_progression --message="Upgrade of $app completed" --last - From 229a2e139958cc79a76885ab7cfa60416782eb6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sat, 19 Dec 2020 23:30:11 +0100 Subject: [PATCH 8/9] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f47f066..5c94666 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Libreto for YunoHost [![Integration level](https://dash.yunohost.org/integration/libreto.svg)](https://dash.yunohost.org/appci/app/libreto) ![](https://ci-apps.yunohost.org/ci/badges/libreto.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/libreto.maintain.svg) -[![Install Libreto with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=libreto) +[![Install Libreto with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=libreto) > *This package allow you to install Libreto quickly and simply on a YunoHost server. If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.* From 1000a4461a3a27517751fda2a0fd3b17bbd1985a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Thu, 7 Jan 2021 18:36:55 +0100 Subject: [PATCH 9/9] Update manifest.json Co-authored-by: Alexandre Aubin --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index d0dd526..d3672df 100644 --- a/manifest.json +++ b/manifest.json @@ -4,7 +4,7 @@ "packaging_format": 1, "description": { "en": "Aggregate your pads to create a wiki.", - "fr": "Agréger vos pads pour créer un wiki." + "fr": "Agrégez vos pads pour créer un wiki." }, "version": "0.0.20180605~ynh2", "url": "https://libreto.net",