From 5ed37fbbd718172ba854c6894305782002d0a79a Mon Sep 17 00:00:00 2001 From: tituspijean Date: Mon, 17 Sep 2018 22:06:03 +0200 Subject: [PATCH 1/3] [enh] Use ynh_print_* helpers Closes #105 --- scripts/_common.sh | 9 +++++---- scripts/install | 10 +++++++++- scripts/upgrade | 7 ++++++- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index a69e3da..ba1bc64 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -26,10 +26,11 @@ exec_composer() { # Do not run composer as root if [ $AS_USER = "root" ] ; then ynh_die "Do not run composer as root" ; fi pushd "${WORKDIR}" - exec_as "$AS_USER" COMPOSER_HOME="${WORKDIR}/.composer" \ + ynh_exec_warn_less \ + "exec_as "$AS_USER" COMPOSER_HOME="${WORKDIR}/.composer" \ php -d memory_limit=-1 \ "${WORKDIR}/composer.phar" $@ \ - --quiet --no-interaction + --no-interaction" popd } @@ -44,8 +45,8 @@ init_composer() { # install composer curl -sS https://getcomposer.org/installer \ - | COMPOSER_HOME="${WORKDIR}/.composer" \ - php -- --quiet --install-dir="$WORKDIR" \ + | 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 diff --git a/scripts/install b/scripts/install index dc8adb5..14f1d56 100644 --- a/scripts/install +++ b/scripts/install @@ -101,6 +101,7 @@ sudo chown -R $app:www-data $tmp sudo chmod -R 0775 $tmp # Install Flarum +ynh_print_info "Composer is installing Flarum and its dependencies. It may take a while..." # First, create the project with core and all basic extensions exec_composer $app $final_path "create-project flarum/flarum $tmp --stability=beta --ansi -d $tmp" # Let's fix the core version by explicitely requiring it @@ -111,6 +112,7 @@ 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_print_info " ... done!" #================================================= # CREATE A MYSQL DATABASE @@ -175,6 +177,7 @@ systemctl reload nginx # FLARUM POST-INSTALL #================================================= +ynh_print_info "Configuring Flarum..." # Copy the configuration.yml to working directory finalflarumconf="$final_path/configuration.yml" cp ../conf/configuration.yml $finalflarumconf @@ -206,6 +209,7 @@ sql_command="REPLACE INTO \`settings\` (\`key\`, \`value\`) VALUES ('mail_host', 'localhost'), ('mail_port', '587');" ynh_mysql_execute_as_root "$sql_command" $db_name +ynh_print_info " ... done!" # 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" @@ -213,6 +217,7 @@ install_and_activate_extension $app $final_path $db_name "tituspijean/flarum-ext ssowatdomain=$(&2 echo $app_message ynh_send_readme_to_admin "$app_message" "$admin" +ynh_print_warn "$app_message" diff --git a/scripts/upgrade b/scripts/upgrade index f9def61..e66904a 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -120,8 +120,9 @@ if [[ $(dpkg --compare-versions $old_flarum_version lt $flarum_version) ]]; then pushd $final_path exec_as $app php flarum cache:clear popd + ynh_print_info "Flarum has been updated to version $flarum_version." else - echo "Flarum doesn't need any update, let's check the extension." + ynh_print_info "Flarum does not need updating." fi # Check if upgrade of SSOwat extension is needed @@ -132,10 +133,14 @@ if [[ $(dpkg --compare-versions $old_ssowat_ext_ver lt $ssowat_ext_ver && echo t ssowatdomain=$( Date: Sun, 11 Nov 2018 21:30:38 +0100 Subject: [PATCH 2/3] [fix/enh] Upgrade to 0.1.0-beta.7.2 and fix upgrade logics [enh] Upgrade to 0.1.0-beta.7.2 [fix] Scripts remembers whether Flarum or its extension were upgraded or not. [fix] Bad logic test for Flarum versions comparison --- scripts/_common.sh | 2 +- scripts/upgrade | 24 +++++++++++++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index a69e3da..e96e9f6 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,5 +1,5 @@ # Version numbers -flarum_version="0.1.0-beta.7.1" +flarum_version="0.1.0-beta.7.2" ssowat_ext_ver="0.6" # Execute a command as another user diff --git a/scripts/upgrade b/scripts/upgrade index f9def61..b78523f 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -114,14 +114,20 @@ fi # 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) ]]; then +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'" + 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" + fi pushd $final_path exec_as $app php flarum cache:clear popd + upgraded_flarum=true else - echo "Flarum doesn't need any update, let's check the extension." + echo "Flarum does not need to be updated." + upgraded_flarum=false fi # Check if upgrade of SSOwat extension is needed @@ -132,6 +138,10 @@ if [[ $(dpkg --compare-versions $old_ssowat_ext_ver lt $ssowat_ext_ver && echo t ssowatdomain=$( Date: Sun, 11 Nov 2018 21:58:15 +0100 Subject: [PATCH 3/3] [fix] Allow insecure curl --- scripts/upgrade | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index b78523f..7ef2beb 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -118,8 +118,8 @@ if [[ $(dpkg --compare-versions $old_flarum_version lt $flarum_version && echo t # 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" + 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