From bb7b728453ca54d0a23cc8a426e1d8eece8ef36f Mon Sep 17 00:00:00 2001 From: tituspijean Date: Thu, 29 Apr 2021 00:20:51 +0200 Subject: [PATCH 01/10] Upgrade to beta 16 --- README.md | 6 +- check_process | 1 - conf/ldap.sql | 15 +++++ conf/mail.sql | 6 ++ manifest.json | 2 +- scripts/_common.sh | 6 +- scripts/experimental_helpers/ynh_composer__2 | 62 ----------------- .../ynh_send_readme_to_admin | 67 ------------------- scripts/install | 57 ++++++---------- scripts/upgrade | 30 +++++---- 10 files changed, 64 insertions(+), 188 deletions(-) create mode 100644 conf/ldap.sql create mode 100644 conf/mail.sql delete mode 100644 scripts/experimental_helpers/ynh_composer__2 delete mode 100644 scripts/experimental_helpers/ynh_send_readme_to_admin 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=$( Date: Thu, 29 Apr 2021 00:32:58 +0200 Subject: [PATCH 02/10] Reinstate composer helper and remove ynh_send_readme_to_admin --- scripts/experimental_helpers/ynh_composer | 61 +++++++++++++++++++++++ scripts/install | 3 +- scripts/upgrade | 1 + 3 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 scripts/experimental_helpers/ynh_composer diff --git a/scripts/experimental_helpers/ynh_composer b/scripts/experimental_helpers/ynh_composer new file mode 100644 index 0000000..37c50ed --- /dev/null +++ b/scripts/experimental_helpers/ynh_composer @@ -0,0 +1,61 @@ +#!/bin/bash + +readonly YNH_DEFAULT_COMPOSER_VERSION=1.10.17 +# Declare the actual composer version to use. +# A packager willing to use another version of composer can override the variable into its _common.sh. +YNH_COMPOSER_VERSION=${YNH_COMPOSER_VERSION:-$YNH_DEFAULT_COMPOSER_VERSION} + +# Execute a command with Composer +# +# usage: ynh_composer_exec [--phpversion=phpversion] [--workdir=$final_path] --commands="commands" +# | 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=vwc + declare -Ar args_array=( [v]=phpversion= [w]=workdir= [c]=commands= ) + local phpversion + local workdir + local commands + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + workdir="${workdir:-$final_path}" + phpversion="${phpversion:-$YNH_PHP_VERSION}" + + COMPOSER_HOME="$workdir/.composer" \ + 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] [--install_args="--optimize-autoloader"] [--composerversion=composerversion] +# | 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 +# | arg: -c, --composerversion - Composer version to install +ynh_install_composer () { + # Declare an array to define the options of this helper. + local legacy_args=vwac + declare -Ar args_array=( [v]=phpversion= [w]=workdir= [a]=install_args= [c]=composerversion=) + local phpversion + local workdir + local install_args + local composerversion + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + workdir="${workdir:-$final_path}" + phpversion="${phpversion:-$YNH_PHP_VERSION}" + install_args="${install_args:-}" + composerversion="${composerversion:-$YNH_COMPOSER_VERSION}" + + curl -sS https://getcomposer.org/installer \ + | COMPOSER_HOME="$workdir/.composer" \ + php${phpversion} -- --quiet --install-dir="$workdir" --version=$composerversion \ + || ynh_die "Unable to install Composer." + + # install dependencies + ynh_composer_exec --phpversion="${phpversion}" --workdir="$workdir" --commands="install --no-dev $install_args" \ + || ynh_die "Unable to install core dependencies with Composer." +} diff --git a/scripts/install b/scripts/install index 53514e3..bccdbff 100644 --- a/scripts/install +++ b/scripts/install @@ -8,8 +8,7 @@ source _common.sh source experimental_helpers/ynh_exec_as -source experimental_helpers/ynh_composer__2 -source experimental_helpers/ynh_send_readme_to_admin +source experimental_helpers/ynh_composer source experimental_helpers/ynh_add_swap source /usr/share/yunohost/helpers diff --git a/scripts/upgrade b/scripts/upgrade index c5b2fdb..b7add8a 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -8,6 +8,7 @@ source _common.sh source experimental_helpers/ynh_exec_as +source experimental_helpers/ynh_composer source experimental_helpers/ynh_add_swap source /usr/share/yunohost/helpers From e11b722225cda2566c38d377ccff34c2406230b2 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Thu, 29 Apr 2021 00:44:54 +0200 Subject: [PATCH 03/10] Fix settings in database --- scripts/install | 4 ++-- scripts/upgrade | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index bccdbff..e799ba9 100644 --- a/scripts/install +++ b/scripts/install @@ -166,12 +166,12 @@ pushd $final_path popd # Email setup -ynh_mysql_execute_as_root --database=$db_name < ../conf/mail.sql +ynh_mysql_connect_as --user=$app --password="$db_pwd" --database=$db_name < ../conf/mail.sql # 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 +ynh_mysql_connect_as --user=$app --password="$db_pwd" --database=$db_name < ../conf/ldap.sql # Install, activate and set language extensions case $language in diff --git a/scripts/upgrade b/scripts/upgrade index b7add8a..1f14995 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -202,7 +202,7 @@ then # 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 + ynh_mysql_connect_as --user=$app --password="$db_pwd" --database=$db_name < ../conf/ldap.sql fi # Install, activate and set language extensions From 99ef5d47fe706dcb3fd0feffd814231a7178b2dc Mon Sep 17 00:00:00 2001 From: tituspijean Date: Thu, 29 Apr 2021 09:15:07 +0200 Subject: [PATCH 04/10] Remove --user=$app from composer helpers Since we removed the custom helper that used exec_as --- scripts/install | 4 ++-- scripts/upgrade | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/install b/scripts/install index e799ba9..323905a 100644 --- a/scripts/install +++ b/scripts/install @@ -177,14 +177,14 @@ ynh_mysql_connect_as --user=$app --password="$db_pwd" --database=$db_name < ../c case $language in fr) ynh_script_progression --message="Installing French extension..." --weight=2 - ynh_exec_warn_less ynh_composer_exec --user=$app --phpversion=$phpversion --workdir=$final_path --commands=\"require qiaeru/lang-french\" + ynh_exec_warn_less ynh_composer_exec --phpversion=$phpversion --workdir=$final_path --commands=\"require qiaeru/lang-french\" activate_flarum_extension $db_name "qiaeru-lang-french" sql_command="UPDATE \`settings\` SET \`value\` = 'fr' WHERE \`settings\`.\`key\` = 'default_locale'" ynh_mysql_execute_as_root --sql="$sql_command" --database=$db_name ;; de) ynh_script_progression --message="Installing German extension..." --weight=2 - ynh_exec_warn_less ynh_composer_exec --user=$app --phpversion=$phpversion --workdir=$final_path --commands=\"require cbmainz/flarum-de\" + ynh_exec_warn_less ynh_composer_exec --phpversion=$phpversion --workdir=$final_path --commands=\"require cbmainz/flarum-de\" activate_flarum_extension $db_name "cbmainz-de" sql_command="UPDATE \`settings\` SET \`value\` = 'de' WHERE \`settings\`.\`key\` = 'default_locale'" ynh_mysql_execute_as_root --sql="$sql_command" --database=$db_name diff --git a/scripts/upgrade b/scripts/upgrade index 1f14995..7a8f24e 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -73,7 +73,7 @@ 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_exec_warn_less ynh_composer_exec --phpversion=$phpversion --workdir=$final_path --commands=\"remove tituspijean/flarum-ext-auth-ssowat\" ynh_app_setting_delete --app=$app --key=ssowat_extension fi @@ -181,13 +181,13 @@ then chown -R $app:www-data $final_path # Install Composer and Flarum - 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 # 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-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\" + ynh_exec_warn_less ynh_composer_exec --phpversion=$phpversion --workdir=$final_path --commands=\"require tituspijean/flarum-ext-auth-ldap:$ldap_version --no-update\" + ynh_exec_warn_less ynh_composer_exec --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 popd @@ -209,14 +209,14 @@ fi case $language in fr) ynh_script_progression --message="Installing French extension..." --weight=2 - ynh_exec_warn_less ynh_composer_exec --user=$app --phpversion=$phpversion --workdir=$final_path --commands=\"require qiaeru/lang-french\" + ynh_exec_warn_less ynh_composer_exec --phpversion=$phpversion --workdir=$final_path --commands=\"require qiaeru/lang-french\" activate_flarum_extension $db_name "qiaeru-lang-french" sql_command="UPDATE \`settings\` SET \`value\` = 'fr' WHERE \`settings\`.\`key\` = 'default_locale'" ynh_mysql_execute_as_root "$sql_command" $db_name ;; de) ynh_script_progression --message="Installing German extension..." --weight=2 - ynh_exec_warn_less ynh_composer_exec --user=$app --phpversion=$phpversion --workdir=$final_path --commands=\"require cbmainz/flarum-de\" + ynh_exec_warn_less ynh_composer_exec --phpversion=$phpversion --workdir=$final_path --commands=\"require cbmainz/flarum-de\" activate_flarum_extension $db_name "cbmainz-de" sql_command="UPDATE \`settings\` SET \`value\` = 'de' WHERE \`settings\`.\`key\` = 'default_locale'" ynh_mysql_execute_as_root "$sql_command" $db_name From d72e24dd4db8aa2d4d03496c94b23c053b01a662 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Thu, 29 Apr 2021 09:20:58 +0200 Subject: [PATCH 05/10] Upgrade app source to beta.16 too --- conf/app.src | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/app.src b/conf/app.src index 81423a9..44afba3 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/flarum/flarum/archive/v0.1.0-beta.13.zip -SOURCE_SUM=D1BA09D2A871A16D193C88A05CC420CF66CCECD1E48C9AEDAC46D699AFE325ED +SOURCE_URL=https://github.com/flarum/flarum/archive/v0.1.0-beta.16.zip +SOURCE_SUM=CB4B892AA0C59C1DAF48812EC0EC842E5D9B1C99ED7D90F30D0A1DB3B411993A SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=zip SOURCE_IN_SUBDIR=true From 3cbf3c69e5933d2154f8ac96dfd1c3a2a10280cc Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sat, 1 May 2021 13:36:03 +0200 Subject: [PATCH 06/10] Fix install with sql files --- conf/mail.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/mail.sql b/conf/mail.sql index 0b02445..5cb435c 100644 --- a/conf/mail.sql +++ b/conf/mail.sql @@ -1,4 +1,4 @@ -REPLACE INTO \`settings\` (\`key\`, \`value\`) VALUES +REPLACE INTO `settings` (`key`, `value`) VALUES ('mail_driver', 'mail'), ('mail_encryption', 'ssl'), ('mail_from', '$app@$domain'), From 95ed212c69113ae57ce908773ead00106e8c0655 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sat, 1 May 2021 15:25:20 +0200 Subject: [PATCH 07/10] Secure file permissions --- scripts/install | 2 ++ scripts/restore | 6 +++--- scripts/upgrade | 2 ++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index 323905a..10b96da 100644 --- a/scripts/install +++ b/scripts/install @@ -149,6 +149,8 @@ ynh_script_progression --message="Securing files and directories..." # Set permissions to app files chown -R $app:www-data $final_path +chmod -R ug+rw,o-rwx $final_path +chmod -R ug+x $final_path/flarum #================================================= # FLARUM POST-INSTALL diff --git a/scripts/restore b/scripts/restore index 6cec03b..7059dc1 100644 --- a/scripts/restore +++ b/scripts/restore @@ -72,9 +72,9 @@ ynh_system_user_create --username=$app ynh_script_progression --message="Restoring user rights..." # Set right permissions -chown -R $app: $final_path -chown -R $app:www-data $final_path/storage -chmod -R 0775 $final_path +chown -R $app:www-data $final_path +chmod -R ug+rw,o-rwx $final_path +chmod -R ug+x $final_path/flarum #================================================= # RESTORE THE PHP-FPM CONFIGURATION diff --git a/scripts/upgrade b/scripts/upgrade index 7a8f24e..66b80fd 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -251,6 +251,8 @@ ynh_script_progression --message="Securing files and directories..." # Set permissions on app files chown -R $app:www-data $final_path +chmod -R ug+rw,o-rwx $final_path +chmod -R ug+x $final_path/flarum #================================================= # RELOAD NGINX From 15c63e7d8aaa54244fbd13afe30158892b888583 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sat, 1 May 2021 15:44:21 +0200 Subject: [PATCH 08/10] Handle existing sql rows --- conf/ldap.sql | 3 ++- conf/mail.sql | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/conf/ldap.sql b/conf/ldap.sql index f75523d..cd91649 100644 --- a/conf/ldap.sql +++ b/conf/ldap.sql @@ -12,4 +12,5 @@ INSERT INTO `settings` (`key`, `value`) VALUES ('tituspijean-auth-ldap.use_ssl', ''), ('tituspijean-auth-ldap.use_tls', ''), ('tituspijean-auth-ldap.user_mail', 'mail'), -('tituspijean-auth-ldap.user_username', 'uid'); +('tituspijean-auth-ldap.user_username', 'uid') + ON DUPLICATE KEY UPDATE value = VALUES(value); diff --git a/conf/mail.sql b/conf/mail.sql index 5cb435c..5025859 100644 --- a/conf/mail.sql +++ b/conf/mail.sql @@ -3,4 +3,5 @@ REPLACE INTO `settings` (`key`, `value`) VALUES ('mail_encryption', 'ssl'), ('mail_from', '$app@$domain'), ('mail_host', 'localhost'), - ('mail_port', '587'); + ('mail_port', '587') + ON DUPLICATE KEY UPDATE value = VALUES(value); From effa42c9b5ab8e4c09eb4f53b829517655a1a6d5 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sat, 1 May 2021 16:09:25 +0200 Subject: [PATCH 09/10] Handle existing sql rows, properly --- conf/ldap.sql | 4 +++- conf/mail.sql | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/conf/ldap.sql b/conf/ldap.sql index cd91649..3b18d69 100644 --- a/conf/ldap.sql +++ b/conf/ldap.sql @@ -13,4 +13,6 @@ INSERT INTO `settings` (`key`, `value`) VALUES ('tituspijean-auth-ldap.use_tls', ''), ('tituspijean-auth-ldap.user_mail', 'mail'), ('tituspijean-auth-ldap.user_username', 'uid') - ON DUPLICATE KEY UPDATE value = VALUES(value); +AS new +ON DUPLICATE KEY UPDATE +value = new.value; diff --git a/conf/mail.sql b/conf/mail.sql index 5025859..f043bcb 100644 --- a/conf/mail.sql +++ b/conf/mail.sql @@ -4,4 +4,6 @@ REPLACE INTO `settings` (`key`, `value`) VALUES ('mail_from', '$app@$domain'), ('mail_host', 'localhost'), ('mail_port', '587') - ON DUPLICATE KEY UPDATE value = VALUES(value); + AS new +ON DUPLICATE KEY UPDATE +value = new.value; From a3b5fb6ecc26b51f59113b06a6a493af25a580e2 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sat, 1 May 2021 21:06:47 +0200 Subject: [PATCH 10/10] =?UTF-8?q?Handle=20existing=20sql=20rows,=20properl?= =?UTF-8?q?y=C2=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conf/ldap.sql | 4 +--- conf/mail.sql | 6 ++---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/conf/ldap.sql b/conf/ldap.sql index 3b18d69..46531f1 100644 --- a/conf/ldap.sql +++ b/conf/ldap.sql @@ -13,6 +13,4 @@ INSERT INTO `settings` (`key`, `value`) VALUES ('tituspijean-auth-ldap.use_tls', ''), ('tituspijean-auth-ldap.user_mail', 'mail'), ('tituspijean-auth-ldap.user_username', 'uid') -AS new -ON DUPLICATE KEY UPDATE -value = new.value; +ON DUPLICATE KEY UPDATE value = VALUES(value); diff --git a/conf/mail.sql b/conf/mail.sql index f043bcb..82a7545 100644 --- a/conf/mail.sql +++ b/conf/mail.sql @@ -1,9 +1,7 @@ -REPLACE INTO `settings` (`key`, `value`) VALUES +INSERT INTO `settings` (`key`, `value`) VALUES ('mail_driver', 'mail'), ('mail_encryption', 'ssl'), ('mail_from', '$app@$domain'), ('mail_host', 'localhost'), ('mail_port', '587') - AS new -ON DUPLICATE KEY UPDATE -value = new.value; +ON DUPLICATE KEY UPDATE value = VALUES(value);