1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/nextcloud_ynh.git synced 2024-09-03 19:55:57 +02:00

Revert "remove upgrade_type"

This reverts commit 09219ab72d.
This commit is contained in:
Éric Gaspar 2024-04-19 12:20:29 +02:00
parent 09219ab72d
commit e509d3766d

View file

@ -3,6 +3,8 @@
source _common.sh
source /usr/share/yunohost/helpers
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
@ -146,28 +148,31 @@ then
fi
fi
ynh_script_progression --message="Upgrading $app..." --weight=3
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading $app..." --weight=3
# Set write access for the following commands
chown -R $app: "$install_dir" "$data_dir"
# Set write access for the following commands
chown -R $app: "$install_dir" "$data_dir"
# Print the current version number of Nextcloud
exec_occ -V
# Print the current version number of Nextcloud
exec_occ -V
# Upgrade may fail if this app is enabled
# Take all apps enabled, and check if mail is one of them
# Then temporary disable the mail app
mail_app_must_be_reactived=0
# Upgrade may fail if this app is enabled
# Take all apps enabled, and check if mail is one of them
# Then temporary disable the mail app
mail_app_must_be_reactived=0
if exec_occ app:list | awk '/Enabled/{f=1;next} /Disabled/{f=0} f' | grep -q -w mail; then
if exec_occ app:list | awk '/Enabled/{f=1;next} /Disabled/{f=0} f' | grep -q -w mail; then
exec_occ app:disable mail
mail_app_must_be_reactived=1
fi
fi
# While the current version is not the last version, do an upgrade
while [ "$last_version" != "$current_version" ]
do
# While the current version is not the last version, do an upgrade
while [ "$last_version" != "$current_version" ]
do
next_major_version="$(( $current_major_version + 1 ))"
if [[ "$next_major_version" -ge "$last_major_version" ]]; then
ynh_print_info --message="Upgrading to Nextcloud $last_version"
@ -221,81 +226,81 @@ do
# Print the current version number of Nextcloud
exec_occ -V
done
done
exec_occ db:add-missing-indices -n
exec_occ db:add-missing-columns -n
exec_occ db:add-missing-primary-keys -n
exec_occ db:convert-filecache-bigint -n
exec_occ db:add-missing-indices -n
exec_occ db:add-missing-columns -n
exec_occ db:add-missing-primary-keys -n
exec_occ db:convert-filecache-bigint -n
#=================================================
# CONFIGURE NEXTCLOUD
#=================================================
ynh_script_progression --message="Reconfiguring $app..." --weight=9
#=================================================
# CONFIGURE NEXTCLOUD
#=================================================
ynh_script_progression --message="Reconfiguring $app..." --weight=9
# Verify the checksum and backup the file if it's different
ynh_backup_if_checksum_is_different --file="$install_dir/config/config.php"
# Verify the checksum and backup the file if it's different
ynh_backup_if_checksum_is_different --file="$install_dir/config/config.php"
nc_conf="${install_dir}/config.json"
ynh_add_config --template="config.json" --destination="$nc_conf"
nc_conf="${install_dir}/config.json"
ynh_add_config --template="config.json" --destination="$nc_conf"
# Reneable the mail app
if [ $mail_app_must_be_reactived -eq 1 ]; then
# Reneable the mail app
if [ $mail_app_must_be_reactived -eq 1 ]; then
exec_occ app:enable mail
fi
fi
# Ensure that UpdateNotification app is disabled
exec_occ app:disable updatenotification
# Ensure that UpdateNotification app is disabled
exec_occ app:disable updatenotification
# Enable LDAP plugin
exec_occ app:enable user_ldap
# Enable LDAP plugin
exec_occ app:enable user_ldap
# Update all installed apps
exec_occ app:update --all
# Update all installed apps
exec_occ app:update --all
# move the logs from the data_dir to the standard /var/log
# it would be better in the ENSURE DOWNWARD COMPATIBILITY section
# but it must be after the exec_occ() definition, so it's here
if [ -f "$data_dir/data/nextcloud.log" ]; then
# move the logs from the data_dir to the standard /var/log
# it would be better in the ENSURE DOWNWARD COMPATIBILITY section
# but it must be after the exec_occ() definition, so it's here
if [ -f "$data_dir/data/nextcloud.log" ]; then
mkdir -p "/var/log/$app"
chmod 750 "/var/log/$app"
mv "$data_dir"/data/nextcloud.log* "/var/log/$app"
# adapt the nextcloud config
exec_occ config:system:set logfile --value="/var/log/$app/nextcloud.log"
fi
fi
# Load the config file in nextcloud
exec_occ config:import "$nc_conf"
# Load the config file in nextcloud
exec_occ config:import "$nc_conf"
# Then remove the config file
ynh_secure_remove --file="$nc_conf"
# Then remove the config file
ynh_secure_remove --file="$nc_conf"
#=================================================
# ALLOW USERS TO DISCONNECT FROM NEXTCLOUD
#=================================================
#=================================================
# ALLOW USERS TO DISCONNECT FROM NEXTCLOUD
#=================================================
# Add dynamic logout URL to the config
exec_occ config:system:get logout_url >/dev/null 2>&1 \
|| echo "
//-YunoHost-
// set logout_url according to main domain
\$main_domain = exec('cat /etc/yunohost/current_host');
\$CONFIG['logout_url'] = 'https://'.\$main_domain.'/yunohost/sso/?action=logout';
//-YunoHost-
" >> "$install_dir/config/config.php"
# Add dynamic logout URL to the config
exec_occ config:system:get logout_url >/dev/null 2>&1 \
|| echo "
//-YunoHost-
// set logout_url according to main domain
\$main_domain = exec('cat /etc/yunohost/current_host');
\$CONFIG['logout_url'] = 'https://'.\$main_domain.'/yunohost/sso/?action=logout';
//-YunoHost-
" >> "$install_dir/config/config.php"
#=================================================
# CHANGE HOSTNAME FOR ACTIVITY NOTIFICATIONS
#=================================================
#=================================================
# CHANGE HOSTNAME FOR ACTIVITY NOTIFICATIONS
#=================================================
exec_occ config:system:set overwrite.cli.url --value="https://${domain}${path}"
exec_occ config:system:set overwrite.cli.url --value="https://${domain}${path}"
#=================================================
# MOUNT HOME FOLDERS AS EXTERNAL STORAGE
#=================================================
#=================================================
# MOUNT HOME FOLDERS AS EXTERNAL STORAGE
#=================================================
# Enable External Storage and create local mount to home folder as needed
if [ $user_home -eq 1 ]; then
# Enable External Storage and create local mount to home folder as needed
if [ $user_home -eq 1 ]; then
exec_occ app:enable files_external
exec_occ files_external:list --output=json \
| grep -q '"storage":"\\\\OC\\\\Files\\\\Storage\\\\Local"' \
@ -304,15 +309,16 @@ if [ $user_home -eq 1 ]; then
for u in $(ynh_user_list); do
setfacl --modify g:$app:rwx "/home/$u" || true
done
fi
#=================================================
# STORE THE CHECKSUM OF THE CONFIG FILE
#=================================================
# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum --file="${install_dir}/config/config.php"
fi
#=================================================
# STORE THE CHECKSUM OF THE CONFIG FILE
#=================================================
# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum --file="${install_dir}/config/config.php"
#=================================================
# REGEN PERMISSIONS
#=================================================