mirror of
https://github.com/YunoHost-Apps/flarum_ynh.git
synced 2024-09-03 18:36:24 +02:00
Merge pull request #100 from YunoHost-Apps/testing
Better handling of version numbers
This commit is contained in:
commit
a9c2393592
5 changed files with 37 additions and 19 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
# Version numbers
|
||||||
|
flarum_version="0.1.0-beta.7.1"
|
||||||
|
ssowat_ext_ver="0.5"
|
||||||
|
|
||||||
# Execute a command as another user
|
# Execute a command as another user
|
||||||
# usage: exec_as USER COMMAND [ARG ...]
|
# usage: exec_as USER COMMAND [ARG ...]
|
||||||
exec_as() {
|
exec_as() {
|
||||||
|
@ -65,7 +69,7 @@ install_and_activate_extension() {
|
||||||
local new_extensions_enabled
|
local new_extensions_enabled
|
||||||
|
|
||||||
# Install extension
|
# 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
|
# Retrieve current extensions
|
||||||
sql_command="SELECT \`value\` FROM settings WHERE \`key\` = 'extensions_enabled'"
|
sql_command="SELECT \`value\` FROM settings WHERE \`key\` = 'extensions_enabled'"
|
||||||
|
|
|
@ -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/pool.d/$app.conf"
|
||||||
|
ynh_backup "/etc/php5/fpm/conf.d/20-$app.ini"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE MYSQL DATABASE
|
# BACKUP THE MYSQL DATABASE
|
||||||
|
|
|
@ -40,8 +40,6 @@ admin=$YNH_APP_ARG_ADMIN
|
||||||
title=$YNH_APP_ARG_TITLE
|
title=$YNH_APP_ARG_TITLE
|
||||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||||
language=$YNH_APP_ARG_LANGUAGE
|
language=$YNH_APP_ARG_LANGUAGE
|
||||||
flarum_version="v0.1.0-beta.7"
|
|
||||||
ssowat_ext_ver="*@dev"
|
|
||||||
bazaar_extension=$YNH_APP_ARG_BAZAAR_EXTENSION
|
bazaar_extension=$YNH_APP_ARG_BAZAAR_EXTENSION
|
||||||
|
|
||||||
#===================================================
|
#===================================================
|
||||||
|
@ -72,6 +70,7 @@ ynh_app_setting_set $app is_public $is_public
|
||||||
ynh_app_setting_set $app language $language
|
ynh_app_setting_set $app language $language
|
||||||
ynh_app_setting_set $app final_path $final_path
|
ynh_app_setting_set $app final_path $final_path
|
||||||
ynh_app_setting_set $app flarum_version $flarum_version
|
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
|
ynh_app_setting_set $app bazaar_extension $bazaar_extension
|
||||||
|
|
||||||
#===================================================
|
#===================================================
|
||||||
|
@ -102,7 +101,10 @@ sudo chown -R $app:www-data $tmp
|
||||||
sudo chmod -R 0775 $tmp
|
sudo chmod -R 0775 $tmp
|
||||||
|
|
||||||
# Install Flarum
|
# 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
|
# Copy Flarum to working directory and clean temp directory
|
||||||
sudo cp -Rf $tmp/* $final_path
|
sudo cp -Rf $tmp/* $final_path
|
||||||
|
@ -205,7 +207,7 @@ sql_command="REPLACE INTO \`settings\` (\`key\`, \`value\`) VALUES
|
||||||
('mail_port', '587');"
|
('mail_port', '587');"
|
||||||
ynh_mysql_execute_as_root "$sql_command" $db_name
|
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"
|
install_and_activate_extension $app $final_path $db_name "tituspijean/flarum-ext-auth-ssowat:$ssowat_ext_ver" "tituspijean-auth-ssowat"
|
||||||
# Configure SSOwat auth extension
|
# Configure SSOwat auth extension
|
||||||
ssowatdomain=$(</etc/yunohost/current_host)
|
ssowatdomain=$(</etc/yunohost/current_host)
|
||||||
|
|
|
@ -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/pool.d/$app.conf"
|
||||||
|
ynh_restore_file "/etc/php5/fpm/conf.d/20-$app.ini"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE LOGROTATE CONFIGURATION
|
# RESTORE THE LOGROTATE CONFIGURATION
|
||||||
|
|
|
@ -42,8 +42,7 @@ final_path=$(ynh_app_setting_get "$app" final_path)
|
||||||
db_name=$(ynh_app_setting_get $app db_name)
|
db_name=$(ynh_app_setting_get $app db_name)
|
||||||
db_pwd=$(ynh_app_setting_get $app db_pwd)
|
db_pwd=$(ynh_app_setting_get $app db_pwd)
|
||||||
old_flarum_version=$(ynh_app_setting_get "$app" flarum_version)
|
old_flarum_version=$(ynh_app_setting_get "$app" flarum_version)
|
||||||
flarum_version="v0.1.0-beta.7"
|
old_ssowat_ext_ver=$(ynh_app_setting_get "$app" ssowat_ext_ver)
|
||||||
ssowat_ext_ver="*@dev"
|
|
||||||
bazaar_extension=$(ynh_app_setting_get "$app" bazaar_extension)
|
bazaar_extension=$(ynh_app_setting_get "$app" bazaar_extension)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -112,9 +111,12 @@ fi
|
||||||
# FLARUM UPGRADE
|
# FLARUM UPGRADE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
if [[ $old_flarum_version -ne $flarum_version ]]; then
|
# 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
|
||||||
# Upgrade Flarum
|
# Upgrade Flarum
|
||||||
exec_composer $app $final_path "update --ansi"
|
exec_composer $app $final_path "require -n flarum/core:'$flarum_version'"
|
||||||
pushd $final_path
|
pushd $final_path
|
||||||
exec_as $app php flarum cache:clear
|
exec_as $app php flarum cache:clear
|
||||||
popd
|
popd
|
||||||
|
@ -122,12 +124,15 @@ else
|
||||||
echo "Flarum doesn't need any update, let's check the extension."
|
echo "Flarum doesn't need any update, let's check the extension."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Update SSOwat extension
|
# Check if upgrade of SSOwat extension is needed
|
||||||
|
if [[ $(dpkg --compare-versions $old_ssowat_ext_ver lt $ssowat_ext_ver) ]] || [ -z $old_ssowat_ext_ver] ; then
|
||||||
|
# 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"
|
install_and_activate_extension $app $final_path $db_name "tituspijean/flarum-ext-auth-ssowat:$ssowat_ext_ver" "tituspijean-auth-ssowat"
|
||||||
# Configure SSOwat auth extension
|
# Configure SSOwat auth extension
|
||||||
ssowatdomain=$(</etc/yunohost/current_host)
|
ssowatdomain=$(</etc/yunohost/current_host)
|
||||||
sql_command="INSERT IGNORE INTO \`settings\` (\`key\`, \`value\`) VALUES ('tituspijean-auth-ssowat.domain', '$ssowatdomain'), ('tituspijean-auth-ssowat.onlyUse', '0');"
|
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
|
ynh_mysql_execute_as_root "$sql_command" $db_name
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ $bazaar_extension ]]; then
|
if [[ $bazaar_extension ]]; then
|
||||||
install_and_activate_extension $app $final_path $db_name "flagrow/bazaar" "flagrow-bazaar"
|
install_and_activate_extension $app $final_path $db_name "flagrow/bazaar" "flagrow-bazaar"
|
||||||
|
@ -139,11 +144,11 @@ fi
|
||||||
|
|
||||||
# Bug in Nginx with locations and aliases (see http://stackoverflow.com/a/35102259 )
|
# Bug in Nginx with locations and aliases (see http://stackoverflow.com/a/35102259 )
|
||||||
if [ $path_url = "/" ]; then
|
if [ $path_url = "/" ]; then
|
||||||
sed -i "s@__LOCATION_HACK__@@g" ../conf/nginx.conf
|
ynh_replace_string "__LOCATION_HACK__" "" "../conf/nginx.conf"
|
||||||
sed -i "s@__PATH_HACK__@/@g" ../conf/nginx.conf
|
ynh_replace_string "__PATH_HACK__" "/" "../conf/nginx.conf"
|
||||||
else
|
else
|
||||||
sed -i "s@__LOCATION_HACK__@$path_url@g" ../conf/nginx.conf
|
ynh_replace_string "__LOCATION_HACK__" "$path_url" "../conf/nginx.conf"
|
||||||
sed -i "s@__PATH_HACK__@$path_url$path_url@g" ../conf/nginx.conf
|
ynh_replace_string "__PATH_HACK__" "$path_url$path_url" "../conf/nginx.conf"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create a dedicated nginx config
|
# Create a dedicated nginx config
|
||||||
|
@ -204,4 +209,9 @@ fi
|
||||||
|
|
||||||
systemctl reload nginx
|
systemctl reload nginx
|
||||||
|
|
||||||
|
#===================================================
|
||||||
|
# STORE SETTINGS
|
||||||
|
#===================================================
|
||||||
|
|
||||||
ynh_app_setting_set $app flarum_version $flarum_version
|
ynh_app_setting_set $app flarum_version $flarum_version
|
||||||
|
ynh_app_setting_set $app ssowat_ext_ver $ssowat_ext_ver
|
||||||
|
|
Loading…
Add table
Reference in a new issue