How to use command to `scan all files` in NextCloud

Noob alert.

TrueNas: TrueNAS-SCALE-23.10.2
NextCloud:

  • App Version: 29.0.0
  • Chart Version: 1.6.61

I added new files to my NC via SMB and now I want to scan the folder so NC can detect the added files.

I found the command is

sudo -u www-data php occ files:scan --all

from here.

So what I am doing in TrueNas is the following:

  1. open shell
  2. cd into the data folder
  3. su
  4. and here is where I am stuck.
    I am trying to use the following:
    su -m www-data -c php occ files:scan
    opens a new empty line and nothing

What I am doing wrong ?

I don’t use NextCloud but I suspect that you need to get a shell opened inside the container instead of a raw/native shell.

I think you should use su and not sudo, but su prompts for a password and No idea what that would be inside the pod.

I have the same issue.
However, I do not know what the “data” folder should be.

ls -lah /
total 102K
drwxr-xr-x   1 root root   5 May  6 19:55 .
drwxr-xr-x   1 root root   5 May  6 19:55 ..
drwxr-xr-x   2 root root  74 Jul  9  2023 bin
drwxrwxr-x   1 root root   3 Jul  9  2023 bitnami
drwxr-xr-x   2 root root   2 Apr  2  2023 boot
drwxr-xr-x   5 root root 360 May  6 19:55 dev
lrwxrwxrwx   1 root root  40 Jul  9  2023 entrypoint.sh -> /opt/bitnami/scripts/redis/entrypoint.sh
drwxr-xr-x   1 root root   3 May  6 19:55 etc
drwxr-xr-x   2 root root   2 Apr  2  2023 home
drwxr-xr-x   7 root root   7 Aug 23  2022 lib
drwxr-xr-x   2 root root   3 Apr 18  2023 lib64
drwxr-xr-x   2 root root   2 Apr 18  2023 media
drwxr-xr-x   2 root root   2 Apr 18  2023 mnt
drwxrwxr-x   1 root root   3 Jul  9  2023 opt
dr-xr-xr-x 766 root root   0 May  6 19:55 proc
drwx------   2 root root   4 Apr 18  2023 root
drwxr-xr-x   4 root root   5 Apr 18  2023 run
lrwxrwxrwx   1 root root  33 Jul  9  2023 run.sh -> /opt/bitnami/scripts/redis/run.sh
drwxr-xr-x   2 root root  46 Jul  9  2023 sbin
drwxr-xr-x   2 root root   2 Apr 18  2023 srv
dr-xr-xr-x  13 root root   0 May  6 19:55 sys
drwxrwxrwt   3 root root   3 Jul  9  2023 tmp
drwxrwxr-x  11 root root  11 Jul  9  2023 usr
drwxr-xr-x  11 root root  13 Apr 18  2023 var

su -m www-data -c php occ files:scan

su -m www-data -c 'php /var/www/html/occ db:add-missing-indices'
Password: 
su: Authentication failure

This is a thread on similar issues.
nextcloud app database errors on fresh install

In my custom app nextcloud, I use this but it may need modified for your app version:

k3s kubectl exec -n ix-nextcloud --stdin --tty "$(/usr/local/bin/k3s kubectl -n ix-nextcloud get pods --field-selector status.phase=Running -o name | cut -f2 -d'/')" -- su -s /bin/bash www-data -c 'php occ files:scan --all'

Note that’s from the truenas command line, not the pod. So, you could simplify it to (within the pod):

su -s /bin/bash www-data -c 'php occ files:scan --all'

But you may need to replace www-data with whatever the user is for the app version. It might be the same, it might not, so, can’t say for sure it will work for the app version but it might.

This worked !

Just needed to add --all`` after files:scan```

Thank you all for your help and time!

Edit:
Here are the steps:

  1. open shell in pod
  2. su
  3. su -s /bin/bash www-data -c 'php occ files:scan --all'
1 Like

Great, glad to hear it. I missed typing that, sorry. Mine was setup to turn on maintenance mode and off and retyped it but missed the --all. But the point was the same so you fixed it and great.

I have to ask, what is the the password for su? I’m in a fresh install, and its neither the nextcloud password nor the truenas scale password.

Are you logging in to the TrueNAS GUI with root? Or another user? This is one reason I don’t use the new “admin user” feature.

1 Like

I’m admin. I’ve not touched the root account. I am somewhat new to TrueNAS so admin existed before I started.

@kris Is this a bug? That when you are the admin account instead of root you can’t execute su shell commands?

Enabling root with a password and logging in solves the problem

I migrated from core to scale and setup nextcloud. When i run this command I am asked about password and it does not take my root password (inherited from CORE) so is not admin
What should i be using to make this work.

Are you logging in to the GUI using the admin user?
You need to enable the root user to log in to the GUI and run the command that way.

I don’t use SCALE, so this was actually an (educated) guess on my part but it seemed that was the actual issue.

I’m not sure what IX recommends as the way to run root commands in pod shells if the root user is not enabled.

I am logged in with the root user which was the admin for Freebsd CORE. I am not sure what is meant by enable the root user? I use the above root user to login to GUI and am running the commands with that user.
Always get Authentication failure