Change logo & backgroud img via OCC command line

Dear Team,
Nextcloud 19
I am trying to make a script which deploy vm with pre-configured nextcloud.
I am stuck at changing the logo and backgroud image

Change logo & backgroud img via OCC command line

php -f occ config:app:set --value=‘Opensource drive’ theming slogan
php -f occ config:app:set --value=http://nextcloud.com theming url
php -f occ config:app:set --value=image/png theming logoMime

I can change the logo and backgroud (and other stuff) from frontend.
But i want to do it via script.
It will also be okay to replace any existing file.

Please help i checked the admin manual but couldn’t find it.
I also didn’t found anything in database.

4 Likes

Sadly the logos don’t appear to be set-able via occ.

The logo images are stored in a folder in ./data that corresponds to your instance id. Which I believe is set on installation.

To change the logos via the command line you need to find your instance id using:

sudo -u www-data php occ config:system:get instanceid

In the commands below replace <INSTANCE_ID> with the value returned from the last command.

if you’re on a new install you’ll first need to create a theming/images file. So run:

sudo -u www-data mkdir -p ./data/appdata_<INSTANCE_ID>/theming/images

then regardless of whether you’ve previously set the image you’ll want to run:

sudo cp /path/to/logo ./data/appdata_<INSTANCE_ID>/theming/images/logo
sudo chown www-data:www-data ./data/appdata_<INSTANCE_ID>/theming/images/logo

which will copy your new logo to the correct location and allow the www-data user to edit it.

If you open a browser at this point the logo won’t have changed. To get it to change you need to tick the cachebuster. You can see the current cachebuster value with:

sudo -u www-data php occ config:app:get theming cachebuster

and then set it to one value higher using:

sudo -u www-data php occ config:app:set theming cachebuster --value 10

I came exactly to the same solution like you describe here. But I think you missed the setting of the corresponding mimetype - like
sudo -u www-data php occ config:app:set theming logoMime --value=“image/jpeg”
or something like that. I didn’t try it without, so I don’t know if it is really necessary

It worked for me without it, but it might not be a bad idea to include that too.

I found out another thing about it. At least the background image is cached in the Nextcloud-Filecache, and if you don’t flush the cache, it might happen that you only load half the picture (if the new one is double sized for example) and this results in loading error… My solution for it, after changing any of the pictures (logo, logoheader, background or favicon):
docker exec nextcloud_db_1 /usr/bin/mysql -h127.0.0.1 -Dnextcloud -unextcloud -pMYPASSWORD --execute “DELETE FROM filecache where path LIKE “appdata_%/theming/images/filename”;”
filename must be replaced with logo, logoheader, background or favicon
and now, everything works like a charm - i can change all of the 4 images programatically without useing the Nextcloud-UI