diff --git a/README.md b/README.md index d851019..3654176 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/check_process b/check_process index c581f08..fca7121 100644 --- a/check_process +++ b/check_process @@ -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& - diff --git a/conf/ldap.sql b/conf/ldap.sql new file mode 100644 index 0000000..f75523d --- /dev/null +++ b/conf/ldap.sql @@ -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'); diff --git a/conf/mail.sql b/conf/mail.sql new file mode 100644 index 0000000..0b02445 --- /dev/null +++ b/conf/mail.sql @@ -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'); diff --git a/manifest.json b/manifest.json index 5556bda..c9644f8 100644 --- a/manifest.json +++ b/manifest.json @@ -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": { diff --git a/scripts/_common.sh b/scripts/_common.sh index fd5bf28..cc9a5d5 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -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 diff --git a/scripts/experimental_helpers/ynh_composer__2 b/scripts/experimental_helpers/ynh_composer__2 deleted file mode 100644 index 6b1c315..0000000 --- a/scripts/experimental_helpers/ynh_composer__2 +++ /dev/null @@ -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." -} diff --git a/scripts/experimental_helpers/ynh_send_readme_to_admin b/scripts/experimental_helpers/ynh_send_readme_to_admin deleted file mode 100644 index dbd86b2..0000000 --- a/scripts/experimental_helpers/ynh_send_readme_to_admin +++ /dev/null @@ -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" -} diff --git a/scripts/install b/scripts/install index 4ead117..53514e3 100644 --- a/scripts/install +++ b/scripts/install @@ -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=$(