mirror of
https://github.com/YunoHost-Apps/flarum_ynh.git
synced 2024-09-03 18:36:24 +02:00
Merge pull request #117 from YunoHost-Apps/v0.1.0-beta.9-1
Upgrade to v0.1.0 beta.9-1
This commit is contained in:
commit
6c6fe9e097
17 changed files with 762 additions and 370 deletions
42
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
42
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
---
|
||||||
|
name: Bug report
|
||||||
|
about: Create a report to help us debug
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**How to post a meaningful bug report**
|
||||||
|
1. *Read this whole template first.*
|
||||||
|
2. *Determine if you are on the right place:*
|
||||||
|
- *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change url...), you are on the right place!*
|
||||||
|
- *If the issue is about logging in and out of the forum, it is most likely due to the SSOwat extension. Please post the issue on its [repository](https://github.com/tituspijean/flarum-ext-auth-ssowat/issue).*
|
||||||
|
- *Otherwise, the issue may be due to Flarum itself. Refer to its [forum](https://discuss.flarum.org) for help.*
|
||||||
|
- *If you have a doubt, post here, we will figure it out together.*
|
||||||
|
3. *Delete the italic comments as you write over them below, and remove this guide.*
|
||||||
|
---
|
||||||
|
|
||||||
|
**Describe the bug**
|
||||||
|
*A clear and concise description of what the bug is.*
|
||||||
|
|
||||||
|
**Versions**
|
||||||
|
- YunoHost version:
|
||||||
|
- Package version/branch: *if you did not specify anything, put "latest"*
|
||||||
|
|
||||||
|
**To Reproduce**
|
||||||
|
*Steps to reproduce the behavior.*
|
||||||
|
- *If you performed a command from the CLI, the command itself is enough. For example:*
|
||||||
|
```sh
|
||||||
|
sudo yunohost app install flarum
|
||||||
|
```
|
||||||
|
- *If you used the webadmin, please perform the equivalent command from the CLI first.*
|
||||||
|
- *If the error occurs in your browser, explain what you did:*
|
||||||
|
1. *Go to '...'*
|
||||||
|
2. *Click on '....'*
|
||||||
|
3. *Scroll down to '....'*
|
||||||
|
4. *See error*
|
||||||
|
|
||||||
|
**Expected behavior**
|
||||||
|
*A clear and concise description of what you expected to happen. You can remove this section if the command above is enough to understand your intent.*
|
||||||
|
|
||||||
|
**Logs**
|
||||||
|
*After a failed command, YunoHost makes the log available to you, but also to others, thanks to `yunohost log display [log name] --share`. The actual command, with the correct log name, is displayed at the end of the failed attempt in the CLI. Execute it and copy here the share link it outputs.*
|
||||||
|
*If applicable and useful, add screenshots to help explain your problem.*
|
16
README.md
16
README.md
|
@ -1,8 +1,8 @@
|
||||||
# Flarum for YunoHost
|
# Flarum for YunoHost
|
||||||
|
|
||||||
[![Install Hubzilla with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=flarum)
|
[![Install Flarum with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=flarum)
|
||||||
|
|
||||||
[![Integration level](https://ci-apps.yunohost.org/ci/logs/flarum%20(Community).svg)](https://dash.yunohost.org/appci/app/flarum) [![Flarum version](https://img.shields.io/badge/flarum-0.1.0--beta.7.2-green.svg)](https://github.com/flarum/core/releases/tag/v0.1.0-beta.7.2)
|
[![Integration level](https://ci-apps.yunohost.org/ci/logs/flarum%20(Community).svg)](https://dash.yunohost.org/appci/app/flarum) [![Flarum version](https://img.shields.io/badge/flarum-0.1.0--beta.9-green.svg)](https://github.com/flarum/flarum/releases/tag/v0.1.0-beta.9) ![PHP version](https://img.shields.io/badge/php--7.3-green.svg)
|
||||||
|
|
||||||
[Flarum](http://flarum.org/), an open-source forum software, packaged for [YunoHost](https://yunohost.org/), a self-hosting server operating server.
|
[Flarum](http://flarum.org/), an open-source forum software, packaged for [YunoHost](https://yunohost.org/), a self-hosting server operating server.
|
||||||
|
|
||||||
|
@ -14,6 +14,8 @@
|
||||||
- SSOwat integration through a [dedicated extension](https://github.com/tituspijean/flarum-ext-auth-ssowat).
|
- SSOwat integration through a [dedicated extension](https://github.com/tituspijean/flarum-ext-auth-ssowat).
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
::warning: Flarum requires PHP 7.1+. PHP versions above 7.0 are currently not officially supported by YunoHost. This package's `install` script directly calls `apt install php7.3 ...`. Proceed with caution.
|
||||||
|
|
||||||
This Flarum package can be installed through:
|
This Flarum package can be installed through:
|
||||||
- YunoHost's webadmin, in the Community listing
|
- YunoHost's webadmin, in the Community listing
|
||||||
- YunoHost's CLI: `yunohost app install https://github.com/YunoHost-Apps/flarum_ynh`.
|
- YunoHost's CLI: `yunohost app install https://github.com/YunoHost-Apps/flarum_ynh`.
|
||||||
|
@ -24,7 +26,7 @@ Required parameters are:
|
||||||
- `admin`, among the YunoHosts users
|
- `admin`, among the YunoHosts users
|
||||||
- `public`, *true* by default, for guests to read the forum
|
- `public`, *true* by default, for guests to read the forum
|
||||||
- `title` of the forum
|
- `title` of the forum
|
||||||
- `language` can be English (by default), French, and German. Other languages installable after installation as any other extensions
|
- `language` can be English `en` (by default), French `fr`, and German `de`. Other languages are installable after installation like any other extensions
|
||||||
- `bazaar_extension` to install the extension marketplace (*false* by default), to avoid using the command line to add new extensions.
|
- `bazaar_extension` to install the extension marketplace (*false* by default), to avoid using the command line to add new extensions.
|
||||||
|
|
||||||
After installation, simply open your browser to Flarum's page. First loading may be a bit longer as assets are generated.
|
After installation, simply open your browser to Flarum's page. First loading may be a bit longer as assets are generated.
|
||||||
|
@ -50,13 +52,13 @@ Reboot the system and try the installation again.
|
||||||
### `Timeout` errors
|
### `Timeout` errors
|
||||||
Some users have reported a successful installation, but get a blank page due to a `timeout` on a PHP script that prepares the forum assests (`Minify.php`, notably).
|
Some users have reported a successful installation, but get a blank page due to a `timeout` on a PHP script that prepares the forum assests (`Minify.php`, notably).
|
||||||
|
|
||||||
In `/etc/php/7.0/fpm/conf.d/20-{APPID}.ini`, you can increase the `max_execution_time` and `max_input_time` limits (both values are in seconds if nothing is specified).
|
In `/etc/php/*php_version*/fpm/pool.d/*app_id*.conf`, you can increase the `max_execution_time` and `max_input_time` limits (both values are in seconds if nothing is specified).
|
||||||
|
|
||||||
Reload PHP-FPM with `sudo service php7.0-fpm reload`.
|
Reload PHP-FPM with `sudo service php*php_version*-fpm reload`.
|
||||||
|
|
||||||
### Upload limit
|
### Upload limit
|
||||||
If you are facing an error while uploading large files into the forum, PHP may be limiting file upload.
|
If you are facing an error while uploading large files into the forum, PHP may be limiting file upload.
|
||||||
|
|
||||||
In `/etc/php/7.0/fpm/conf.d/20-{APPID}.ini`, you can uncomment (remove `;` at the beginning of the line) and increase the values of `upload_max_filesize` and `post_max_size` (both values are in bytes).
|
In `/etc/php/*php_version*/fpm/pool.d/*app_id*.conf`, you can uncomment (remove `;` at the beginning of the line) and increase the values of `upload_max_filesize` and `post_max_size` (both values are in bytes).
|
||||||
|
|
||||||
Reload PHP-FPM with `sudo service php7.0-fpm reload`.
|
Reload PHP-FPM with `sudo service php*php_version*-fpm reload`.
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
setup_private=1
|
setup_private=1
|
||||||
setup_public=1
|
setup_public=1
|
||||||
upgrade=1
|
upgrade=1
|
||||||
upgrade=1 from_commit=46ca549825e311f4095b173e79d58a349d70d9a2
|
upgrade=1 from_commit=e9d524d3ede85572e72bf9ac05b224c18b2f1765
|
||||||
backup_restore=1
|
backup_restore=1
|
||||||
multi_instance=1
|
multi_instance=1
|
||||||
incorrect_path=1
|
incorrect_path=1
|
||||||
|
|
|
@ -4,23 +4,16 @@ location ^~ __PATH__ {
|
||||||
rewrite ^ https://$server_name$request_uri? permanent;
|
rewrite ^ https://$server_name$request_uri? permanent;
|
||||||
}
|
}
|
||||||
|
|
||||||
alias __FINALPATH__/;
|
alias __FINALPATH__/public/;
|
||||||
try_files $uri $uri/ /index.php?$query_string;
|
index index.php;
|
||||||
index __LOCATION_HACK__/index.php;
|
|
||||||
|
|
||||||
# Bug in Nginx with locations and aliases (see http://stackoverflow.com/a/35102259 )
|
# Bug in Nginx with locations and aliases (see http://stackoverflow.com/a/35102259 )
|
||||||
location __LOCATION_HACK__/ { try_files $uri $uri/ __PATH_HACK__/index.php?$query_string; }
|
# try_files $uri $uri/ /index.php?$query_string; # will not work for /admin and /api
|
||||||
location __LOCATION_HACK__/api { try_files $uri $uri/ __PATH_HACK__/api.php?$query_string; }
|
if (!-e $request_filename) { rewrite ^ __PATH_HACK__/index.php last; }
|
||||||
location __LOCATION_HACK__/admin { try_files $uri $uri/ __PATH_HACK__/admin.php?$query_string; }
|
|
||||||
|
|
||||||
location __LOCATION_HACK__/flarum/ {
|
|
||||||
deny all;
|
|
||||||
return 404;
|
|
||||||
}
|
|
||||||
|
|
||||||
location ~* \.php$ {
|
location ~* \.php$ {
|
||||||
fastcgi_split_path_info ^(.+.php)(/.+)$;
|
fastcgi_split_path_info ^(.+.php)(/.+)$;
|
||||||
fastcgi_pass unix:/var/run/php5-fpm-__NAME__.sock;
|
fastcgi_pass unix:/var/run/php-fpm-__NAME__.sock;
|
||||||
include fastcgi_params;
|
include fastcgi_params;
|
||||||
fastcgi_param SCRIPT_FILENAME $request_filename;
|
fastcgi_param SCRIPT_FILENAME $request_filename;
|
||||||
fastcgi_param HTTP_PROXY ""; # Fix for https://httpoxy.org/ vulnerability
|
fastcgi_param HTTP_PROXY ""; # Fix for https://httpoxy.org/ vulnerability
|
||||||
|
@ -28,38 +21,61 @@ location ^~ __PATH__ {
|
||||||
fastcgi_read_timeout 600;
|
fastcgi_read_timeout 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
location ~* \.html$ {
|
# Expire rules for static content
|
||||||
expires -1;
|
location ~* \.(?:manifest|appcache|html?|xml|json)$ {
|
||||||
|
add_header Cache-Control "max-age=0";
|
||||||
}
|
}
|
||||||
|
|
||||||
location ~* \.(css|js|gif|jpe?g|png)$ {
|
location ~* \.(?:rss|atom)$ {
|
||||||
expires 1M;
|
add_header Cache-Control "max-age=3600";
|
||||||
add_header Pragma public;
|
|
||||||
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|mp4|ogg|ogv|webm|htc)$ {
|
||||||
|
add_header Cache-Control "max-age=2592000";
|
||||||
|
access_log off;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~* \.(?:css|js)$ {
|
||||||
|
add_header Cache-Control "max-age=31536000";
|
||||||
|
access_log off;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~* \.(?:ttf|ttc|otf|eot|woff|woff2)$ {
|
||||||
|
add_header Cache-Control "max-age=2592000";
|
||||||
|
access_log off;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Gzip compression
|
||||||
gzip on;
|
gzip on;
|
||||||
gzip_http_version 1.1;
|
gzip_comp_level 5;
|
||||||
gzip_vary on;
|
gzip_min_length 256;
|
||||||
gzip_comp_level 6;
|
|
||||||
gzip_proxied any;
|
gzip_proxied any;
|
||||||
gzip_types application/atom+xml
|
gzip_vary on;
|
||||||
application/javascript
|
gzip_types
|
||||||
application/json
|
application/atom+xml
|
||||||
application/vnd.ms-fontobject
|
application/javascript
|
||||||
application/x-font-ttf
|
application/json
|
||||||
application/x-web-app-manifest+json
|
application/ld+json
|
||||||
application/xhtml+xml
|
application/manifest+json
|
||||||
application/xml
|
application/rss+xml
|
||||||
font/opentype
|
application/vnd.geo+json
|
||||||
image/svg+xml
|
application/vnd.ms-fontobject
|
||||||
image/x-icon
|
application/x-font-ttf
|
||||||
text/css
|
application/x-web-app-manifest+json
|
||||||
text/plain
|
application/xhtml+xml
|
||||||
text/xml;
|
application/xml
|
||||||
gzip_buffers 16 8k;
|
font/opentype
|
||||||
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
|
image/bmp
|
||||||
|
image/svg+xml
|
||||||
|
image/x-icon
|
||||||
|
text/cache-manifest
|
||||||
|
text/css
|
||||||
|
text/plain
|
||||||
|
text/vcard
|
||||||
|
text/vnd.rim.location.xloc
|
||||||
|
text/vtt
|
||||||
|
text/x-component
|
||||||
|
text/x-cross-domain-policy;
|
||||||
|
|
||||||
# Include SSOWAT user panel.
|
# Include SSOWAT user panel.
|
||||||
# include conf.d/yunohost_panel.conf.inc;
|
# include conf.d/yunohost_panel.conf.inc;
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
; specific port;
|
; specific port;
|
||||||
; '/path/to/unix/socket' - to listen on a unix socket.
|
; '/path/to/unix/socket' - to listen on a unix socket.
|
||||||
; Note: This value is mandatory.
|
; Note: This value is mandatory.
|
||||||
listen = /var/run/php5-fpm-__USER__.sock
|
listen = /var/run/php-fpm-__USER__.sock
|
||||||
|
|
||||||
; Set listen(2) backlog. A value of '-1' means unlimited.
|
; Set listen(2) backlog. A value of '-1' means unlimited.
|
||||||
; Default Value: 128 (-1 on FreeBSD and OpenBSD)
|
; Default Value: 128 (-1 on FreeBSD and OpenBSD)
|
||||||
|
@ -246,7 +246,7 @@ catch_workers_output = yes
|
||||||
; Other common parameters
|
; Other common parameters
|
||||||
php_value[max_execution_time] = 600
|
php_value[max_execution_time] = 600
|
||||||
php_value[max_input_time] = 600
|
php_value[max_input_time] = 600
|
||||||
;php_value[memory_limit] = 256M
|
php_value[memory_limit] = 256M
|
||||||
;php_value[short_open_tag] = On
|
;php_value[short_open_tag] = On
|
||||||
|
|
||||||
env[COMPOSER_HOME] = __FINALPATH__/.composer
|
env[COMPOSER_HOME] = __FINALPATH__/.composer
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
; Common values to change to increase file upload limit
|
|
||||||
; upload_max_filesize = 50M
|
|
||||||
; post_max_size = 50M
|
|
||||||
; mail.add_x_header = Off
|
|
||||||
|
|
||||||
; Other common parameters
|
|
||||||
max_execution_time = 600
|
|
||||||
max_input_time = 300
|
|
||||||
memory_limit = 256M
|
|
||||||
; short_open_tag = On
|
|
|
@ -9,7 +9,7 @@
|
||||||
},
|
},
|
||||||
"url": "http://flarum.org/",
|
"url": "http://flarum.org/",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"version": "0.1.0-beta.7",
|
"version": "0.1.0-beta.9~ynh1",
|
||||||
"maintainer": {
|
"maintainer": {
|
||||||
"name": "tituspijean",
|
"name": "tituspijean",
|
||||||
"email": "tituspijean@outlook.com"
|
"email": "tituspijean@outlook.com"
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
"multi_instance": true,
|
"multi_instance": true,
|
||||||
"services": [
|
"services": [
|
||||||
"nginx",
|
"nginx",
|
||||||
"php5-fpm",
|
"php7.3-fpm",
|
||||||
"mysql"
|
"mysql"
|
||||||
],
|
],
|
||||||
"arguments": {
|
"arguments": {
|
||||||
|
|
|
@ -1,77 +1,38 @@
|
||||||
|
#=================================================
|
||||||
|
# COMMON VARIABLES
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# dependencies used by the app
|
||||||
|
pkg_dependencies="php7.3 php7.3-curl php7.3-dom php7.3-gd php7.3-json php7.3-mbstring php7.3-pdo-mysql php7.3-tokenizer php7.3-zip"
|
||||||
|
|
||||||
# Version numbers
|
# Version numbers
|
||||||
project_version="0.1.0-beta.7"
|
php_version="7.3"
|
||||||
flarum_version="0.1.0-beta.7.2"
|
project_version="0.1.0-beta.9"
|
||||||
ssowat_ext_ver="0.6"
|
core_version="0.1.0-beta.9"
|
||||||
|
ssowat_version="0.1.0-beta.9-1"
|
||||||
|
|
||||||
# Execute a command as another user
|
#=================================================
|
||||||
# usage: exec_as USER COMMAND [ARG ...]
|
# PERSONAL HELPERS
|
||||||
exec_as() {
|
#=================================================
|
||||||
local USER=$1
|
|
||||||
shift 1
|
|
||||||
|
|
||||||
if [[ $USER = $(whoami) ]]
|
|
||||||
then
|
|
||||||
eval $@
|
|
||||||
else
|
|
||||||
sudo -u "$USER" $@
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Execute a composer command from a given directory
|
|
||||||
# usage: composer_exec AS_USER WORKDIR COMMAND [ARG ...]
|
|
||||||
exec_composer() {
|
|
||||||
local AS_USER=$1
|
|
||||||
local WORKDIR=$2
|
|
||||||
shift 2
|
|
||||||
|
|
||||||
# Do not run composer as root
|
|
||||||
if [ $AS_USER = "root" ] ; then ynh_die "Do not run composer as root" ; fi
|
|
||||||
pushd "${WORKDIR}"
|
|
||||||
ynh_exec_warn_less \
|
|
||||||
"exec_as "$AS_USER" COMPOSER_HOME="${WORKDIR}/.composer" \
|
|
||||||
php -d memory_limit=-1 \
|
|
||||||
"${WORKDIR}/composer.phar" $@ \
|
|
||||||
--no-interaction"
|
|
||||||
popd
|
|
||||||
}
|
|
||||||
|
|
||||||
# Install and initialize Composer in the given directory
|
|
||||||
# usage: init_composer destdir
|
|
||||||
init_composer() {
|
|
||||||
local AS_USER=$1
|
|
||||||
local WORKDIR=$2
|
|
||||||
|
|
||||||
# Do not install composer as root
|
|
||||||
if [ $AS_USER = "root" ] ; then ynh_die "Do not install composer as root" ; fi
|
|
||||||
|
|
||||||
# install composer
|
|
||||||
curl -sS https://getcomposer.org/installer \
|
|
||||||
| ynh_exec_warn_less \
|
|
||||||
"COMPOSER_HOME="${WORKDIR}/.composer" php -- --install-dir="$WORKDIR"" \
|
|
||||||
|| ynh_die "Unable to install Composer"
|
|
||||||
chmod +x "${WORKDIR}/composer.phar"
|
|
||||||
# update dependencies to create composer.lock
|
|
||||||
#exec_composer "$AS_USER" "$WORKDIR" install --no-dev \
|
|
||||||
# || ynh_die "Unable to update core dependencies with Composer"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Install extension, and activate it in database
|
# Install extension, and activate it in database
|
||||||
# usage: install_and_activate_extension $user $final_path $db_name $extension $short_extension
|
# usage: install_and_activate_extension $user $php_version $final_path $db_name $extension $short_extension
|
||||||
# $extension is the "vendor/extension-name" string from packagist
|
# $extension is the "vendor/extension-name" string from packagist
|
||||||
# $short_extension is the extension name written in database, how it is shortened is still a mystery
|
# $short_extension is the extension name written in database, how it is shortened is still a mystery
|
||||||
install_and_activate_extension() {
|
install_and_activate_extension() {
|
||||||
local AS_USER=$1
|
local AS_USER=$1
|
||||||
local WORKDIR=$2
|
local PHP_VERSION=$2
|
||||||
local DB_NAME=$3
|
local WORKDIR=$3
|
||||||
local EXTENSION=$4
|
local DB_NAME=$4
|
||||||
local SHORT_EXTENSION=$5
|
local EXTENSION=$5
|
||||||
|
local SHORT_EXTENSION=$6
|
||||||
local sql_command
|
local sql_command
|
||||||
local old_extensions_enabled
|
local old_extensions_enabled
|
||||||
local addition
|
local addition
|
||||||
local new_extensions_enabled
|
local new_extensions_enabled
|
||||||
|
|
||||||
# Install extension
|
# Install extension
|
||||||
exec_composer $AS_USER $WORKDIR "require $EXTENSION -n --ansi -d $WORKDIR"
|
ynh_composer_exec $AS_USER $PHP_VERSION $WORKDIR "require $EXTENSION -n --ansi -d $WORKDIR"
|
||||||
|
|
||||||
# Retrieve current extensions
|
# Retrieve current extensions
|
||||||
sql_command="SELECT \`value\` FROM settings WHERE \`key\` = 'extensions_enabled'"
|
sql_command="SELECT \`value\` FROM settings WHERE \`key\` = 'extensions_enabled'"
|
||||||
|
@ -86,63 +47,8 @@ install_and_activate_extension() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Send an email to inform the administrator
|
#=================================================
|
||||||
#
|
# EXPERIMENTAL HELPERS
|
||||||
# usage: ynh_send_readme_to_admin app_message [recipients]
|
#=================================================
|
||||||
# | arg: app_message - The message to send to the administrator.
|
|
||||||
# | arg: recipients - The recipients of this email. Use spaces to separate multiples recipients. - default: root
|
|
||||||
# example: "root admin@domain"
|
|
||||||
# If you give the name of a YunoHost user, ynh_send_readme_to_admin will find its email adress for you
|
|
||||||
# example: "root admin@domain user1 user2"
|
|
||||||
ynh_send_readme_to_admin() {
|
|
||||||
local app_message="${1:-...No specific information...}"
|
|
||||||
local recipients="${2:-root}"
|
|
||||||
|
|
||||||
# Retrieve the email of users
|
# See ynh_* scripts
|
||||||
find_mails () {
|
|
||||||
local list_mails="$1"
|
|
||||||
local mail
|
|
||||||
local recipients=" "
|
|
||||||
# Read each mail in argument
|
|
||||||
for mail in $list_mails
|
|
||||||
do
|
|
||||||
# Keep root or a real email address as it is
|
|
||||||
if [ "$mail" = "root" ] || echo "$mail" | grep --quiet "@"
|
|
||||||
then
|
|
||||||
recipients="$recipients $mail"
|
|
||||||
else
|
|
||||||
# But replace an user name without a domain after by its email
|
|
||||||
if mail=$(ynh_user_get_info "$mail" "mail" 2> /dev/null)
|
|
||||||
then
|
|
||||||
recipients="$recipients $mail"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
echo "$recipients"
|
|
||||||
}
|
|
||||||
recipients=$(find_mails "$recipients")
|
|
||||||
|
|
||||||
local mail_subject="☁️🆈🅽🅷☁️: \`$app\` was just installed!"
|
|
||||||
|
|
||||||
local mail_message="This is an automated message from your beloved YunoHost server.
|
|
||||||
|
|
||||||
Specific information for the application $app.
|
|
||||||
|
|
||||||
$app_message
|
|
||||||
|
|
||||||
---
|
|
||||||
Automatic diagnosis data from YunoHost
|
|
||||||
|
|
||||||
$(yunohost tools diagnosis | grep -B 100 "services:" | sed '/services:/d')"
|
|
||||||
|
|
||||||
# Define binary to use for mail command
|
|
||||||
if [ -e /usr/bin/bsd-mailx ]
|
|
||||||
then
|
|
||||||
local mail_bin=/usr/bin/bsd-mailx
|
|
||||||
else
|
|
||||||
local mail_bin=/usr/bin/mail.mailutils
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Send the email to the recipients
|
|
||||||
echo "$mail_message" | $mail_bin -a "Content-Type: text/plain; charset=UTF-8" -s "$mail_subject" "$recipients"
|
|
||||||
}
|
|
||||||
|
|
|
@ -6,62 +6,73 @@
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
if [ ! -e _common.sh ]; then
|
#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||||
# Get the _common.sh file if it's not in the current directory
|
source ../settings/scripts/_common.sh
|
||||||
cp ../settings/scripts/_common.sh ./_common.sh
|
|
||||||
chmod a+rx _common.sh
|
|
||||||
fi
|
|
||||||
source _common.sh
|
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MANAGE SCRIPT FAILURE
|
# MANAGE SCRIPT FAILURE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
ynh_clean_setup () {
|
||||||
|
### Remove this function if there's nothing to clean before calling the remove script.
|
||||||
|
true
|
||||||
|
}
|
||||||
# Exit if an error occurs during the execution of the script
|
# Exit if an error occurs during the execution of the script
|
||||||
ynh_abort_if_errors
|
ynh_abort_if_errors
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Loading installation settings..." --time --weight=1
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
final_path=$(ynh_app_setting_get $app final_path)
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
domain=$(ynh_app_setting_get $app domain)
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
db_name=$(ynh_app_setting_get $app db_name)
|
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD BACKUP STEPS
|
# STANDARD BACKUP STEPS
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE APP MAIN DIR
|
# BACKUP THE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Backing up the main app directory..." --time --weight=1
|
||||||
|
|
||||||
ynh_backup "$final_path"
|
ynh_backup --src_path="$final_path"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE NGINX CONFIGURATION
|
# BACKUP THE NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Backing up nginx web server configuration..." --time --weight=1
|
||||||
|
|
||||||
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
|
# BACKUP THE PHP-FPM CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Backing up php-fpm configuration..." --time --weight=1
|
||||||
|
|
||||||
ynh_backup "/etc/php5/fpm/pool.d/$app.conf"
|
ynh_backup --src_path="/etc/php/7.0/fpm/pool.d/$app.conf"
|
||||||
ynh_backup "/etc/php5/fpm/conf.d/20-$app.ini"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE MYSQL DATABASE
|
# BACKUP THE MYSQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Backing up the MySQL database..." --time --weight=1
|
||||||
|
|
||||||
ynh_mysql_dump_db "$db_name" > db.sql
|
ynh_mysql_dump_db --database="$db_name" > db.sql
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC BACKUP
|
# SPECIFIC BACKUP
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP LOGROTATE
|
# BACKUP LOGROTATE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Backing up logrotate configuration..." --time --weight=1
|
||||||
|
|
||||||
ynh_backup "/etc/logrotate.d/$app"
|
ynh_backup --src_path="/etc/logrotate.d/$app"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --time --last
|
||||||
|
|
|
@ -24,22 +24,15 @@ app=$YNH_APP_INSTANCE_NAME
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Loading installation settings..." --time --weight=1
|
||||||
|
|
||||||
# Needed for helper "ynh_add_nginx_config"
|
# Needed for helper "ynh_add_nginx_config"
|
||||||
final_path=$(ynh_app_setting_get $app final_path)
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
|
|
||||||
# Add settings here as needed by your application
|
# Add settings here as needed by your application
|
||||||
#db_name=$(ynh_app_setting_get "$app" db_name)
|
#db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
#db_pwd=$(ynh_app_setting_get $app db_pwd)
|
#db_user=$db_name
|
||||||
|
#db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
|
||||||
#=================================================
|
|
||||||
# CHECK THE SYNTAX OF THE PATHS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK WHICH PARTS SHOULD BE CHANGED
|
# CHECK WHICH PARTS SHOULD BE CHANGED
|
||||||
|
@ -59,9 +52,17 @@ fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD MODIFICATIONS
|
# STANDARD MODIFICATIONS
|
||||||
|
#=================================================
|
||||||
|
# STOP SYSTEMD SERVICE
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Stopping a systemd service..." --time --weight=1
|
||||||
|
|
||||||
|
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MODIFY URL IN NGINX CONF
|
# 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
|
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
||||||
|
|
||||||
|
@ -69,17 +70,15 @@ nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
||||||
if [ $change_path -eq 1 ]
|
if [ $change_path -eq 1 ]
|
||||||
then
|
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"
|
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
|
||||||
# Set global variables for nginx helper
|
# Set global variables for nginx helper
|
||||||
domain="$old_domain"
|
domain="$old_domain"
|
||||||
path_url="$new_path"
|
path_url="$new_path"
|
||||||
# Bug in Nginx with locations and aliases (see http://stackoverflow.com/a/35102259 )
|
# Bug in Nginx with locations and aliases (see http://stackoverflow.com/a/35102259 )
|
||||||
if [ $path_url = "/" ]; then
|
if [ $path_url = "/" ]; then
|
||||||
sed -i "s@__LOCATION_HACK__@@g" ../conf/nginx.conf
|
ynh_replace_string "__PATH_HACK__" "" "../conf/nginx.conf"
|
||||||
sed -i "s@__PATH_HACK__@/@g" ../conf/nginx.conf
|
|
||||||
else
|
else
|
||||||
sed -i "s@__LOCATION_HACK__@$path_url@g" ../conf/nginx.conf
|
ynh_replace_string "__PATH_HACK__" "$path_url" "../conf/nginx.conf"
|
||||||
sed -i "s@__PATH_HACK__@$path_url$path_url@g" ../conf/nginx.conf
|
|
||||||
fi
|
fi
|
||||||
# Create a dedicated nginx config
|
# Create a dedicated nginx config
|
||||||
ynh_add_nginx_config
|
ynh_add_nginx_config
|
||||||
|
@ -89,32 +88,36 @@ fi
|
||||||
if [ $change_domain -eq 1 ]
|
if [ $change_domain -eq 1 ]
|
||||||
then
|
then
|
||||||
# Delete file checksum for the old conf file location
|
# Delete file checksum for the old conf file location
|
||||||
ynh_delete_file_checksum "$nginx_conf_path"
|
ynh_delete_file_checksum --file="$nginx_conf_path"
|
||||||
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
||||||
# Store file checksum for the new config file location
|
# Store file checksum for the new config file location
|
||||||
ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC MODIFICATIONS
|
# SPECIFIC MODIFICATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
# MODIFY URL IN CONFIG.PHP
|
# ...
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
if [ $change_domain -eq 1 ]
|
|
||||||
then
|
|
||||||
ynh_replace_string $old_domain $new_domain $final_path/config.php
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $change_path -eq 1 ]
|
|
||||||
then
|
|
||||||
ynh_replace_string $old_path $new_path $final_path/config.php
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALISATION
|
# GENERIC FINALISATION
|
||||||
|
#=================================================
|
||||||
|
# START SYSTEMD SERVICE
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Starting a systemd service..." --time --weight=1
|
||||||
|
|
||||||
|
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Reloading nginx web server..." --time --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" --time --last
|
||||||
|
|
|
@ -7,6 +7,9 @@
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
source _common.sh
|
source _common.sh
|
||||||
|
source ynh_exec_as
|
||||||
|
source ynh_composer__2
|
||||||
|
source ynh_send_readme_to_admin__2
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -69,16 +72,35 @@ ynh_app_setting_set $app admin $admin
|
||||||
ynh_app_setting_set $app is_public $is_public
|
ynh_app_setting_set $app is_public $is_public
|
||||||
ynh_app_setting_set $app language $language
|
ynh_app_setting_set $app language $language
|
||||||
ynh_app_setting_set $app final_path $final_path
|
ynh_app_setting_set $app final_path $final_path
|
||||||
|
ynh_app_setting_set $app php_version $php_version
|
||||||
ynh_app_setting_set $app project_version $project_version
|
ynh_app_setting_set $app project_version $project_version
|
||||||
ynh_app_setting_set $app flarum_version $flarum_version
|
ynh_app_setting_set $app core_version $core_version
|
||||||
ynh_app_setting_set $app ssowat_ext_ver $ssowat_ext_ver
|
ynh_app_setting_set $app ssowat_version $ssowat_version
|
||||||
ynh_app_setting_set $app bazaar_extension $bazaar_extension
|
ynh_app_setting_set $app bazaar_extension $bazaar_extension
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# STANDARD MODIFICATIONS
|
||||||
|
#=================================================
|
||||||
|
# INSTALL DEPENDENCIES
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Installing dependencies..." --time --weight=1
|
||||||
|
|
||||||
|
### `ynh_install_app_dependencies` allows you to add any "apt" dependencies to the package.
|
||||||
|
### Those deb packages will be installed as dependencies of this package.
|
||||||
|
### If you're not using this helper:
|
||||||
|
### - Remove the section "REMOVE DEPENDENCIES" in the remove script
|
||||||
|
### - Remove the variable "pkg_dependencies" in _common.sh
|
||||||
|
### - As well as the section "REINSTALL DEPENDENCIES" in the restore script
|
||||||
|
### - And the section "UPGRADE DEPENDENCIES" in the upgrade script
|
||||||
|
|
||||||
|
#ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
apt install $pkg_dependencies
|
||||||
|
|
||||||
#===================================================
|
#===================================================
|
||||||
# CREATE DEDICATED USER
|
# CREATE DEDICATED USER
|
||||||
#===================================================
|
#===================================================
|
||||||
|
|
||||||
ynh_system_user_create $app $final_path
|
ynh_system_user_create $app $final_path 1
|
||||||
sudo usermod -a -G www-data $app
|
sudo usermod -a -G www-data $app
|
||||||
# Create working directory
|
# Create working directory
|
||||||
sudo mkdir -p "$final_path/.composer"
|
sudo mkdir -p "$final_path/.composer"
|
||||||
|
@ -89,7 +111,8 @@ sudo chmod -R 0775 $final_path
|
||||||
# COMPOSER INSTALLATION
|
# COMPOSER INSTALLATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
init_composer $app $final_path
|
ynh_script_progression --message="Installing Composer..." --time --weight=1
|
||||||
|
ynh_install_composer $php_version $final_path
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# FLARUM INSTALLATION
|
# FLARUM INSTALLATION
|
||||||
|
@ -102,18 +125,21 @@ sudo chown -R $app:www-data $tmp
|
||||||
sudo chmod -R 0775 $tmp
|
sudo chmod -R 0775 $tmp
|
||||||
|
|
||||||
# Install Flarum
|
# Install Flarum
|
||||||
ynh_print_info "Composer is installing Flarum and its dependencies. It may take a while..."
|
ynh_script_progression --message="Composer is installing Flarum and its dependencies (may take a while)..." --time --weight=3
|
||||||
|
|
||||||
# First, create the project with core and all basic extensions
|
# First, create the project with core and all basic extensions
|
||||||
exec_composer $app $final_path "create-project flarum/flarum=$project_version $tmp --stability=beta --ansi -d $tmp"
|
ynh_composer_exec $app $php_version $final_path "create-project flarum/flarum=$project_version $tmp --stability=beta --ansi -d $tmp"
|
||||||
# Let's fix the core version by explicitely requiring it
|
# Let's fix the core version by explicitely requiring it
|
||||||
exec_composer $app $final_path "require flarum/core:$flarum_version -n --ansi -d $tmp"
|
ynh_composer_exec $app $php_version $final_path "require flarum/core:$core_version -n --ansi -d $tmp"
|
||||||
|
|
||||||
# Copy Flarum to working directory and clean temp directory
|
# Copy Flarum to working directory and clean temp directory
|
||||||
sudo cp -Rf $tmp/* $final_path
|
sudo cp -Rf $tmp/* $final_path
|
||||||
sudo chown -R $app:www-data $final_path
|
|
||||||
sudo chmod -R 0775 $final_path
|
|
||||||
ynh_secure_remove $tmp
|
ynh_secure_remove $tmp
|
||||||
ynh_print_info " ... done!"
|
|
||||||
|
# Set right permissions for the post-installation
|
||||||
|
chown -R $app: $final_path
|
||||||
|
chown -R $app:www-data $final_path/storage
|
||||||
|
sudo chmod -R 0775 $final_path
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE A MYSQL DATABASE
|
# CREATE A MYSQL DATABASE
|
||||||
|
@ -130,12 +156,11 @@ ynh_app_setting_set "$app" db_pwd "$db_pwd"
|
||||||
|
|
||||||
# Bug in Nginx with locations and aliases (see http://stackoverflow.com/a/35102259 )
|
# Bug in Nginx with locations and aliases (see http://stackoverflow.com/a/35102259 )
|
||||||
if [ $path_url = "/" ]; then
|
if [ $path_url = "/" ]; then
|
||||||
ynh_replace_string "__LOCATION_HACK__" "" "../conf/nginx.conf"
|
ynh_replace_string "__PATH_HACK__" "" "../conf/nginx.conf"
|
||||||
ynh_replace_string "__PATH_HACK__" "/" "../conf/nginx.conf"
|
|
||||||
else
|
else
|
||||||
ynh_replace_string "__LOCATION_HACK__" "$path_url" "../conf/nginx.conf"
|
ynh_replace_string "__PATH_HACK__" "$path_url" "../conf/nginx.conf"
|
||||||
ynh_replace_string "__PATH_HACK__" "$path_url$path_url" "../conf/nginx.conf"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create a dedicated nginx config
|
# Create a dedicated nginx config
|
||||||
ynh_add_nginx_config
|
ynh_add_nginx_config
|
||||||
|
|
||||||
|
@ -144,7 +169,7 @@ ynh_add_nginx_config
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Create a dedicated php-fpm config
|
# Create a dedicated php-fpm config
|
||||||
ynh_add_fpm_config
|
ynh_add_fpm_config $php_version
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP LOGROTATE
|
# SETUP LOGROTATE
|
||||||
|
@ -177,8 +202,8 @@ systemctl reload nginx
|
||||||
#=================================================
|
#=================================================
|
||||||
# FLARUM POST-INSTALL
|
# FLARUM POST-INSTALL
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Configuring Flarum..." --time --weight=2
|
||||||
|
|
||||||
ynh_print_info "Configuring Flarum..."
|
|
||||||
# Copy the configuration.yml to working directory
|
# Copy the configuration.yml to working directory
|
||||||
finalflarumconf="$final_path/configuration.yml"
|
finalflarumconf="$final_path/configuration.yml"
|
||||||
cp ../conf/configuration.yml $finalflarumconf
|
cp ../conf/configuration.yml $finalflarumconf
|
||||||
|
@ -197,9 +222,9 @@ ynh_replace_string "__ADMIN_EML__" "$admin_mail" "$finalflarumconf"
|
||||||
ynh_replace_string "__FORUM_TITLE__" "$title" "$finalflarumconf"
|
ynh_replace_string "__FORUM_TITLE__" "$title" "$finalflarumconf"
|
||||||
# Execute post-installation
|
# Execute post-installation
|
||||||
pushd $final_path
|
pushd $final_path
|
||||||
exec_as $app "php -d $final_path -d memory_limit=-1 flarum install -f configuration.yml"
|
exec_as $app php$php_version -d $final_path -d memory_limit=-1 flarum install -f configuration.yml
|
||||||
# Delete configuration.yml as it sensitive data
|
# Delete configuration.yml as it contains sensitive data
|
||||||
ynh_secure_remove $finalflarumconf
|
ynh_secure_remove $finalflarumconf
|
||||||
popd
|
popd
|
||||||
|
|
||||||
# Email setup
|
# Email setup
|
||||||
|
@ -210,10 +235,11 @@ sql_command="REPLACE INTO \`settings\` (\`key\`, \`value\`) VALUES
|
||||||
('mail_host', 'localhost'),
|
('mail_host', 'localhost'),
|
||||||
('mail_port', '587');"
|
('mail_port', '587');"
|
||||||
ynh_mysql_execute_as_root "$sql_command" $db_name
|
ynh_mysql_execute_as_root "$sql_command" $db_name
|
||||||
ynh_print_info " ... done!"
|
|
||||||
|
|
||||||
# Install and activate the SSOwat auth extension
|
# Install and activate the SSOwat auth extension
|
||||||
install_and_activate_extension $app $final_path $db_name "tituspijean/flarum-ext-auth-ssowat:$ssowat_ext_ver" "tituspijean-auth-ssowat"
|
ynh_script_progression --message="Installing SSOwat extension..." --time --weight=2
|
||||||
|
install_and_activate_extension $app $php_version $final_path $db_name "tituspijean/flarum-ext-auth-ssowat:$ssowat_version" "tituspijean-auth-ssowat"
|
||||||
# Configure SSOwat auth extension
|
# Configure SSOwat auth extension
|
||||||
ssowatdomain=$(</etc/yunohost/current_host)
|
ssowatdomain=$(</etc/yunohost/current_host)
|
||||||
sql_command="INSERT INTO \`settings\` (\`key\`, \`value\`) VALUES ('tituspijean-auth-ssowat.domain', '$ssowatdomain'), ('tituspijean-auth-ssowat.onlyUse', '0');"
|
sql_command="INSERT INTO \`settings\` (\`key\`, \`value\`) VALUES ('tituspijean-auth-ssowat.domain', '$ssowatdomain'), ('tituspijean-auth-ssowat.onlyUse', '0');"
|
||||||
|
@ -223,25 +249,29 @@ ynh_print_info "SSOwat extension has been installed."
|
||||||
# Install, activate and set language extensions
|
# Install, activate and set language extensions
|
||||||
case $language in
|
case $language in
|
||||||
fr)
|
fr)
|
||||||
install_and_activate_extension $app $final_path $db_name "milescellar/flarum-ext-french" "milescellar-french"
|
ynh_script_progression --message="Installing French extension..." --time --weight=2
|
||||||
|
install_and_activate_extension $app $php_version $final_path $db_name "milescellar/flarum-ext-french" "milescellar-french"
|
||||||
sql_command="UPDATE \`settings\` SET \`value\` = 'fr' WHERE \`settings\`.\`key\` = 'default_locale'"
|
sql_command="UPDATE \`settings\` SET \`value\` = 'fr' WHERE \`settings\`.\`key\` = 'default_locale'"
|
||||||
ynh_mysql_execute_as_root "$sql_command" $db_name
|
ynh_mysql_execute_as_root "$sql_command" $db_name
|
||||||
ynh_print_info "French language has been installed."
|
|
||||||
;;
|
;;
|
||||||
de)
|
de)
|
||||||
install_and_activate_extension $app $final_path $db_name "cbmainz/flarum-de" "cbmainz-de"
|
ynh_script_progression --message="Installing German extension..." --time --weight=2
|
||||||
|
install_and_activate_extension $app $php_version $final_path $db_name "cbmainz/flarum-de" "cbmainz-de"
|
||||||
sql_command="UPDATE \`settings\` SET \`value\` = 'de' WHERE \`settings\`.\`key\` = 'default_locale'"
|
sql_command="UPDATE \`settings\` SET \`value\` = 'de' WHERE \`settings\`.\`key\` = 'default_locale'"
|
||||||
ynh_mysql_execute_as_root "$sql_command" $db_name
|
ynh_mysql_execute_as_root "$sql_command" $db_name
|
||||||
ynh_print_info "German language has been installed."
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [ $bazaar_extension -eq 1 ]; then
|
if [ $bazaar_extension -eq 1 ]; then
|
||||||
exec_composer $app $final_path "require flagrow/bazaar --ansi"
|
ynh_script_progression --message="Installing Bazaar extension..." --time --weight=2
|
||||||
ynh_print_info "Bazaar extension has been installed."
|
ynh_composer_exec $app $php_version $final_path "require flagrow/bazaar --ansi"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Send login credentials to admin
|
#=================================================
|
||||||
|
# SEND CREDENTIALS TO ADMIN
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Sending generated admin credentials by email, but you can log in with your YunoHost credentials!" --time --weight=1
|
||||||
app_message="User : $admin, password : $admin_pwd
|
app_message="User : $admin, password : $admin_pwd
|
||||||
Change your password!
|
Change your password!
|
||||||
Your forum is accessible at https://$domain$path_url"
|
Your forum is accessible at https://$domain$path_url"
|
||||||
|
|
|
@ -12,32 +12,46 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Loading installation settings..." --time --weight=1
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
domain=$(ynh_app_setting_get $app domain)
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
db_name=$(ynh_app_setting_get $app db_name)
|
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||||
|
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
db_user=$db_name
|
db_user=$db_name
|
||||||
final_path=$(ynh_app_setting_get $app final_path)
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# STANDARD REMOVE
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE THE MYSQL DATABASE
|
# REMOVE THE MYSQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Removing the MySQL database..." --time --weight=1
|
||||||
|
|
||||||
# Remove a database if it exists, along with the associated user
|
# Remove a database if it exists, along with the associated user
|
||||||
ynh_mysql_remove_db $db_user $db_name
|
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# REMOVE DEPENDENCIES
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Removing dependencies..." --time --weight=1
|
||||||
|
|
||||||
|
# Remove metapackage and its dependencies
|
||||||
|
ynh_remove_app_dependencies
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE APP MAIN DIR
|
# REMOVE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Removing app main directory..." --time --weight=1
|
||||||
|
|
||||||
# Remove the app directory securely
|
# Remove the app directory securely
|
||||||
ynh_secure_remove "$final_path"
|
ynh_secure_remove --file="$final_path"
|
||||||
ynh_secure_remove "/tmp/$app"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE NGINX CONFIGURATION
|
# REMOVE NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Removing nginx web server configuration..." --time --weight=1
|
||||||
|
|
||||||
# Remove the dedicated nginx config
|
# Remove the dedicated nginx config
|
||||||
ynh_remove_nginx_config
|
ynh_remove_nginx_config
|
||||||
|
@ -45,6 +59,7 @@ ynh_remove_nginx_config
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE PHP-FPM CONFIGURATION
|
# REMOVE PHP-FPM CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Removing php-fpm configuration..." --time --weight=1
|
||||||
|
|
||||||
# Remove the dedicated php-fpm config
|
# Remove the dedicated php-fpm config
|
||||||
ynh_remove_fpm_config
|
ynh_remove_fpm_config
|
||||||
|
@ -52,15 +67,35 @@ ynh_remove_fpm_config
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE LOGROTATE CONFIGURATION
|
# REMOVE LOGROTATE CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Removing logrotate configuration..." --time --weight=1
|
||||||
|
|
||||||
# Remove the app-specific logrotate config
|
# Remove the app-specific logrotate config
|
||||||
ynh_remove_logrotate
|
ynh_remove_logrotate
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SPECIFIC REMOVE
|
||||||
|
#=================================================
|
||||||
|
# REMOVE THE CRON FILE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Remove a temp directory securely
|
||||||
|
ynh_secure_remove --file="/tmp/$app/"
|
||||||
|
|
||||||
|
# Remove the log files
|
||||||
|
ynh_secure_remove --file="/var/log/$app/"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE DEDICATED USER
|
# REMOVE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Removing the dedicated system user..." --time --weight=1
|
||||||
|
|
||||||
# Delete a system user
|
# 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" --time --last
|
||||||
|
|
|
@ -42,14 +42,40 @@ test ! -d $final_path \
|
||||||
# RESTORE THE NGINX CONFIGURATION
|
# RESTORE THE NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE APP MAIN DIR
|
# RESTORE THE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Restoring the app main directory..." --time --weight=1
|
||||||
|
|
||||||
ynh_restore_file "$final_path"
|
ynh_restore_file --origin_path="$final_path"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RECREATE THE DEDICATED USER
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Recreating the dedicated system user..." --time --weight=1
|
||||||
|
|
||||||
|
# Create the dedicated user (if not existing)
|
||||||
|
ynh_system_user_create --username=$app
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RESTORE USER RIGHTS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Set right permissions
|
||||||
|
chown -R $app: $final_path
|
||||||
|
chown -R $app:www-data $final_path/storage
|
||||||
|
sudo chmod -R 0775 $final_path
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RESTORE THE PHP-FPM CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_restore_file --origin_path="/etc/php/${php_version}/fpm/pool.d/$app.conf"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SPECIFIC RESTORATION
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE MYSQL DATABASE
|
# RESTORE THE MYSQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -58,28 +84,6 @@ db_pwd=$(ynh_app_setting_get $app mysqlpwd)
|
||||||
ynh_mysql_setup_db $db_name $db_name $db_pwd
|
ynh_mysql_setup_db $db_name $db_name $db_pwd
|
||||||
ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql
|
ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RECREATE THE DEDICATED USER
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# Create the dedicated user (if not existing)
|
|
||||||
ynh_system_user_create $app
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RESTORE USER RIGHTS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# Restore permissions on app files
|
|
||||||
chown -R $app:www-data $final_path
|
|
||||||
chmod -R 0775 $final_path
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RESTORE THE PHP-FPM CONFIGURATION
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
ynh_restore_file "/etc/php5/fpm/pool.d/$app.conf"
|
|
||||||
ynh_restore_file "/etc/php5/fpm/conf.d/20-$app.ini"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE LOGROTATE CONFIGURATION
|
# RESTORE THE LOGROTATE CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -91,6 +95,13 @@ ynh_restore_file "/etc/logrotate.d/$app"
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX AND PHP-FPM
|
# RELOAD NGINX AND PHP-FPM
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Reloading nginx web server and php-fpm..." --time --weight=1
|
||||||
|
|
||||||
systemctl reload php5-fpm
|
ynh_systemd_action --service_name=php${php_version}-fpm --action=reload
|
||||||
systemctl reload nginx
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Restoration completed for $app" --time --last
|
||||||
|
|
311
scripts/upgrade
311
scripts/upgrade
|
@ -10,40 +10,235 @@ source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MANAGE SCRIPT FAILURE
|
# LOAD SETTINGS
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Loading installation settings..." --time --weight=1
|
||||||
|
|
||||||
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
|
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||||
|
admin=$(ynh_app_setting_get --app=$app --key=admin)
|
||||||
|
is_public=$(ynh_app_setting_get --app=$app --key=is_public)
|
||||||
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
|
language=$(ynh_app_setting_get --app=$app --key=language)
|
||||||
|
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
|
db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
|
||||||
|
old_project_version=$(ynh_app_setting_get --app=$app --key=project_version)
|
||||||
|
old_core_version=$(ynh_app_setting_get --app=$app --key=core_version)
|
||||||
|
old_ssowat_version=$(ynh_app_setting_get --app=$app --key=ssowat_version)
|
||||||
|
bazaar_extension=$(ynh_app_setting_get --app=$app --key=bazaar_extension)
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CHECK VERSION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
### This helper will compare the version of the currently installed app and the version of the upstream package.
|
||||||
|
### $upgrade_type can have 2 different values
|
||||||
|
### - UPGRADE_APP if the upstream app version has changed
|
||||||
|
### - UPGRADE_PACKAGE if only the YunoHost package has changed
|
||||||
|
### ynh_check_app_version_changed will stop the upgrade if the app is up to date.
|
||||||
|
### UPGRADE_APP should be used to upgrade the core app only if there's an upgrade to do.
|
||||||
|
upgrade_type=$(ynh_check_app_version_changed)
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# ENSURE DOWNWARD COMPATIBILITY
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1
|
||||||
|
|
||||||
|
# Fix is_public as a boolean value
|
||||||
|
if [ "$is_public" = "Yes" ]; then
|
||||||
|
ynh_app_setting_set --app=$app --key=is_public --value=1
|
||||||
|
is_public=1
|
||||||
|
elif [ "$is_public" = "No" ]; then
|
||||||
|
ynh_app_setting_set --app=$app --key=is_public --value=0
|
||||||
|
is_public=0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If db_name doesn't exist, create it
|
||||||
|
if [ -z "$db_name" ]; then
|
||||||
|
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
||||||
|
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If final_path doesn't exist, create it
|
||||||
|
if [ -z "$final_path" ]; then
|
||||||
|
final_path=/var/www/$app
|
||||||
|
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||||
|
fi
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --time --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
|
# Exit if an error occurs during the execution of the script
|
||||||
ynh_abort_if_errors
|
ynh_abort_if_errors
|
||||||
|
|
||||||
#===================================================
|
#=================================================
|
||||||
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
# CHECK THE PATH
|
||||||
#===================================================
|
#=================================================
|
||||||
|
|
||||||
# This is a multi-instance app, meaning it can be installed several times independently
|
# Normalize the URL path syntax
|
||||||
# The id of the app as stated in the manifest is available as $YNH_APP_ID
|
# N.B. : this is for app installations before YunoHost 2.7
|
||||||
# The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...)
|
# where this value might be something like /foo/ or foo/
|
||||||
# The app instance name is available as $YNH_APP_INSTANCE_NAME
|
# instead of /foo ....
|
||||||
# - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample
|
# If nobody installed your app before 2.7, then you may
|
||||||
# - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2
|
# safely remove this line
|
||||||
# - ynhexample__{N} for the subsequent installations, with N=3,4, ...
|
path_url=$(ynh_normalize_url_path --path_url=$path_url)
|
||||||
# The app instance name is probably what you are interested the most, since this is
|
|
||||||
# guaranteed to be unique. This is a good unique identifier to define installation path,
|
#=================================================
|
||||||
# db names, ...
|
# STANDARD UPGRADE STEPS
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
#=================================================
|
||||||
|
# NGINX CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Upgrading nginx web server configuration..." --time --weight=1
|
||||||
|
|
||||||
|
# Create a dedicated nginx config
|
||||||
|
ynh_add_nginx_config
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# UPGRADE DEPENDENCIES
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Upgrading dependencies..." --time --weight=1
|
||||||
|
|
||||||
|
# Bug in Nginx with locations and aliases (see http://stackoverflow.com/a/35102259 )
|
||||||
|
if [ $path_url = "/" ]; then
|
||||||
|
ynh_replace_string "__PATH_HACK__" "" "../conf/nginx.conf"
|
||||||
|
else
|
||||||
|
ynh_replace_string "__PATH_HACK__" "$path_url" "../conf/nginx.conf"
|
||||||
|
fi
|
||||||
|
|
||||||
|
ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CREATE DEDICATED USER
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Making sure dedicated system user exists..." --time --weight=1
|
||||||
|
|
||||||
|
# Create a dedicated user (if not existing)
|
||||||
|
ynh_system_user_create --username=$app
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# PHP-FPM CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Upgrading php-fpm configuration..." --time --weight=1
|
||||||
|
|
||||||
|
# Create a dedicated php-fpm config
|
||||||
|
ynh_add_fpm_config
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SPECIFIC UPGRADE
|
||||||
|
#=================================================
|
||||||
|
# COMPOSER UPGRADE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
if ! type "$final_path/composer.phar" > /dev/null; then
|
||||||
|
ynh_install_composer $php_version $final_path
|
||||||
|
fi
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# FLARUM UPGRADE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Downward compatibility: remove the v before version number
|
||||||
|
if [[ $old_project_version == "v*" ]]; then $old_project_version = ${old_project_version:1}; fi
|
||||||
|
# Check if upgrade of Flarum core is needed
|
||||||
|
if [[ $(dpkg --compare-versions $old_project_version lt $project_version && echo true) ]]; then
|
||||||
|
# Upgrade Flarum
|
||||||
|
ynh_composer_exec $app $php_version $final_path "require -n flarum/core:$project_version"
|
||||||
|
# Database password has to be input on admin page after upgrade to 0.1.0-beta.7.2
|
||||||
|
if [[ $project_version == "0.1.0-beta.7.2" ]]; then
|
||||||
|
curl "https://$domain$path_url/admin" -H "Accept: */*" --compressed -H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" --data "databasePassword=$db_pwd" -k
|
||||||
|
fi
|
||||||
|
pushd $final_path
|
||||||
|
exec_as $app php flarum cache:clear
|
||||||
|
popd
|
||||||
|
ynh_print_info "Flarum has been updated to version $project_version."
|
||||||
|
upgraded_flarum=true
|
||||||
|
else
|
||||||
|
ynh_print_info "Flarum does not need updating."
|
||||||
|
upgraded_flarum=false
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if upgrade of SSOwat extension is needed
|
||||||
|
if [[ $(dpkg --compare-versions $old_ssowat_version lt $ssowat_version && echo true) || -z $old_ssowat_version ]]; then
|
||||||
|
# Install and activate the SSOwat auth extension
|
||||||
|
install_and_activate_extension $app $final_path $db_name "tituspijean/flarum-ext-auth-ssowat:$ssowat_version" "tituspijean-auth-ssowat"
|
||||||
|
# Configure SSOwat auth extension
|
||||||
|
ssowatdomain=$(</etc/yunohost/current_host)
|
||||||
|
sql_command="INSERT IGNORE INTO \`settings\` (\`key\`, \`value\`) VALUES ('tituspijean-auth-ssowat.domain', '$ssowatdomain'), ('tituspijean-auth-ssowat.onlyUse', '0');"
|
||||||
|
ynh_mysql_execute_as_root "$sql_command" $db_name
|
||||||
|
ynh_print_info "SSOwat extension has been updated and configured."
|
||||||
|
upgraded_ssowat=true
|
||||||
|
else
|
||||||
|
ynh_print_info "SSOwat extension does not need updating."
|
||||||
|
upgraded_ssowat=false
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $bazaar_extension -eq 1 ]; then
|
||||||
|
install_and_activate_extension $app $final_path $db_name "flagrow/bazaar" "flagrow-bazaar"
|
||||||
|
ynh_print_info "Bazaar extension has been installed."
|
||||||
|
fi
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SETUP LOGROTATE
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Upgrading logrotate configuration..." --time --weight=1
|
||||||
|
|
||||||
|
# Use logrotate to manage app-specific logfile(s)
|
||||||
|
ynh_use_logrotate --non-append
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC FINALIZATION
|
||||||
|
#=================================================
|
||||||
|
# SECURE FILES AND DIRECTORIES
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Set permissions on app files
|
||||||
|
chown -R $app: $final_path
|
||||||
|
chown -R $app:www-data $final_path/storage
|
||||||
|
sudo chmod -R 0775 $final_path
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SETUP SSOWAT
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Upgrading SSOwat configuration..." --time --weight=1
|
||||||
|
|
||||||
|
# Make app public if necessary
|
||||||
|
if [ $is_public -eq 1 ]
|
||||||
|
then
|
||||||
|
# unprotected_uris allows SSO credentials to be passed anyway
|
||||||
|
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
|
||||||
|
fi
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# START SYSTEMD SERVICE
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Starting a systemd service..." --time --weight=1
|
||||||
|
|
||||||
|
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RELOAD NGINX
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Reloading nginx web server..." --time --weight=1
|
||||||
|
|
||||||
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Upgrade of $app completed" --time --last
|
||||||
|
|
||||||
# Retrieve app settings
|
|
||||||
|
|
||||||
domain=$(ynh_app_setting_get "$app" domain)
|
|
||||||
path_url=$(ynh_app_setting_get "$app" path)
|
|
||||||
admin=$(ynh_app_setting_get "$app" admin)
|
|
||||||
is_public=$(ynh_app_setting_get "$app" is_public)
|
|
||||||
final_path=$(ynh_app_setting_get "$app" final_path)
|
|
||||||
db_name=$(ynh_app_setting_get $app db_name)
|
|
||||||
db_pwd=$(ynh_app_setting_get $app db_pwd)
|
|
||||||
old_flarum_version=$(ynh_app_setting_get "$app" flarum_version)
|
|
||||||
old_ssowat_ext_ver=$(ynh_app_setting_get "$app" ssowat_ext_ver)
|
|
||||||
bazaar_extension=$(ynh_app_setting_get "$app" bazaar_extension)
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# ENSURE DOWNWARD COMPATIBILITY
|
# ENSURE DOWNWARD COMPATIBILITY
|
||||||
|
@ -99,57 +294,6 @@ path_url=$(ynh_normalize_url_path $path_url)
|
||||||
# Create a system user
|
# Create a system user
|
||||||
ynh_system_user_create $app
|
ynh_system_user_create $app
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# COMPOSER UPGRADE
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
if ! type "$final_path/composer.phar" > /dev/null; then
|
|
||||||
init_composer $app $final_path
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# FLARUM UPGRADE
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# Downward compatibility: remove the v before version number
|
|
||||||
if [[ $old_flarum_version == "v*" ]]; then $old_flarum_version = ${old_flarum_version:1}; fi
|
|
||||||
# Check if upgrade of Flarum core is needed
|
|
||||||
if [[ $(dpkg --compare-versions $old_flarum_version lt $flarum_version && echo true) ]]; then
|
|
||||||
# Upgrade Flarum
|
|
||||||
exec_composer $app $final_path "require -n flarum/core:$flarum_version"
|
|
||||||
# Database password has to be input on admin page after upgrade to 0.1.0-beta.7.2
|
|
||||||
if [[ $flarum_version == "0.1.0-beta.7.2" ]]; then
|
|
||||||
curl "https://$domain$path_url/admin" -H "Accept: */*" --compressed -H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" --data "databasePassword=$db_pwd" -k
|
|
||||||
fi
|
|
||||||
pushd $final_path
|
|
||||||
exec_as $app php flarum cache:clear
|
|
||||||
popd
|
|
||||||
ynh_print_info "Flarum has been updated to version $flarum_version."
|
|
||||||
upgraded_flarum=true
|
|
||||||
else
|
|
||||||
ynh_print_info "Flarum does not need updating."
|
|
||||||
upgraded_flarum=false
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if upgrade of SSOwat extension is needed
|
|
||||||
if [[ $(dpkg --compare-versions $old_ssowat_ext_ver lt $ssowat_ext_ver && echo true) || -z $old_ssowat_ext_ver ]]; then
|
|
||||||
# Install and activate the SSOwat auth extension
|
|
||||||
install_and_activate_extension $app $final_path $db_name "tituspijean/flarum-ext-auth-ssowat:$ssowat_ext_ver" "tituspijean-auth-ssowat"
|
|
||||||
# Configure SSOwat auth extension
|
|
||||||
ssowatdomain=$(</etc/yunohost/current_host)
|
|
||||||
sql_command="INSERT IGNORE INTO \`settings\` (\`key\`, \`value\`) VALUES ('tituspijean-auth-ssowat.domain', '$ssowatdomain'), ('tituspijean-auth-ssowat.onlyUse', '0');"
|
|
||||||
ynh_mysql_execute_as_root "$sql_command" $db_name
|
|
||||||
ynh_print_info "SSOwat extension has been updated and configured."
|
|
||||||
upgraded_ssowat=true
|
|
||||||
else
|
|
||||||
ynh_print_info "SSOwat extension does not need updating."
|
|
||||||
upgraded_ssowat=false
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $bazaar_extension -eq 1 ]; then
|
|
||||||
install_and_activate_extension $app $final_path $db_name "flagrow/bazaar" "flagrow-bazaar"
|
|
||||||
ynh_print_info "Bazaar extension has been installed."
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# NGINX CONFIGURATION
|
# NGINX CONFIGURATION
|
||||||
|
@ -157,11 +301,9 @@ fi
|
||||||
|
|
||||||
# Bug in Nginx with locations and aliases (see http://stackoverflow.com/a/35102259 )
|
# Bug in Nginx with locations and aliases (see http://stackoverflow.com/a/35102259 )
|
||||||
if [ $path_url = "/" ]; then
|
if [ $path_url = "/" ]; then
|
||||||
ynh_replace_string "__LOCATION_HACK__" "" "../conf/nginx.conf"
|
ynh_replace_string "__PATH_HACK__" "" "../conf/nginx.conf"
|
||||||
ynh_replace_string "__PATH_HACK__" "/" "../conf/nginx.conf"
|
|
||||||
else
|
else
|
||||||
ynh_replace_string "__LOCATION_HACK__" "$path_url" "../conf/nginx.conf"
|
ynh_replace_string "__PATH_HACK__" "$path_url" "../conf/nginx.conf"
|
||||||
ynh_replace_string "__PATH_HACK__" "$path_url$path_url" "../conf/nginx.conf"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create a dedicated nginx config
|
# Create a dedicated nginx config
|
||||||
|
@ -198,7 +340,8 @@ ynh_use_logrotate --non-append
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Set right permissions
|
# Set right permissions
|
||||||
chown -R $app:www-data $final_path
|
chown -R $app: $final_path
|
||||||
|
chown -R $app:www-data $final_path/storage
|
||||||
sudo chmod -R 0775 $final_path
|
sudo chmod -R 0775 $final_path
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -227,8 +370,8 @@ systemctl reload nginx
|
||||||
#===================================================
|
#===================================================
|
||||||
|
|
||||||
if [ $upgraded_flarum ]; then
|
if [ $upgraded_flarum ]; then
|
||||||
ynh_app_setting_set $app flarum_version $flarum_version
|
ynh_app_setting_set $app project_version $project_version
|
||||||
fi
|
fi
|
||||||
if [ $upgraded_ssowat ]; then
|
if [ $upgraded_ssowat ]; then
|
||||||
ynh_app_setting_set $app ssowat_ext_ver $ssowat_ext_ver
|
ynh_app_setting_set $app ssowat_version $ssowat_version
|
||||||
fi
|
fi
|
||||||
|
|
49
scripts/ynh_composer__2
Normal file
49
scripts/ynh_composer__2
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Execute a command with Composer
|
||||||
|
#
|
||||||
|
# usage: ynh_composer_exec --phpversion=phpversion [--workdir=$final_path] --commands="commands"
|
||||||
|
# | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path.
|
||||||
|
# | arg: -c, --commands - Commands to execute.
|
||||||
|
ynh_composer_exec () {
|
||||||
|
# Declare an array to define the options of this helper.
|
||||||
|
local legacy_args=uvwc
|
||||||
|
declare -Ar args_array=( [u]=user [v]=phpversion= [w]=workdir= [c]=commands= )
|
||||||
|
local user
|
||||||
|
local phpversion
|
||||||
|
local workdir
|
||||||
|
local commands
|
||||||
|
# Manage arguments with getopts
|
||||||
|
ynh_handle_getopts_args "$@"
|
||||||
|
workdir="${workdir:-$final_path}"
|
||||||
|
phpversion="${phpversion:-7.0}"
|
||||||
|
|
||||||
|
COMPOSER_HOME="$workdir/.composer" \
|
||||||
|
exec_as $user php${phpversion} "$workdir/composer.phar" $commands \
|
||||||
|
-d "$workdir" --quiet --no-interaction
|
||||||
|
}
|
||||||
|
|
||||||
|
# Install and initialize Composer in the given directory
|
||||||
|
#
|
||||||
|
# usage: ynh_install_composer --phpversion=phpversion [--workdir=$final_path]
|
||||||
|
# | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path.
|
||||||
|
ynh_install_composer () {
|
||||||
|
# Declare an array to define the options of this helper.
|
||||||
|
local legacy_args=vw
|
||||||
|
declare -Ar args_array=( [v]=phpversion= [w]=workdir= )
|
||||||
|
local phpversion
|
||||||
|
local workdir
|
||||||
|
# Manage arguments with getopts
|
||||||
|
ynh_handle_getopts_args "$@"
|
||||||
|
workdir="${workdir:-$final_path}"
|
||||||
|
phpversion="${phpversion:-7.0}"
|
||||||
|
|
||||||
|
curl -sS https://getcomposer.org/installer \
|
||||||
|
| COMPOSER_HOME="$workdir/.composer" \
|
||||||
|
exec_as $app php${phpversion} -- --quiet --install-dir="$workdir" \
|
||||||
|
|| ynh_die "Unable to install Composer."
|
||||||
|
|
||||||
|
# update dependencies to create composer.lock
|
||||||
|
#ynh_composer_exec --phpversion="${phpversion}" --workdir="$workdir" --commands="install --no-dev" \
|
||||||
|
# || ynh_die "Unable to update core dependencies with Composer."
|
||||||
|
}
|
14
scripts/ynh_exec_as
Normal file
14
scripts/ynh_exec_as
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Execute a command as another user
|
||||||
|
# usage: exec_as USER COMMAND [ARG ...]
|
||||||
|
exec_as() {
|
||||||
|
local USER=$1
|
||||||
|
shift 1
|
||||||
|
|
||||||
|
if [[ $USER = $(whoami) ]]; then
|
||||||
|
eval "$@"
|
||||||
|
else
|
||||||
|
sudo -u "$USER" "$@"
|
||||||
|
fi
|
||||||
|
}
|
140
scripts/ynh_send_readme_to_admin__2
Normal file
140
scripts/ynh_send_readme_to_admin__2
Normal file
|
@ -0,0 +1,140 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Send an email to inform the administrator
|
||||||
|
#
|
||||||
|
# usage: ynh_send_readme_to_admin --app_message=app_message [--recipients=recipients] [--type=type]
|
||||||
|
# | arg: -m --app_message= - The file with the content to send to the administrator.
|
||||||
|
# | arg: -r, --recipients= - The recipients of this email. Use spaces to separate multiples recipients. - default: root
|
||||||
|
# example: "root admin@domain"
|
||||||
|
# If you give the name of a YunoHost user, ynh_send_readme_to_admin will find its email adress for you
|
||||||
|
# example: "root admin@domain user1 user2"
|
||||||
|
# | arg: -t, --type= - Type of mail, could be 'backup', 'change_url', 'install', 'remove', 'restore', 'upgrade'
|
||||||
|
ynh_send_readme_to_admin() {
|
||||||
|
# Declare an array to define the options of this helper.
|
||||||
|
declare -Ar args_array=( [m]=app_message= [r]=recipients= [t]=type= )
|
||||||
|
local app_message
|
||||||
|
local recipients
|
||||||
|
local type
|
||||||
|
# Manage arguments with getopts
|
||||||
|
|
||||||
|
ynh_handle_getopts_args "$@"
|
||||||
|
app_message="${app_message:-}"
|
||||||
|
recipients="${recipients:-root}"
|
||||||
|
type="${type:-install}"
|
||||||
|
|
||||||
|
# Get the value of admin_mail_html
|
||||||
|
admin_mail_html=$(ynh_app_setting_get $app admin_mail_html)
|
||||||
|
admin_mail_html="${admin_mail_html:-0}"
|
||||||
|
|
||||||
|
# Retrieve the email of users
|
||||||
|
find_mails () {
|
||||||
|
local list_mails="$1"
|
||||||
|
local mail
|
||||||
|
local recipients=" "
|
||||||
|
# Read each mail in argument
|
||||||
|
for mail in $list_mails
|
||||||
|
do
|
||||||
|
# Keep root or a real email address as it is
|
||||||
|
if [ "$mail" = "root" ] || echo "$mail" | grep --quiet "@"
|
||||||
|
then
|
||||||
|
recipients="$recipients $mail"
|
||||||
|
else
|
||||||
|
# But replace an user name without a domain after by its email
|
||||||
|
if mail=$(ynh_user_get_info "$mail" "mail" 2> /dev/null)
|
||||||
|
then
|
||||||
|
recipients="$recipients $mail"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo "$recipients"
|
||||||
|
}
|
||||||
|
recipients=$(find_mails "$recipients")
|
||||||
|
|
||||||
|
# Subject base
|
||||||
|
local mail_subject="☁️🆈🅽🅷☁️: \`$app\`"
|
||||||
|
|
||||||
|
# Adapt the subject according to the type of mail required.
|
||||||
|
if [ "$type" = "backup" ]; then
|
||||||
|
mail_subject="$mail_subject has just been backup."
|
||||||
|
elif [ "$type" = "change_url" ]; then
|
||||||
|
mail_subject="$mail_subject has just been moved to a new URL!"
|
||||||
|
elif [ "$type" = "remove" ]; then
|
||||||
|
mail_subject="$mail_subject has just been removed!"
|
||||||
|
elif [ "$type" = "restore" ]; then
|
||||||
|
mail_subject="$mail_subject has just been restored!"
|
||||||
|
elif [ "$type" = "upgrade" ]; then
|
||||||
|
mail_subject="$mail_subject has just been upgraded!"
|
||||||
|
else # install
|
||||||
|
mail_subject="$mail_subject has just been installed!"
|
||||||
|
fi
|
||||||
|
|
||||||
|
local mail_message="This is an automated message from your beloved YunoHost server.
|
||||||
|
|
||||||
|
Specific information for the application $app.
|
||||||
|
|
||||||
|
$(if [ -n "$app_message" ]
|
||||||
|
then
|
||||||
|
cat "$app_message"
|
||||||
|
else
|
||||||
|
echo "...No specific information..."
|
||||||
|
fi)
|
||||||
|
|
||||||
|
---
|
||||||
|
Automatic diagnosis data from YunoHost
|
||||||
|
|
||||||
|
__PRE_TAG1__$(yunohost tools diagnosis | grep -B 100 "services:" | sed '/services:/d')__PRE_TAG2__"
|
||||||
|
|
||||||
|
# Store the message into a file for further modifications.
|
||||||
|
echo "$mail_message" > mail_to_send
|
||||||
|
|
||||||
|
# If a html email is required. Apply html tags to the message.
|
||||||
|
if [ "$admin_mail_html" -eq 1 ]
|
||||||
|
then
|
||||||
|
# Insert 'br' tags at each ending of lines.
|
||||||
|
ynh_replace_string "$" "<br>" mail_to_send
|
||||||
|
|
||||||
|
# Insert starting HTML tags
|
||||||
|
sed --in-place '1s@^@<!DOCTYPE html>\n<html>\n<head></head>\n<body>\n@' mail_to_send
|
||||||
|
|
||||||
|
# Keep tabulations
|
||||||
|
ynh_replace_string " " "\ \ " mail_to_send
|
||||||
|
ynh_replace_string "\t" "\ \ " mail_to_send
|
||||||
|
|
||||||
|
# Insert url links tags
|
||||||
|
ynh_replace_string "__URL_TAG1__\(.*\)__URL_TAG2__\(.*\)__URL_TAG3__" "<a href=\"\2\">\1</a>" mail_to_send
|
||||||
|
|
||||||
|
# Insert pre tags
|
||||||
|
ynh_replace_string "__PRE_TAG1__" "<pre>" mail_to_send
|
||||||
|
ynh_replace_string "__PRE_TAG2__" "<\pre>" mail_to_send
|
||||||
|
|
||||||
|
# Insert finishing HTML tags
|
||||||
|
echo -e "\n</body>\n</html>" >> mail_to_send
|
||||||
|
|
||||||
|
# Otherwise, remove tags to keep a plain text.
|
||||||
|
else
|
||||||
|
# Remove URL tags
|
||||||
|
ynh_replace_string "__URL_TAG[1,3]__" "" mail_to_send
|
||||||
|
ynh_replace_string "__URL_TAG2__" ": " mail_to_send
|
||||||
|
|
||||||
|
# Remove PRE tags
|
||||||
|
ynh_replace_string "__PRE_TAG[1-2]__" "" mail_to_send
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Define binary to use for mail command
|
||||||
|
if [ -e /usr/bin/bsd-mailx ]
|
||||||
|
then
|
||||||
|
local mail_bin=/usr/bin/bsd-mailx
|
||||||
|
else
|
||||||
|
local mail_bin=/usr/bin/mail.mailutils
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$admin_mail_html" -eq 1 ]
|
||||||
|
then
|
||||||
|
content_type="text/html"
|
||||||
|
else
|
||||||
|
content_type="text/plain"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Send the email to the recipients
|
||||||
|
cat mail_to_send | $mail_bin -a "Content-Type: $content_type; charset=UTF-8" -s "$mail_subject" "$recipients"
|
||||||
|
}
|
Loading…
Reference in a new issue