1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/spip_ynh.git synced 2024-09-03 20:25:59 +02:00
spip_ynh/scripts/upgrade

158 lines
6.7 KiB
Text
Raw Normal View History

2017-03-26 16:26:55 +02:00
#!/bin/bash
2015-04-28 17:32:31 +02:00
2019-03-10 02:20:27 +01:00
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
2016-08-30 00:22:47 +02:00
2019-03-10 02:20:27 +01:00
source _common.sh
source /usr/share/yunohost/helpers
2021-05-18 04:02:21 +02:00
#=================================================
# CHECK VERSION
#=================================================
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# STANDARD UPGRADE STEPS
2019-03-10 02:20:27 +01:00
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
2020-12-18 10:52:22 +01:00
ynh_script_progression --message="Ensuring downward compatibility..."
2016-09-20 01:51:28 +02:00
2019-03-10 02:20:27 +01:00
# If users_status doesn't exist, create it
2023-06-01 10:09:17 +02:00
if [ -z "${users_status:-}" ]; then
2019-03-10 02:20:27 +01:00
users_status="Editor"
2020-12-18 10:52:22 +01:00
ynh_app_setting_set --app=$app --key=users_status --value=$users_status
2019-03-10 02:20:27 +01:00
fi
2019-03-10 02:20:27 +01:00
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
2021-05-18 04:02:21 +02:00
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading source files..."
# Download, check integrity, uncompress and patch the source from app.src
2023-06-01 10:01:18 +02:00
ynh_setup_source --dest_dir="$install_dir"
2021-05-18 04:02:21 +02:00
fi
2023-06-01 10:01:18 +02:00
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
2019-03-10 02:20:27 +01:00
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
2020-12-18 10:52:22 +01:00
ynh_script_progression --message="Upgrading PHP-FPM configuration..."
2019-03-10 02:20:27 +01:00
2021-05-18 04:02:21 +02:00
# Create a dedicated PHP-FPM config
2021-12-31 08:57:46 +01:00
ynh_add_fpm_config
2019-03-10 02:20:27 +01:00
2022-08-04 21:35:29 +02:00
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..."
# Create a dedicated NGINX config
ynh_add_nginx_config
2019-03-10 02:20:27 +01:00
#=================================================
# SPECIFIC UPGRADE
#=================================================
# SETUP APPLICATION WITH CURL
#=================================================
2021-05-24 12:31:28 +02:00
ynh_script_progression --message="Setuping application with CURL..."
2019-03-10 02:20:27 +01:00
# Set right permissions for curl install
2023-06-01 10:01:18 +02:00
mkdir -p $install_dir/plugins/auto
chown -R $app:www-data "$install_dir"
2019-03-10 02:20:27 +01:00
# Set the app as temporarily public for curl call
2021-05-18 04:02:21 +02:00
ynh_script_progression --message="Configuring SSOwat..."
2021-08-09 11:25:34 +02:00
2023-06-01 10:01:18 +02:00
ynh_backup_if_checksum_is_different --file="$install_dir/config/connect.php"
2019-03-10 02:20:27 +01:00
2023-06-01 10:01:18 +02:00
mv $install_dir/config/connect.php $install_dir/config/connect.php.ynh_bkp
2019-03-10 02:20:27 +01:00
2021-05-24 12:31:28 +02:00
# Installation with curl
ynh_script_progression --message="Finalizing installation..."
2019-03-10 02:20:27 +01:00
ynh_local_curl "/ecrire/?suivant" "exec=install" "etape=chmod"
2021-08-09 11:25:34 +02:00
ynh_local_curl "/ecrire/?suivant" "exec=install" "etape=2" "chmod=750" "adresse_db=localhost" "login_db=$db_name" "pass_db=$db_pwd" "server_db=mysql"
2019-03-10 02:20:27 +01:00
ynh_local_curl "/ecrire/?suivant" "exec=install" "etape=3" "adresse_db=localhost" "login_db=$db_name" "pass_db=$db_pwd" "server_db=mysql" "choix_db=$db_name" "tprefix=$db_name"
2019-03-13 21:25:07 +01:00
# For now spip have a problem with LDAP
#ynh_local_curl "/ecrire/?suivant" "exec=install" "etape=ldap1"
#ynh_local_curl "/ecrire/?suivant" "exec=install" "etape=ldap2" "adresse_ldap=localhost" "port_ldap=389" "tls_ldap=no" "protocole_ldap=3"
#ynh_local_curl "/ecrire/?suivant" "exec=install" "etape=ldap3" "adresse_ldap=localhost" "port_ldap=389" "tls_ldap=no" "protocole_ldap=3"
#ynh_local_curl "/ecrire/?suivant" "exec=install" "etape=ldap4" "adresse_ldap=localhost" "port_ldap=389" "tls_ldap=no" "protocole_ldap=3" "base_ldap=dc=yunohost,dc=org"
#
## statut_ldap can take: 0minirezo for Administrator, 1comite for Editor, 6forum for Visitor
#if [ $users_status = "Administrator" ]; then
# status="0minirezo"
#elif [ $users_status = "Editor" ]; then
# status="1comite"
#else
# status="6forum"
#fi
#ynh_local_curl "/ecrire/?suivant" "exec=install" "etape=ldap5" "adresse_ldap=localhost" "port_ldap=389" "tls_ldap=no" "protocole_ldap=3" "base_ldap=dc=yunohost,dc=org" "statut_ldap=$status" "ldap_login=sAMAccountName,uid,login,userid,cn,sn" "ldap_nom=cn" "ldap_email=mail" "ldap_bio=description"
#ynh_local_curl "/ecrire/?suivant" "exec=install" "etape=3" "ldap_present=true"
2019-03-10 02:20:27 +01:00
2020-04-25 21:44:42 +02:00
# Fix db initialization
ynh_local_curl "/ecrire/?exec=install" "etape=3b"
2019-03-10 02:20:27 +01:00
email=$(yunohost user info $admin | grep mail: | cut -d' ' -f2 | tr -d '\n')
2019-03-13 21:25:07 +01:00
ynh_local_curl "/ecrire/?suivant" "exec=install" "etape=3b" "adresse_db=localhost" "login_db=$db_name" "pass_db=$db_pwd" "server_db=mysql" "sel_db=$db_name" "nom=$admin" "email=$email" "login=$admin" "pass=$password" "pass_verif=$password"
2019-03-10 02:20:27 +01:00
ynh_local_curl "/ecrire/?suivant" "exec=install" "etape=fin"
#=================================================
2021-05-18 04:02:21 +02:00
# UPDATE A CONFIG FILE
2019-03-10 02:20:27 +01:00
#=================================================
2022-08-04 21:35:29 +02:00
ynh_script_progression --message="Updating a configuration file..."
2021-05-24 12:31:28 +02:00
2023-06-01 10:01:18 +02:00
#ynh_replace_string --match_string="'','utf8');" --replace_string="'ldap.php','utf8');" --target_file=$install_dir/config/connect.php
cp ../conf/mes_options.php $install_dir/config/mes_options.php
2019-03-10 02:20:27 +01:00
2023-06-01 10:09:17 +02:00
# Add security fix https://www.spip.net/en_article4201.html
cp ../conf/ecran_securite.php $install_dir/config/ecran_securite.php
2023-06-01 10:01:18 +02:00
if [ ! -f $install_dir/config/connect.php ]; then
mv $install_dir/config/connect.php.ynh_bkp $install_dir/config/connect.php
2021-06-18 10:58:09 +02:00
else
2023-06-01 10:01:18 +02:00
#REMOVEME? ynh_secure_remove --file="$install_dir/config/connect.php.ynh_bkp"
2021-06-18 10:58:09 +02:00
fi
2023-06-01 10:01:18 +02:00
ynh_store_file_checksum --file="$install_dir/config/connect.php"
2019-03-10 02:20:27 +01:00
2019-03-10 20:13:09 +01:00
#=================================================
# SEND INFORMATION
#=================================================
2023-06-01 10:01:18 +02:00
echo "To finish the upgrade, you may have to update the database by clicking on the button (if asked) at this location: https://$domain$path/ecrire/" > mail_to_send
2019-03-10 20:13:09 +01:00
ynh_send_readme_to_admin --app_message="mail_to_send" --type="upgrade"
2019-03-13 22:44:30 +01:00
if [ $migration_process -eq 1 ]
then
2020-12-18 10:52:22 +01:00
ynh_script_progression --message="Spip2 has been successfully migrated to Spip! \
2019-03-13 22:44:30 +01:00
A last scheduled operation will run in a couple of minutes to finish the \
migration in YunoHost side. Do not proceed any application operation while \
you don't see Spip as installed."
# Execute a post migration script after the end of this upgrade.
# Mainly for some cleaning
script_post_migration=spip2_post_migration.sh
cp ../conf/$script_post_migration /tmp
2020-12-18 10:52:22 +01:00
ynh_replace_string --match_string="__OLD_APP__" --replace_string="$old_app" --target_file=/tmp/$script_post_migration
ynh_replace_string --match_string="__NEW_APP__" --replace_string="$app" --target_file=/tmp/$script_post_migration
2019-03-13 22:44:30 +01:00
chmod +x /tmp/$script_post_migration
(cd /tmp; echo "/tmp/$script_post_migration > /tmp/$script_post_migration.log 2>&1" | at now + 2 minutes)
fi
2019-03-10 02:20:27 +01:00
#=================================================
# END OF SCRIPT
#=================================================
2020-12-18 10:52:22 +01:00
ynh_script_progression --message="Upgrade of $app completed" --last