1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/flarum_ynh.git synced 2024-09-03 18:36:24 +02:00

Upgrade to beta 16

This commit is contained in:
tituspijean 2021-04-29 00:20:51 +02:00
parent bf35fb018d
commit bb7b728453
10 changed files with 64 additions and 188 deletions

View file

@ -9,7 +9,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
## Overview
[Flarum](http://flarum.org/), an open-source forum software, packaged for [YunoHost](https://yunohost.org/), a self-hosting server operating server.
**Shipped version:** 0.1.0-beta.14
**Shipped version:** 0.1.0-beta.16
## Screenshots
@ -18,7 +18,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
## 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).
- LDAP integration through a [dedicated extension](https://github.com/tituspijean/flarum-ext-auth-ldap).
## Installation
@ -42,7 +42,7 @@ Note that all third-party extensions are removed upon upgrading.
## Adding extensions after installation
Replace `flarum` with your app ID in case of multiple installation.
Replace `flarum` with your app ID in case of multiple installations.
Replace `vendor/extension` with the appropriate names. Read the extension documentation if it requires additional steps.
```bash

View file

@ -33,4 +33,3 @@ Notification=none
; commit=0d30809a2903544a660635f62a25bc6057ea2f15
name=2021-02-19 0.1.0.14~ynh2
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&title=Forum&

15
conf/ldap.sql Normal file
View file

@ -0,0 +1,15 @@
INSERT INTO `settings` (`key`, `value`) VALUES
('tituspijean-auth-ldap.admin_dn', ''),
('tituspijean-auth-ldap.admin_password', ''),
('tituspijean-auth-ldap.base_dn', 'ou=users,dc=yunohost,dc=org'),
('tituspijean-auth-ldap.filter', '(&(objectClass=posixAccount)(permission=cn=flarum.main,ou=permission,dc=yunohost,dc=org))'),
('tituspijean-auth-ldap.follow_referrals', '0'),
('tituspijean-auth-ldap.hosts', 'localhost'),
('tituspijean-auth-ldap.method_name', 'YunoHost'),
('tituspijean-auth-ldap.onlyUse', '1'),
('tituspijean-auth-ldap.port', '389'),
('tituspijean-auth-ldap.search_user_fields', 'uid,mail'),
('tituspijean-auth-ldap.use_ssl', ''),
('tituspijean-auth-ldap.use_tls', ''),
('tituspijean-auth-ldap.user_mail', 'mail'),
('tituspijean-auth-ldap.user_username', 'uid');

6
conf/mail.sql Normal file
View file

@ -0,0 +1,6 @@
REPLACE INTO \`settings\` (\`key\`, \`value\`) VALUES
('mail_driver', 'mail'),
('mail_encryption', 'ssl'),
('mail_from', '$app@$domain'),
('mail_host', 'localhost'),
('mail_port', '587');

View file

@ -7,7 +7,7 @@
"fr": "Un forum de nouvelle génération, simplement.",
"de": "Forum der nächsten Generation leicht gemacht."
},
"version": "0.1.0.14~ynh3",
"version": "0.1.0.16~ynh1",
"url": "http://flarum.org/",
"license": "MIT",
"maintainer": {

View file

@ -12,9 +12,9 @@ YNH_PHP_VERSION="7.3"
extra_php_dependencies="php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-dom php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-json php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-pdo-mysql php${YNH_PHP_VERSION}-tokenizer php${YNH_PHP_VERSION}-zip"
# Version numbers
project_version="~0.1.0-beta.14"
core_version="~0.1.0-beta.14"
ssowat_version="~0.1.0-beta.14"
project_version="~0.1.0-beta.16"
core_version="~0.1.0-beta.16"
ldap_version="~0.1.0-beta.16-1"
#=================================================
# PERSONAL HELPERS

View file

@ -1,62 +0,0 @@
#!/bin/bash
# Execute a command with Composer
#
# usage: ynh_composer_exec [--user=app] [--phpversion=phpversion] [--workdir=$final_path] --commands="commands"
# | arg: -u, --user - User to execute composer with.
# | arg: -v, --phpversion - PHP version to use with composer.
# | 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 "$@"
user="${user:-$app}"
workdir="${workdir:-$final_path}"
phpversion="${phpversion:-$YNH_PHP_VERSION}"
COMPOSER_HOME="$workdir/.composer" \
exec_as $user php${phpversion} "$workdir/composer.phar" $commands \
-d "$workdir" --no-interaction
}
# Install and initialize Composer in the given directory
#
# usage: ynh_install_composer [--phpversion=phpversion] [--workdir=$final_path] [--install_args="--optimize-autoloader"]
# | arg: -u, --user - User to execute composer with.
# | arg: -v, --phpversion - PHP version to use with composer
# | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path.
# | arg: -a, --install_args - Additional arguments provided to the composer install. Argument --no-dev already include
ynh_install_composer () {
# Declare an array to define the options of this helper.
local legacy_args=vwa
declare -Ar args_array=( [u]=user= [v]=phpversion= [w]=workdir= [a]=install_args=)
local user
local phpversion
local workdir
local install_args
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
user="${user:-$app}"
workdir="${workdir:-$final_path}"
phpversion="${phpversion:-$YNH_PHP_VERSION}"
install_args="${install_args:-}"
curl -sS https://getcomposer.org/installer \
| COMPOSER_HOME="$workdir/.composer" \
php${phpversion} -- --install-dir="$workdir" \
|| ynh_die "Unable to install Composer."
# Making sure workdir is writable
chown -R $user: $workdir
# update dependencies to create composer.lock
ynh_composer_exec --user=$user --phpversion="${phpversion}" --workdir="$workdir" --commands="install --no-dev $install_args" \
|| ynh_die "Unable to update core dependencies with Composer."
}

View file

@ -1,67 +0,0 @@
#!/bin/bash
# Need also the helper https://github.com/YunoHost-Apps/Experimental_helpers/blob/master/ynh_handle_getopts_args/ynh_handle_getopts_args
# Send an email to inform the administrator
#
# usage: ynh_send_readme_to_admin app_message [recipients]
# | arg: -m --app_message= - The message 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"
ynh_send_readme_to_admin() {
# Declare an array to define the options of this helper.
declare -Ar args_array=( [m]=app_message= [r]=recipients= )
local app_message
local recipients
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
local app_message="${app_message:-...No specific information...}"
local recipients="${recipients:-root}"
# 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")
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
"
# 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"
}

View file

@ -61,7 +61,7 @@ ynh_app_setting_set --app=$app --key=admin --value=$admin
ynh_app_setting_set --app=$app --key=language --value=$language
ynh_app_setting_set --app=$app --key=project_version --value=$project_version
ynh_app_setting_set --app=$app --key=core_version --value=$core_version
ynh_app_setting_set --app=$app --key=ssowat_version --value=$ssowat_version
ynh_app_setting_set --app=$app --key=ldap_version --value=$ldap_version
#=================================================
# STANDARD MODIFICATIONS
@ -132,16 +132,24 @@ ynh_add_swap --size=$swap_needed
#=================================================
ynh_script_progression --message="Installing composer dependencies..." --weight=5
ynh_exec_warn_less ynh_install_composer --user=$app --phpversion="$phpversion" --workdir="$final_path"
ynh_exec_warn_less ynh_install_composer --phpversion="$phpversion" --workdir="$final_path"
# Set Flarum version
ynh_exec_warn_less ynh_composer_exec --user=$app --phpversion=$phpversion --workdir=$final_path --commands=\"require flarum/core:$core_version --prefer-lowest --no-update\"
ynh_exec_warn_less ynh_composer_exec --phpversion=$phpversion --workdir=$final_path --commands=\"require flarum/core:$core_version --prefer-lowest --no-update\"
# Require SSOwat extension
ynh_exec_warn_less ynh_composer_exec --user=$app --phpversion=$phpversion --workdir=$final_path --commands=\"require tituspijean/flarum-ext-auth-ssowat:$ssowat_version --no-update\"
# Require LDAP extension
ynh_exec_warn_less ynh_composer_exec --phpversion=$phpversion --workdir=$final_path --commands=\"require tituspijean/flarum-ext-auth-ldap:$ldap_version --no-update\"
# Update and download dependencies
ynh_exec_warn_less ynh_composer_exec --user=$app --phpversion=$phpversion --workdir=$final_path --commands=\"update\"
ynh_exec_warn_less ynh_composer_exec --phpversion=$phpversion --workdir=$final_path --commands=\"update\"
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
ynh_script_progression --message="Securing files and directories..."
# Set permissions to app files
chown -R $app:www-data $final_path
#=================================================
# FLARUM POST-INSTALL
@ -159,20 +167,12 @@ pushd $final_path
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="$sql_command" --database=$db_name
ynh_mysql_execute_as_root --database=$db_name < ../conf/mail.sql
# Enable and set up the SSOwat auth extension
ynh_script_progression --message="Enabling and configuring SSOwat extension..." --weight=2
activate_flarum_extension $db_name "tituspijean-auth-ssowat"
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="$sql_command" --database=$db_name
# Enable and set up the LDAP auth extension
ynh_script_progression --message="Enabling and configuring LDAP extension..." --weight=2
activate_flarum_extension $db_name "tituspijean-auth-ldap"
ynh_mysql_execute_as_root --database=$db_name < ../conf/ldap.sql
# Install, activate and set language extensions
case $language in
@ -194,14 +194,6 @@ esac
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
ynh_script_progression --message="Securing files and directories..."
# Set permissions to app files
chown -R $app:www-data $final_path
#=================================================
# SETUP LOGROTATE
#=================================================
@ -230,17 +222,6 @@ ynh_script_progression --message="Reloading nginx web server..."
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# SEND CREDENTIALS TO ADMIN
#=================================================
ynh_script_progression --message="Sending generated admin credentials by email, but you can log in with your YunoHost credentials!" --weight=1
app_message="User : $admin, password : $admin_pwd
Change your password!
Your forum is accessible at https://$domain$path_url"
ynh_send_readme_to_admin --app_message=$app_message --recipients=$admin
ynh_print_warn --message=$app_message
#=================================================
# END OF SCRIPT
#=================================================

View file

@ -8,7 +8,6 @@
source _common.sh
source experimental_helpers/ynh_exec_as
source experimental_helpers/ynh_composer__2
source experimental_helpers/ynh_add_swap
source /usr/share/yunohost/helpers
@ -28,8 +27,7 @@ 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)
old_ldap_version=$(ynh_app_setting_get --app=$app --key=ldap_version)
#=================================================
# CHECK VERSION
@ -65,11 +63,19 @@ fi
# Remove the v before version number
if [[ $old_project_version == "v*" ]]; then $old_project_version = ${old_project_version:1}; fi
# Remove bazaar_extension if exists
# Remove bazaar_extension if it exists
bazaar_extension=$(ynh_app_setting_get --app=$app --key=bazaar_extension)
if [ ! -z "$bazaar_extension" ]; then
ynh_app_setting_delete --app=$app --key=bazaar_extension
fi
# Remove SSOwat if it exists
ssowat_extension=$(ynh_app_setting_get --app=$app --key=ssowat_extension)
if [ ! -z "$ssowat_extension" ]; then
ynh_exec_warn_less ynh_composer_exec --user=$app --phpversion=$phpversion --workdir=$final_path --commands=\"remove tituspijean/flarum-ext-auth-ssowat\"
ynh_app_setting_delete --app=$app --key=ssowat_extension
fi
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
@ -179,7 +185,7 @@ then
# Perform migrations and clear cache
pushd $final_path
ynh_script_progression --message="Upgrading Flarum and its extensions..." --weight=1
ynh_exec_warn_less ynh_composer_exec --user=$app --phpversion=$phpversion --workdir=$final_path --commands=\"require tituspijean/flarum-ext-auth-ssowat:$ssowat_version --no-update\"
ynh_exec_warn_less ynh_composer_exec --user=$app --phpversion=$phpversion --workdir=$final_path --commands=\"require tituspijean/flarum-ext-auth-ldap:$ldap_version --no-update\"
ynh_exec_warn_less ynh_composer_exec --user=$app --phpversion=$phpversion --workdir=$final_path --commands=\"require flarum/core:$core_version --prefer-dist --update-no-dev -a --update-with-all-dependencies\"
exec_as $app php$phpversion flarum migrate
exec_as $app php$phpversion flarum cache:clear
@ -190,14 +196,12 @@ fi
# FLARUM EXTENSIONS
#=================================================
if ! exec_as $app php$phpversion flarum info | grep -q "tituspijean-auth-ssowat" | grep -q $ssowat_version;
if ! exec_as $app php$phpversion flarum info | grep -q "tituspijean-auth-ldap" | grep -q $ldap_version;
then
# Install and activate the SSOwat auth extension
activate_flarum_extension $db_name "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
# Install and activate the LDAP auth extension
activate_flarum_extension $db_name "tituspijean-auth-ldap"
# Configure LDAP auth extension
ynh_mysql_execute_as_root --database=$db_name < ../conf/ldap.sql
fi
# Install, activate and set language extensions
@ -227,7 +231,7 @@ popd
# Save version settings
ynh_app_setting_set $app project_version $project_version
ynh_app_setting_set $app core_version $core_version
ynh_app_setting_set $app ssowat_version $ssowat_version
ynh_app_setting_set $app ldap_version $ldap_version
#=================================================
# SETUP LOGROTATE