mirror of
https://github.com/YunoHost-Apps/flarum_ynh.git
synced 2024-09-03 18:36:24 +02:00
[enh] Use ynh_print_* helpers
This commit is contained in:
commit
3fb3dda94a
3 changed files with 20 additions and 6 deletions
|
@ -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
|
||||
|
|
|
@ -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=$(</etc/yunohost/current_host)
|
||||
sql_command="INSERT 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_print_info "SSOwat extension has been installed."
|
||||
|
||||
# Install, activate and set language extensions
|
||||
case $language in
|
||||
|
@ -220,21 +225,24 @@ case $language in
|
|||
install_and_activate_extension $app $final_path $db_name "milescellar/flarum-ext-french" "milescellar-french"
|
||||
sql_command="UPDATE \`settings\` SET \`value\` = 'fr' WHERE \`settings\`.\`key\` = 'default_locale'"
|
||||
ynh_mysql_execute_as_root "$sql_command" $db_name
|
||||
ynh_print_info "French language has been installed."
|
||||
;;
|
||||
de)
|
||||
install_and_activate_extension $app $final_path $db_name "cbmainz/flarum-de" "cbmainz-de"
|
||||
sql_command="UPDATE \`settings\` SET \`value\` = 'de' WHERE \`settings\`.\`key\` = 'default_locale'"
|
||||
ynh_mysql_execute_as_root "$sql_command" $db_name
|
||||
ynh_print_info "German language has been installed."
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ $bazaar_extension -eq 1 ]; then
|
||||
exec_composer $app $final_path "require flagrow/bazaar --ansi"
|
||||
ynh_print_info "Bazaar extension has been installed."
|
||||
fi
|
||||
|
||||
# Send login credentials to admin
|
||||
app_message="User : $admin, password : $admin_pwd
|
||||
Change your password!
|
||||
Your forum is accessible at https://$domain$path_url"
|
||||
>&2 echo $app_message
|
||||
ynh_send_readme_to_admin "$app_message" "$admin"
|
||||
ynh_print_warn "$app_message"
|
||||
|
|
|
@ -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=$(</etc/yunohost/current_host)
|
||||
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_print_info "SSOwat extension has been updated and configured."
|
||||
else
|
||||
ynh_print_info "SSOwat extension does not need updating."
|
||||
fi
|
||||
|
||||
if [ $bazaar_extension -eq 1 ]; then
|
||||
install_and_activate_extension $app $final_path $db_name "flagrow/bazaar" "flagrow-bazaar"
|
||||
ynh_print_info "Bazaar extension has been installed."
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
|
Loading…
Reference in a new issue