#!/bin/bash #================================================= # GENERIC START #================================================= # Import common cmd source ./experimental_helper.sh source ./_common.sh # Source YunoHost helpers source /usr/share/yunohost/helpers # Stop script if errors ynh_abort_if_errors ynh_script_progression --message="Loading installation settings..." # Retrieve arguments domain=$(ynh_app_setting_get --app $app --key domain) path_url=$(ynh_normalize_url_path --path_url $(ynh_app_setting_get --app $app --key path)) seahub_port=$(ynh_app_setting_get --app $app --key seahub_port) fileserver_port=$(ynh_app_setting_get --app $app --key fileserver_port) webdav_port=$(ynh_app_setting_get --app $app --key webdav_port) final_path=$(ynh_app_setting_get --app $app --key final_path) seafile_user=$app seafile_data=/home/yunohost.app/seafile-data installed_version=${YNH_APP_CURRENT_VERSION/~ynh*/} seafile_version=$(ynh_app_upstream_version) if [ "$YNH_APP_CURRENT_VERSION" == '-' ]; then YNH_APP_CURRENT_VERSION="6.0.9~ynh0" installed_version=${YNH_APP_CURRENT_VERSION/~ynh*/} fi ynh_script_progression --message="Stoping services..." # stop seafile server if [ -e /etc/init.d/seafile-server ] then # Old init script support systemctl stop seafile-server --quiet systemctl disable seafile-server --quiet ynh_secure_remove --file=/etc/init.d/seafile-server yunohost service remove seafile-server else ynh_systemd_action --service_name seafile --action stop ynh_systemd_action --service_name seahub --action stop fi sleep 5 pkill -f seafile-controller || true pkill -f seaf-server || true pkill -f ccnet-server || true pkill -f seahub || true ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=30 # Backup the current version of the app if [ "0$(ynh_app_setting_get --app=$app --key=disable_backup_before_upgrade)" -ne 1 ] \ && (ynh_compare_current_package_version --comparison=ge --version='7.0.5~ynh1') then ynh_backup_before_upgrade ynh_clean_setup () { # Clean installation remainings that are not handled by the remove script. ynh_clean_check_starting ynh_restore_upgradebackup } fi #================================================= # MIGRATION FROM OLD VERSION #================================================= ynh_script_progression --message="Fixing old settings..." --weight=1 # Get configuration for user and final path if [ -z $final_path ]; then if [ -e /var/www/$app ]; then final_path=/var/www/$app elif [ -e /opt/yunohost/$app ]; then final_path=/opt/yunohost/$app else ynh_die --message "Error : can't find seafile path" fi fi if [ $final_path == "/var/www/$app" ]; then final_path="/opt/yunohost/$app" mkdir -p /opt/yunohost mv /var/www/$app /opt/yunohost/$app ynh_system_user_create --username $seafile_user --home_dir $final_path ynh_app_setting_set --app $app --key final_path --value $final_path test -e /var/log/seafile && rm /var/log/$app if ! [ -z "$(ls -A $final_path/seafile_data)" ]; then # Data directory NOT empty, transfer data to /home/yunohost.app/seafile mv $final_path/seafile_data/* /home/yunohost.app/seafile-data/ ynh_secure_remove $final_path/seafile_data ln -s /home/yunohost.app/seafile-data $final_path/ fi ln -s $final_path/logs /var/log/seafile fi ynh_script_progression --message="Upgrading source files..." --weight=6 # extract new version test -e $final_path/seafile-server-$seafile_version && ynh_secure_remove --file="$final_path/seafile-server-$seafile_version" install_source # Upgrade dependances ynh_script_progression --message="Upgrading dependencies..." install_dependance ynh_script_progression --message="Configuring application..." # permission to execute update script and expect helper mv_expect_scripts set_permission chmod u+x,o= $final_path/seafile-server-$seafile_version/upgrade/upgrade_*.sh chmod u+x,o= $final_path/seafile-server-$seafile_version/upgrade/minor-upgrade.sh # do the upgrade ( the ";&" syntax mean when it go in the first case which is true it do all the next case) case $installed_version in "4.0."* ) # Update seafile by script ynh_die "Upgrade form the version 4.0 was removed. Upgrade from this version won't be supported any more." ;& "4.1."* ) # Update seafile by script install_source_7_0 $expect_scripts_dir/upgrade_4.2.1.exp $final_path/seafile-server-7.0.5 ;& "4.3."* ) # Update seafile by script install_source_7_0 $expect_scripts_dir/upgrade_4.4.3.exp $final_path/seafile-server-7.0.5 ;& "4.4."* ) # Update seafile by script install_source_7_0 $expect_scripts_dir/upgrade_5.0.3.exp $final_path/seafile-server-7.0.5 ;& "5.0."* ) # Update seafile by script install_source_7_0 $expect_scripts_dir/upgrade_5.1.exp $final_path/seafile-server-7.0.5 ;& "5.1."* ) # Update seafile by script install_source_7_0 $expect_scripts_dir/upgrade_6.0.exp $final_path/seafile-server-7.0.5 ;& "6.0."* ) install_source_7_0 # Update seafile by script $expect_scripts_dir/upgrade_6.1.exp $final_path/seafile-server-7.0.5 # Enable manually wiki echo 'ENABLE_WIKI = True' | tee -a $final_path/conf/seahub_settings.py ;& "6.1."* ) # Update seafile by script install_source_7_0 $expect_scripts_dir/upgrade_6.2.exp $final_path/seafile-server-7.0.5 ;& "6.2."* ) # Update seafile by script install_source_7_0 $expect_scripts_dir/upgrade_6.3.exp $final_path/seafile-server-7.0.5 # Update logrotate to have the last version ynh_use_logrotate --logfile $final_path/logs --nonappend ;& "6.3."* ) # Update seafile by script install_source_7_0 $expect_scripts_dir/upgrade_7.0.exp $final_path/seafile-server-7.0.5 # SSO authentication echo 'ENABLE_REMOTE_USER_AUTHENTICATION = True' | tee -a $final_path/conf/seahub_settings.py echo "REMOTE_USER_HEADER = 'HTTP_EMAIL'" | tee -a $final_path/conf/seahub_settings.py echo 'REMOTE_USER_CREATE_UNKNOWN_USER = False' | tee -a $final_path/conf/seahub_settings.py echo "REMOTE_USER_PROTECTED_PATH = ['$path_url', '$path_url/accounts/login']" | tee -a $final_path/conf/seahub_settings.py # Clean connexion from the SSO. If we don't do this we could have some when the user was loged by the old SSO auth mecanisme ynh_mysql_execute_as_root --sql "DELETE FROM \`django_session\`" --database seahubdb ynh_print_warn --message "To be able to continue to use the SSO you probybly need to migrate your account. You can use the command 'yunohost app action run seafile migrate_user_email_to_mail_email' to migrate all of theses account. Note that after this migratation you need to reconfigure all your client with the official email of the user." ;& "7.0"* ) # Fix file comment pushd $final_path/seafile-server-$seafile_version sudo -u $seafile_user $final_path/seafile-server-$seafile_version/seahub.sh python-env python3 seahub/manage.py migrate_file_comment popd # Update seafile by script sudo -u $seafile_user $expect_scripts_dir/upgrade_7.1.exp $final_path/seafile-server-$seafile_version ynh_secure_remove --file="$final_path/seafile-server-7.0.5" # Enable memcached cat >> $final_path/conf/seahub_settings.py <