Hey Nexcloud - STOP OVERWRITING .user.ini & .htaccess on upgrades

Hey Nexcloud - STOP OVERWRITING .user.ini & .htaccess on upgrades

read that again - you’ve been doing it incessantly

STOP OVERWRITING .user.ini & .htaccess on upgrades

It causes a need to manually edit these files.
It causes the checks to fail requiring disabling the security features.

Move these settings to the DB if you must. Or do something intelligent.
But this has been around since version 8.

2 Likes

Normally, you should be able to put modifications below this line in your .htaccess

#### DO NOT CHANGE ANYTHING ABOVE THIS LINE ####

What kind of update you’re using ?
Manual or via the Updater ?

Hi,

I’ve just installed Nextcloud 12.0.1 and edited the .htaccess BELOW the mention “#### DO NOT CHANGE ANYTHING ABOVE THIS LINE ####”.

I upgraded Nextcloud to version 12.0.2 via the web interface.

Unfortunately everything located BELOW the specific mention disappeared…

May nextcloud devs can copy paste the added content during upgrades ?

I have the same problem.

@LukasReschke is there a way to keep existing settings automatically?

Indeed, this is very annoying, especially if updates come in fast cycles. The maximum upload size gets reset every time to the default value of 512 MB. It has to be set to the right value after each minor update in the admin settings.

This subject is one of the things, why NC is by far not a cloud for everybody - everytime you make an update, you have to go with some ftp-program to search for a file which is usually not even visible on Mac OS and to download it, edit some lines in it, upload it again - almost impossible for the consumer / enduser, but even if you managed once, its coming after you after every update… (in my case in a hosted enviroment)

1 Like

I did the following (if it’s a good idea … you should decide)

In my NC Dir /var/www/ i created a Script named “.upd_nc.sh” (Update Mode) with following code

#!/bin/bash
#Sets permissions of the Nextcloud instance for updating

ncpath=’/var/www/nextcloud’
htuser='www-data’
htgroup=‘www-data’

cp /var/www/nextcloud/.htaccess /var/www/Backup/.htaccess
cp /var/www/nextcloud/.user.ini /var/www/Backup/.user.ini
chown -R ${htuser}:${htgroup} ${ncpath}

I made the script executable and run it before the Updater starts

After the Update, very important that the Updater once passed the integrity check with the original .user.ini and .htaccess files (!), I use a second Script named “.run_nc.sh” (to get my settings back) with following code

#!/bin/bash
ncpath=’/var/www/nextcloud’
htuser='www-data’
htgroup='www-data’
rootuser=‘root’

printf "Creating possible missing Directories\n"
mkdir -p $ncpath/updater

printf "chmod Files and Directories\n"
find ${ncpath} -type f -print0 | xargs -0 chmod 0640
find ${ncpath} -type d -print0 | xargs -0 chmod 0750

printf "chown Directories\n"
chown -R ${rootuser}:${htgroup} ${ncpath}
chown -R ${htuser}:${htgroup} ${ncpath}/apps/
chown -R ${htuser}:${htgroup} ${ncpath}/config/
chown -R ${htuser}:${htgroup} ${ncpath}/themes/
chown -R ${htuser}:${htgroup} ${ncpath}/updater/

cp /var/www/Backup/.htaccess /var/www/nextcloud/.htaccess
cp /var/www/Backup/.user.ini /var/www/nextcloud/.user.ini
chmod +x ${ncpath}/occ

printf "chmod/chown .htaccess\n"
if [ -f ${ncpath}/.htaccess ]
then
chmod 0644 ${ncpath}/.htaccess
chown ${rootuser}:${htgroup} ${ncpath}/.htaccess
fi
if [ -f ${ncpath}/data/.htaccess ]
then
chmod 0644 ${ncpath}/data/.htaccess
chown ${rootuser}:${htgroup} ${ncpath}/data/.htaccess
fi

With that I get back my own values in .htaccess and .user.ini by bash script.

MayBe a way to workaround the “problem” ?

Yes, it is a way to do it, but I think the updater should do this out of the box.

I see that there is obviously no bug report on Github for this issue, so creating one would be advisable.

2 Likes

Okay, here is the bug report:

3 Likes