mirror of
https://github.com/YunoHost-Apps/flarum_ynh.git
synced 2024-09-03 18:36:24 +02:00
commit
653aa45f6d
5 changed files with 247 additions and 104 deletions
69
README.md
69
README.md
|
@ -1,39 +1,62 @@
|
|||
Flarum for YunoHost
|
||||
-------------------
|
||||
[Flarum](http://flarum.org/), an open-source forum software, packaged for [YunoHost](https://yunohost.org/), a self-hosting server operating server.
|
||||
# Flarum for YunoHost
|
||||
|
||||
**Shipped version:** 0.1.0-beta.7
|
||||
[![Install Hubzilla with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=flarum)
|
||||
|
||||
[![Integration level](https://dash.yunohost.org/integration/flarum.svg)](https://dash.yunohost.org/appci/app/flarum) [![Flarum version](https://img.shields.io/badge/flarum-0.1.0--beta.7.1-green.svg)](https://github.com/flarum/core/releases/tag/v0.1.0-beta.7.1)
|
||||
|
||||
[Flarum](http://flarum.org/), an open-source forum software, packaged for [YunoHost](https://yunohost.org/), a self-hosting server operating server.
|
||||
|
||||
![](http://flarum.org/img/screenshot_2x.png)
|
||||
|
||||
## Features
|
||||
|
||||
- All Flarum features, see its [documentation](http://flarum.org/docs/)
|
||||
- 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
|
||||
Flarum is available in the Community listing.
|
||||
This Flarum package can be installed through:
|
||||
- YunoHost's webadmin, in the Community listing
|
||||
- YunoHost's CLI: `yunohost app install https://github.com/YunoHost-Apps/flarum_ynh`.
|
||||
|
||||
You can also install it with `yunohost app install https://github.com/YunoHost-Apps/flarum_ynh`.
|
||||
Required parameters are:
|
||||
- `domain`
|
||||
- `path`
|
||||
- `admin`, among the YunoHosts users
|
||||
- `public`, *true* by default, for guests to read the forum
|
||||
- `title` of the forum
|
||||
- `language` can be English (by default), French, and German. Other languages installable after installation as any other extensions
|
||||
- `bazaar_extension` to install the extension marketplace (*false* by default), to avoid using the command line to add new extensions.
|
||||
|
||||
- Required parameters are :
|
||||
- `domain`
|
||||
- `path`
|
||||
- `admin`, among the YunoHosts users
|
||||
- `public`, *true* by default, for guests to read the forum
|
||||
- Optional parameters are :
|
||||
- `title` :warning: if you leave it empty, you will have to perform manual post-installation.
|
||||
- `language` can be English (by default), French, and German. Other languages installable after installation as any other 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.
|
||||
|
||||
### Manual post-installation
|
||||
## Troubleshooting
|
||||
|
||||
1. Retrieve database password:
|
||||
* It should be displayed in the log messages, on top of installation page, for web installations.
|
||||
* For command line installations, `sudo cat /etc/yunohost/apps/flarum/settings.yml | grep mysql` (Replace `flarum` by its actual app id if you are using multiple Flarum instances in YunoHost)
|
||||
### `Low memory` errors
|
||||
A swapfile will enable your system to extend its limited memory through its disk capacity. The following commands will create a 1 GB swapfile.
|
||||
```
|
||||
sudo dd if=/dev/zero of=/swapfile bs=1024 count=1024000
|
||||
sudo chmod 600 /swapfile
|
||||
sudo mkswap /swapfile
|
||||
sudo swapon /swapfile
|
||||
```
|
||||
|
||||
2. Go to your Flarum homepage to initiate manual post-installation.
|
||||
Then add this line in `/etc/fstab`:
|
||||
```
|
||||
/swapfile none swap sw 0 0
|
||||
```
|
||||
|
||||
3. Fill in the blanks about `MySQL` as follow, put the retrieved database password. The remaining blanks are up to you.
|
||||
Reboot the system and try the installation again.
|
||||
|
||||
<p align="center"><img src="http://i.imgur.com/p7XmTDw.png" width="300" ></p>
|
||||
### `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).
|
||||
|
||||
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).
|
||||
|
||||
Reload PHP-FPM with `sudo service php7.0-fpm reload`.
|
||||
|
||||
### Upload limit
|
||||
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).
|
||||
|
||||
Reload PHP-FPM with `sudo service php7.0-fpm reload`.
|
||||
|
|
10
conf/php-fpm.ini
Normal file
10
conf/php-fpm.ini
Normal file
|
@ -0,0 +1,10 @@
|
|||
; 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
|
|
@ -49,23 +49,21 @@
|
|||
"name": "admin",
|
||||
"type": "user",
|
||||
"ask": {
|
||||
"en": "Choose the admin user (required for automatic post-installation)",
|
||||
"fr": "Choisissez l’administrateur (nécessaire pour la post-installation automatique)",
|
||||
"de": "Wählen einen Administrator (erforderlich für die automatische Nachinstallation)"
|
||||
"en": "Choose the admin user",
|
||||
"fr": "Choisissez l’administrateur",
|
||||
"de": "Wählen einen Administrator"
|
||||
},
|
||||
"example": "johndoe",
|
||||
"optional": true
|
||||
"example": "johndoe"
|
||||
},
|
||||
{
|
||||
"name": "title",
|
||||
"ask": {
|
||||
"en": "Choose a title for your forum (required for automatic post-installation)",
|
||||
"fr": "Choisissez un titre pour votre forum (nécessaire pour la post-installation automatique)",
|
||||
"de": "Wählen einen Titel für eure Internetforum (erforderlich für die automatische Nachinstallation)"
|
||||
"en": "Choose a title for your forum",
|
||||
"fr": "Choisissez un titre pour votre forum",
|
||||
"de": "Wählen einen Titel für eure Internetforum"
|
||||
},
|
||||
"example": "My forum",
|
||||
"default": "",
|
||||
"optional": true
|
||||
"default": ""
|
||||
},
|
||||
{
|
||||
"name": "is_public",
|
||||
|
|
120
scripts/change_url
Normal file
120
scripts/change_url
Normal file
|
@ -0,0 +1,120 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC STARTING
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# RETRIEVE ARGUMENTS
|
||||
#=================================================
|
||||
|
||||
old_domain=$YNH_APP_OLD_DOMAIN
|
||||
old_path=$YNH_APP_OLD_PATH
|
||||
|
||||
new_domain=$YNH_APP_NEW_DOMAIN
|
||||
new_path=$YNH_APP_NEW_PATH
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
|
||||
# Needed for helper "ynh_add_nginx_config"
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
|
||||
# Add settings here as needed by your application
|
||||
#db_name=$(ynh_app_setting_get "$app" db_name)
|
||||
#db_pwd=$(ynh_app_setting_get $app 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
|
||||
#=================================================
|
||||
|
||||
change_domain=0
|
||||
if [ "$old_domain" != "$new_domain" ]
|
||||
then
|
||||
change_domain=1
|
||||
fi
|
||||
|
||||
change_path=0
|
||||
if [ "$old_path" != "$new_path" ]
|
||||
then
|
||||
change_path=1
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
# MODIFY URL IN NGINX CONF
|
||||
#=================================================
|
||||
|
||||
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
||||
|
||||
# Change the path in the nginx config file
|
||||
if [ $change_path -eq 1 ]
|
||||
then
|
||||
# Make a backup of the original nginx config file if modified
|
||||
ynh_backup_if_checksum_is_different "$nginx_conf_path"
|
||||
# Set global variables for nginx helper
|
||||
domain="$old_domain"
|
||||
path_url="$new_path"
|
||||
# Bug in Nginx with locations and aliases (see http://stackoverflow.com/a/35102259 )
|
||||
if [ $path_url = "/" ]; then
|
||||
sed -i "s@__LOCATION_HACK__@@g" ../conf/nginx.conf
|
||||
sed -i "s@__PATH_HACK__@/@g" ../conf/nginx.conf
|
||||
else
|
||||
sed -i "s@__LOCATION_HACK__@$path_url@g" ../conf/nginx.conf
|
||||
sed -i "s@__PATH_HACK__@$path_url$path_url@g" ../conf/nginx.conf
|
||||
fi
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config
|
||||
fi
|
||||
|
||||
# Change the domain for nginx
|
||||
if [ $change_domain -eq 1 ]
|
||||
then
|
||||
# Delete file checksum for the old conf file location
|
||||
ynh_delete_file_checksum "$nginx_conf_path"
|
||||
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
||||
# Store file checksum for the new config file location
|
||||
ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# 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
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
|
||||
systemctl reload nginx
|
108
scripts/install
108
scripts/install
|
@ -125,11 +125,11 @@ ynh_app_setting_set "$app" db_pwd "$db_pwd"
|
|||
|
||||
# Bug in Nginx with locations and aliases (see http://stackoverflow.com/a/35102259 )
|
||||
if [ $path_url = "/" ]; then
|
||||
sed -i "s@__LOCATION_HACK__@@g" ../conf/nginx.conf
|
||||
sed -i "s@__PATH_HACK__@/@g" ../conf/nginx.conf
|
||||
ynh_replace_string "__LOCATION_HACK__" "" "../conf/nginx.conf"
|
||||
ynh_replace_string "__PATH_HACK__" "/" "../conf/nginx.conf"
|
||||
else
|
||||
sed -i "s@__LOCATION_HACK__@$path_url@g" ../conf/nginx.conf
|
||||
sed -i "s@__PATH_HACK__@$path_url$path_url@g" ../conf/nginx.conf
|
||||
ynh_replace_string "__LOCATION_HACK__" "$path_url" "../conf/nginx.conf"
|
||||
ynh_replace_string "__PATH_HACK__" "$path_url$path_url" "../conf/nginx.conf"
|
||||
fi
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config
|
||||
|
@ -173,49 +173,47 @@ systemctl reload nginx
|
|||
# FLARUM POST-INSTALL
|
||||
#=================================================
|
||||
|
||||
if [[ -n $admin && -n $title ]]; then
|
||||
# If admin user and title were specified, start post-installation
|
||||
# Copy the configuration.yml to working directory
|
||||
finalflarumconf="$final_path/configuration.yml"
|
||||
cp ../conf/configuration.yml $finalflarumconf
|
||||
chown $app:www-data $finalflarumconf
|
||||
# Generate admin password and retrieve their email address
|
||||
admin_pwd=$(ynh_string_random 8)
|
||||
admin_mail=$(ynh_user_get_info $admin mail)
|
||||
# Populate configuration.yml
|
||||
sed -i "s@__DOMAIN__@$domain@g" $finalflarumconf
|
||||
sed -i "s@/__PATH__@$path_url@g" $finalflarumconf
|
||||
sed -i "s@__USER__@$app@g" $finalflarumconf
|
||||
sed -i "s@__DB_PWD__@$db_pwd@g" $finalflarumconf
|
||||
sed -i "s@__ADMIN__@$admin@g" $finalflarumconf
|
||||
sed -i "s@__ADMIN_PWD__@$admin_pwd@g" $finalflarumconf
|
||||
sed -i "s%__ADMIN_EML__%$admin_mail%g" $finalflarumconf
|
||||
sed -i "s@__FORUM_TITLE__@$title@g" $finalflarumconf
|
||||
# Execute post-installation
|
||||
pushd $final_path
|
||||
exec_as $app "php -d $final_path -d memory_limit=-1 flarum install -f configuration.yml"
|
||||
# Delete configuration.yml as it sensitive data
|
||||
ynh_secure_remove $finalflarumconf
|
||||
popd
|
||||
# Copy the configuration.yml to working directory
|
||||
finalflarumconf="$final_path/configuration.yml"
|
||||
cp ../conf/configuration.yml $finalflarumconf
|
||||
chown $app:www-data $finalflarumconf
|
||||
# Generate admin password and retrieve their email address
|
||||
admin_pwd=$(ynh_string_random 8)
|
||||
admin_mail=$(ynh_user_get_info $admin mail)
|
||||
# Populate configuration.yml
|
||||
ynh_replace_string "__DOMAIN__" "$domain" "$finalflarumconf"
|
||||
ynh_replace_string "/__PATH__" "$path_url" "$finalflarumconf"
|
||||
ynh_replace_string "__USER__" "$app" "$finalflarumconf"
|
||||
ynh_replace_string "__DB_PWD__" "$db_pwd" "$finalflarumconf"
|
||||
ynh_replace_string "__ADMIN__" "$admin" "$finalflarumconf"
|
||||
ynh_replace_string "__ADMIN_PWD__" "$admin_pwd" "$finalflarumconf"
|
||||
ynh_replace_string "__ADMIN_EML__" "$admin_mail" "$finalflarumconf"
|
||||
ynh_replace_string "__FORUM_TITLE__" "$title" "$finalflarumconf"
|
||||
# Execute post-installation
|
||||
pushd $final_path
|
||||
exec_as $app "php -d $final_path -d memory_limit=-1 flarum install -f configuration.yml"
|
||||
# Delete configuration.yml as it sensitive data
|
||||
ynh_secure_remove $finalflarumconf
|
||||
popd
|
||||
|
||||
# Email setup
|
||||
sql_command="REPLACE INTO \`settings\` (\`key\`, \`value\`) VALUES
|
||||
('mail_driver', 'mail'),
|
||||
('mail_encryption', 'ssl'),
|
||||
('mail_from', '$app@$domain'),
|
||||
('mail_host', 'localhost'),
|
||||
('mail_port', '587');"
|
||||
ynh_mysql_execute_as_root "$sql_command" $db_name
|
||||
# Email setup
|
||||
sql_command="REPLACE INTO \`settings\` (\`key\`, \`value\`) VALUES
|
||||
('mail_driver', 'mail'),
|
||||
('mail_encryption', 'ssl'),
|
||||
('mail_from', '$app@$domain'),
|
||||
('mail_host', 'localhost'),
|
||||
('mail_port', '587');"
|
||||
ynh_mysql_execute_as_root "$sql_command" $db_name
|
||||
|
||||
# Install and active 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 INTO \`settings\` (\`key\`, \`value\`) VALUES ('tituspijean-auth-ssowat.domain', '$ssowatdomain'), ('tituspijean-auth-ssowat.onlyUse', '0');"
|
||||
ynh_mysql_execute_as_root "$sql_command" $db_name
|
||||
# Install and active 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 INTO \`settings\` (\`key\`, \`value\`) VALUES ('tituspijean-auth-ssowat.domain', '$ssowatdomain'), ('tituspijean-auth-ssowat.onlyUse', '0');"
|
||||
ynh_mysql_execute_as_root "$sql_command" $db_name
|
||||
|
||||
# Install, activate and set language extensions
|
||||
case $language in
|
||||
# Install, activate and set language extensions
|
||||
case $language in
|
||||
fr)
|
||||
install_and_activate_extension $app $final_path $db_name "milescellar/flarum-ext-french" "milescellar-french"
|
||||
sql_command="UPDATE \`settings\` SET \`value\` = 'fr' WHERE \`settings\`.\`key\` = 'default_locale'"
|
||||
|
@ -228,19 +226,13 @@ if [[ -n $admin && -n $title ]]; then
|
|||
;;
|
||||
esac
|
||||
|
||||
if [[ $bazaar_extension ]]; then
|
||||
if [[ $bazaar_extension ]]; then
|
||||
exec_composer $app $final_path "require flagrow/bazaar --ansi"
|
||||
fi
|
||||
|
||||
# Send login credentials to admin
|
||||
app_message="User : $admin, password : $admin_pwd
|
||||
Change your password!
|
||||
Your forum is accessible at https://$domain$path_url"
|
||||
>&2 echo $app_message
|
||||
ynh_send_readme_to_admin "$app_message" "$admin"
|
||||
else
|
||||
# If admin user and title were not specified, ask admin to perform manual post-installation
|
||||
app_message="Post-installation required, visit your Flarum instance."
|
||||
>&2 echo $app_message
|
||||
ynh_send_readme_to_admin "$app_message" "$admin"
|
||||
fi
|
||||
|
||||
# Send login credentials to admin
|
||||
app_message="User : $admin, password : $admin_pwd
|
||||
Change your password!
|
||||
Your forum is accessible at https://$domain$path_url"
|
||||
>&2 echo $app_message
|
||||
ynh_send_readme_to_admin "$app_message" "$admin"
|
||||
|
|
Loading…
Reference in a new issue