From 197c71c4a2c78e5d5fe9fcb6976e443cfbc6a5d0 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Mon, 3 Sep 2018 18:30:35 +0200 Subject: [PATCH 01/10] [enh] Move version numbers into _common.sh --- scripts/_common.sh | 4 ++++ scripts/install | 2 -- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 38e1984..3ea6568 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,3 +1,7 @@ +# Version numbers +flarum_version="0.1.0-beta.7" +ssowat_ext_ver="*@dev" + # Execute a command as another user # usage: exec_as USER COMMAND [ARG ...] exec_as() { diff --git a/scripts/install b/scripts/install index 5cc2bcc..2cb73fa 100644 --- a/scripts/install +++ b/scripts/install @@ -40,8 +40,6 @@ admin=$YNH_APP_ARG_ADMIN title=$YNH_APP_ARG_TITLE is_public=$YNH_APP_ARG_IS_PUBLIC language=$YNH_APP_ARG_LANGUAGE -flarum_version="v0.1.0-beta.7" -ssowat_ext_ver="*@dev" bazaar_extension=$YNH_APP_ARG_BAZAAR_EXTENSION #=================================================== From 8030e7a9b3d2ce0ba009ad9c188c1b77ca97d975 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Mon, 3 Sep 2018 18:34:44 +0200 Subject: [PATCH 02/10] [enh] Store ssowat extension version number --- scripts/install | 1 + scripts/upgrade | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 2cb73fa..2fe3af5 100644 --- a/scripts/install +++ b/scripts/install @@ -70,6 +70,7 @@ ynh_app_setting_set $app is_public $is_public ynh_app_setting_set $app language $language ynh_app_setting_set $app final_path $final_path ynh_app_setting_set $app flarum_version $flarum_version +ynh_app_setting_set $app ssowat_ext_ver $ssowat_ext_ver ynh_app_setting_set $app bazaar_extension $bazaar_extension #=================================================== diff --git a/scripts/upgrade b/scripts/upgrade index 8cadcd5..1ac8302 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -42,8 +42,6 @@ final_path=$(ynh_app_setting_get "$app" final_path) db_name=$(ynh_app_setting_get $app db_name) db_pwd=$(ynh_app_setting_get $app db_pwd) old_flarum_version=$(ynh_app_setting_get "$app" flarum_version) -flarum_version="v0.1.0-beta.7" -ssowat_ext_ver="*@dev" bazaar_extension=$(ynh_app_setting_get "$app" bazaar_extension) #================================================= @@ -204,4 +202,9 @@ fi systemctl reload nginx +#=================================================== +# STORE SETTINGS +#=================================================== + ynh_app_setting_set $app flarum_version $flarum_version +ynh_app_setting_set $app ssowat_ext_ver $ssowat_ext_ver From ed3c73348b758b10f5d0569cf7d840f04e9a57ee Mon Sep 17 00:00:00 2001 From: tituspijean Date: Mon, 3 Sep 2018 18:37:36 +0200 Subject: [PATCH 03/10] [enh] Use ynh_replace_string instead of sed in upgrade --- scripts/upgrade | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 1ac8302..ba3d1b8 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -137,11 +137,11 @@ fi # 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 From 396491a65f8c4cc2c3d80676deb48045015bb778 Mon Sep 17 00:00:00 2001 From: frju365 Date: Mon, 3 Sep 2018 19:10:13 +0200 Subject: [PATCH 04/10] change sign for string --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 8cadcd5..cdfbe97 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -112,7 +112,7 @@ fi # FLARUM UPGRADE #================================================= -if [[ $old_flarum_version -ne $flarum_version ]]; then +if [[ $old_flarum_version = $flarum_version ]]; then # Upgrade Flarum exec_composer $app $final_path "update --ansi" pushd $final_path From 2462b282f9060b6a19d5a2c872a604c68d5badf0 Mon Sep 17 00:00:00 2001 From: frju365 Date: Mon, 3 Sep 2018 19:11:22 +0200 Subject: [PATCH 05/10] revert change... not in a branch. Sorry. --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index cdfbe97..8cadcd5 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -112,7 +112,7 @@ fi # FLARUM UPGRADE #================================================= -if [[ $old_flarum_version = $flarum_version ]]; then +if [[ $old_flarum_version -ne $flarum_version ]]; then # Upgrade Flarum exec_composer $app $final_path "update --ansi" pushd $final_path From 6523a2d31df096c8cc90a7a8477ca3023543a10b Mon Sep 17 00:00:00 2001 From: tituspijean Date: Mon, 3 Sep 2018 19:53:07 +0200 Subject: [PATCH 06/10] [enh] Handle core and ssowat extension version numbers Fixes #94 Closes #67 --- scripts/_common.sh | 6 +++--- scripts/install | 7 +++++-- scripts/upgrade | 9 ++++++--- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 3ea6568..ff6ed04 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,6 +1,6 @@ # Version numbers -flarum_version="0.1.0-beta.7" -ssowat_ext_ver="*@dev" +flarum_version="0.1.0-beta.7.1" +ssowat_ext_ver="0.5" # Execute a command as another user # usage: exec_as USER COMMAND [ARG ...] @@ -69,7 +69,7 @@ install_and_activate_extension() { local new_extensions_enabled # Install extension - exec_composer $AS_USER $WORKDIR "require $EXTENSION --ansi -d $WORKDIR" + exec_composer $AS_USER $WORKDIR "require $EXTENSION -n --ansi -d $WORKDIR" # Retrieve current extensions sql_command="SELECT \`value\` FROM settings WHERE \`key\` = 'extensions_enabled'" diff --git a/scripts/install b/scripts/install index 2fe3af5..1474aaa 100644 --- a/scripts/install +++ b/scripts/install @@ -101,7 +101,10 @@ sudo chown -R $app:www-data $tmp sudo chmod -R 0775 $tmp # Install Flarum -exec_composer $app $final_path "create-project flarum/flarum $tmp $flarum_version --stability=beta --ansi -d $tmp" +# 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 +exec_composer $app $final_path "require flarum/core:$flarum_version -n --ansi -d $tmp" # Copy Flarum to working directory and clean temp directory sudo cp -Rf $tmp/* $final_path @@ -204,7 +207,7 @@ sql_command="REPLACE INTO \`settings\` (\`key\`, \`value\`) VALUES ('mail_port', '587');" ynh_mysql_execute_as_root "$sql_command" $db_name -# Install and active the SSOwat auth extension +# 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" # Configure SSOwat auth extension ssowatdomain=$( Date: Mon, 3 Sep 2018 20:18:06 +0200 Subject: [PATCH 07/10] Backup and restore php-fpm conf.ini Fixes #97 --- scripts/backup | 1 + scripts/restore | 1 + 2 files changed, 2 insertions(+) diff --git a/scripts/backup b/scripts/backup index aa59f65..1d863fd 100644 --- a/scripts/backup +++ b/scripts/backup @@ -50,6 +50,7 @@ ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= ynh_backup "/etc/php5/fpm/pool.d/$app.conf" +ynh_backup "/etc/php5/fpm/conf.d/20-$app.ini" #================================================= # BACKUP THE MYSQL DATABASE diff --git a/scripts/restore b/scripts/restore index 828a567..16cbde8 100644 --- a/scripts/restore +++ b/scripts/restore @@ -78,6 +78,7 @@ chmod -R 0775 $final_path #================================================= ynh_restore_file "/etc/php5/fpm/pool.d/$app.conf" +ynh_restore_file "/etc/php5/fpm/conf.d/20-$app.ini" #================================================= # RESTORE THE LOGROTATE CONFIGURATION From 728377daeebacc55c0eff00bb740ae7c086c207b Mon Sep 17 00:00:00 2001 From: tituspijean Date: Mon, 3 Sep 2018 20:37:35 +0200 Subject: [PATCH 08/10] [fix] Forgot ; after if statement --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 26d264b..33b8e9e 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -111,7 +111,7 @@ fi #================================================= # Downward compatibility: remove the v before version number -if [[ $old_flarum_version == "v*" ]] then $old_flarum_version = ${old_flarum_version:1}; fi +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-version $old_flarum_version lt $flarum_version ]]; then # Upgrade Flarum From 87a8db86e4da15ccb22c70551d2c0b66e35a8303 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Mon, 3 Sep 2018 20:52:48 +0200 Subject: [PATCH 09/10] [fix] Testing dpkg --correct-versions --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 33b8e9e..a6c105a 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -113,7 +113,7 @@ 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-version $old_flarum_version lt $flarum_version ]]; then +if [[ $(dpkg --compare-versions $old_flarum_version lt $flarum_version) ]]; then # Upgrade Flarum exec_composer $app $final_path "require -n flarum/core:'$flarum_version'" pushd $final_path From c838c74fa9fcc2c29d40b118c5b61f53bcc5e866 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Mon, 3 Sep 2018 21:24:38 +0200 Subject: [PATCH 10/10] [enh] Also check if SSOwat extension upgrade is needed --- scripts/upgrade | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index a6c105a..30978ef 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -42,6 +42,7 @@ final_path=$(ynh_app_setting_get "$app" final_path) db_name=$(ynh_app_setting_get $app db_name) db_pwd=$(ynh_app_setting_get $app db_pwd) old_flarum_version=$(ynh_app_setting_get "$app" flarum_version) +old_ssowat_ext_ver=$(ynh_app_setting_get "$app" ssowat_ext_ver) bazaar_extension=$(ynh_app_setting_get "$app" bazaar_extension) #================================================= @@ -123,12 +124,15 @@ else echo "Flarum doesn't need any update, let's check the extension." fi -# 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" -# Configure SSOwat auth extension -ssowatdomain=$(