How to run console OCC Nextcloud command in TrueNAS Scale

mitma

Cadet
Joined
Oct 5, 2022
Messages
8
Hello community, I'm new to TrueNAS. I'm testing TrueNAS Scale in VirtualBox and all is fine. I installed Nextcloud with Collabora, but now I'm searching the way to run the Nextcloud's occ comand.

Opening a TrueNAS's shell, using the "find" linux's command, I located "occ" in "/mnt/<myPool>/ix-applications/releases/<myNextcloudName>/volumes/ix_volumes/ix-nextcloud_data/html/occ", whereas there are two "config" folders:

1) [owner=www-data] > "/mnt/<myPool>/ix-applications/releases/<myNextcloudName>/volumes/ix_volumes/ix-nextcloud_data/config"

2) [owner=root] > "/mnt/<myPool>/ix-applications/releases/<myNextcloudName>/volumes/ix_volumes/ix-nextcloud_data/html/config"

By changing the directory to "/mnt/<myPool>/ix-applications/releases/<myNextcloudName>/volumes/ix_volumes/ix-nextcloud_data/html" in the shell, to give the occ command like:

# sudo -u www-data php occ maintenance:mode --on

it says the config folder is not writable (the owner of that folder, that is the second listed, is root, infact, differently from the first one listed above, whose owner is www-data)...

So the question: how to use the Nextcloud's occ tool inside TrueNAS Scale?

Thank you so much for your support
 

SnoppyFloppy

Explorer
Joined
Jun 17, 2021
Messages
77
You are running Nextcloud in a container. If you want to use the OCC command you need to access the appropriate containers shell. In the Scale WebUI, Under Applications > Installed Applications, locate the app, click the icon in the upper right corner (I think it is three dots) and select shell from the drop-down. Then select the correct pod and container in the popup and voilà...
 

mitma

Cadet
Joined
Oct 5, 2022
Messages
8
You are running Nextcloud in a container. If you want to use the OCC command you need to access the appropriate containers shell. In the Scale WebUI, Under Applications > Installed Applications, locate the app, click the icon in the upper right corner (I think it is three dots) and select shell from the drop-down. Then select the correct pod and container in the popup and voilà...
Hello @SnoppyFloppy , thank you for you support. Trying your instructions, using:

pod: <Nextcloud_Application_Name>-nextcloud-<digits>-nl566
container: nextcloud
commands: /bin/sh

I can access to the Nextcloud's root folder but, trying an occ command like the previous one (sudo -u www-data php occ maintenance:mode --on), I get the error: "/bin/sh: 1: sudo: not found"...

There is certainly something wrong that I am still doing. Thank you
 

mitma

Cadet
Joined
Oct 5, 2022
Messages
8
Hello @SnoppyFloppy , thank you for you support. Trying your instructions, using:

pod: <Nextcloud_Application_Name>-nextcloud-<digits>-nl566
container: nextcloud
commands: /bin/sh

I can access to the Nextcloud's root folder but, trying an occ command like the previous one (sudo -u www-data php occ maintenance:mode --on), I get the error: "/bin/sh: 1: sudo: not found"...

There is certainly something wrong that I am still doing. Thank you
I found this similar topic but perhaps it refers to TrueNAS Core, not Scale. Anyway, giving 'pwd' command to locate the nextcloud folder in the container's shell (/var/www/html), I therefore replaced the path for occ in this way:
su -m www-data -c 'php /var/www/html/occ maintenance:mode --on'
but it says that this account (www-data) is currently not available...
 

mitma

Cadet
Joined
Oct 5, 2022
Messages
8
I found this similar topic but perhaps it refers to TrueNAS Core, not Scale. Anyway, giving 'pwd' command to locate the nextcloud folder in the container's shell (/var/www/html), I therefore replaced the path for occ in this way:
su -m www-data -c 'php /var/www/html/occ maintenance:mode --on'
but it says that this account (www-data) is currently not available...
Great, SOLVED!
The list of commands, in the container's shell, after the login, are:
  1. List folder content: ls
  2. to know the current path (in my case: '/var/www/html'): pwd
  3. become root: su
  4. occ command: su -m www-data -c 'php $(pwd)/occ maintenance:mode --on'
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
So the sudo command isn't installed in the container. What about su? The equivalent command would be su www-data -c 'php occ maintenance:mode --on'
 

mitma

Cadet
Joined
Oct 5, 2022
Messages
8
So the sudo command isn't installed in the container. What about su? The equivalent command would be su www-data -c 'php occ maintenance:mode --on'
Hello @danb35, this last one (su www-data -c 'php occ maintenance:mode --on') give me the previous error: this account is currently not available. Yes, it seems that sudo isn't installed in the container, perhaps for security reasons, I think?
 

mitma

Cadet
Joined
Oct 5, 2022
Messages
8
So the sudo command isn't installed in the container. What about su? The equivalent command would be su www-data -c 'php occ maintenance:mode --on'
Sorry @danb35, maybe you meant:
su -m www-data -c 'php occ maintenance:mode --on'
Yes, it works too! Great
 

SnoppyFloppy

Explorer
Joined
Jun 17, 2021
Messages
77
By the way @mitma are you running the iX systems nextcloud app or the Truecharts one?

I run the truecharts one and I've newer used the one from iX systems.

The truecharts Nextcloud app supports bash shell which I much prefer over sh. Further more you will run as user www-data which means that you simply run occ commands like this ./occ maintenance:mode --on
 
Last edited:

mitma

Cadet
Joined
Oct 5, 2022
Messages
8
By the way @mitma are you running the iX systems nextcloud app or the Truecharts one?

I run the truecharts one and I've newer used the one from iX systems.

The truecharts Nextcloud app supports bash shell which I much prefer over sh. Further more you will run as user www-data which means that you simply run occ commands like this ./occ maintenance:mode --on
Hello @SnoppyFloppy, I'm new to the terminology; if I understood, with "iX systems" you mean the official app supported by TrueNAS, while "Truecharts" is the Community's one? In that case, I have only the official repository (have to find the repositories for the community's apps. I saw some videos on YouTube that show other apps too, but in my case they are not available). Maybe the "ix-" in my paths stands for "iX systems"?
 

SnoppyFloppy

Explorer
Joined
Jun 17, 2021
Messages
77
Hello @SnoppyFloppy, I'm new to the terminology; if I understood, with "iX systems" you mean the official app supported by TrueNAS, while "Truecharts" is the Community's one? In that case, I have only the official repository (have to find the repositories for the community's apps. I saw some videos on YouTube that show other apps too, but in my case they are not available). Maybe the "ix-" in my paths stands for "iX systems"?
Yes I'm referring to the official and community apps. I would chose the Truecharts over the official apps any day. They have much more options exposed during configuration and easy setup to reverse proxy your apps with Traefik.

Have a look at https://truecharts.org/. Under Docs --> SCALE Apps you will find a lot of quick start guides including how to add the catalogue to Scale. There are also some youtube vids though they haven't been updated for a while most of them are still pretty accurate though. There's also a discord channel where you can ask for help AFTER you have read the aforementioned guides.

And by the way: They have A LOT more apps available.
 

mitma

Cadet
Joined
Oct 5, 2022
Messages
8
Yes I'm referring to the official and community apps. I would chose the Truecharts over the official apps any day. They have much more options exposed during configuration and easy setup to reverse proxy your apps with Traefik.

Have a look at https://truecharts.org/. Under Docs --> SCALE Apps you will find a lot of quick start guides including how to add the catalogue to Scale. There are also some youtube vids though they haven't been updated for a while most of them are still pretty accurate though. There's also a discord channel where you can ask for help AFTER you have read the aforementioned guides.

And by the way: They have A LOT more apps available.
Great, @SnoppyFloppy, thank you for all your informations, I will explore them!
Greetings
 

artstar

Dabbler
Joined
Jan 10, 2022
Messages
36
Many thanks for posting the solution here. This recent upgrade (official TrueNAS, not Truecharts) from v25 to v26 rendered my installation locked into maintenance mode, so I needed this to get it back out!
 

plinsboorg

Cadet
Joined
Apr 4, 2023
Messages
3
Thank you @mitma . Just used your 4-step instruction to run the memories nextcloud app indexing.
# su
root@....# su -m www-data -c 'php /var/www/html/occ memories:index'
 

LV52

Dabbler
Joined
Oct 14, 2022
Messages
10
Great, SOLVED!
The list of commands, in the container's shell, after the login, are:
  1. List folder content: ls
  2. to know the current path (in my case: '/var/www/html'): pwd
  3. become root: su
  4. occ command: su -m www-data -c 'php $(pwd)/occ maintenance:mode --on'
Hi, I am confuse about the password about the su. when I use the command: su, the system requires me to enter su's password, but I don't know which password I should use. Thanks!
 

Migamix

Cadet
Joined
Sep 20, 2023
Messages
1
posting here because it is FULLY relevant to the issue of occ commands
my solution for other noobs about to kick their NAS (even with decades of technical knowledge truenas has made me up my med doses)
i have no idea why this didint work until the 898698th issuing of the same command but i do see the difference in the current commands this time for me so im placing my detailed solution that actually worked for TrueNAS-SCALE-23.10.0.1.
i also dont know why the nextcloud installer said it would take a long time, as it completed in microseconds and frankly should have been done during install. but my NC instance had a warning of needing...
occ db:add-missing-indices


how to get there to issue the command since everyone leaves out the steps because assumptions of knowlege level of others:
  • in the appliocations screen >
  • click on nextcloud >
  • under workloads: click on the "shell" button for the main nexcloud container (mine is docker.io/library/nextcloud:28.0.0) >
window pops up >
  • container = nextcloud
  • pods = nextcloud-#$#$#$#$#$#-$$$$ (#numbers'n'$characters) (not postgres- or nginx-)
  • commands = /bin/bash
  • "choose"
type
  • su
  • su -m www-data -c 'php /var/www/html/occ db:add-missing-indices'
sudo is NOT installed so the su command must be used even after elevating to su (mentioned in this thread)​
the ' matters, do not use " (single quote vs double quote)​
<rant> talk to us like we are five, and assume if we post under trunas SCALE, we are talking about SCALE stock apps and NOT CORE jails, (and yes, i know some post questions about core under scale, that confusion mess is IX's fault IMO).
you want to direct us to another repo, give us a valid reason for it instead of thinking thats what we are talking about, if i have an issue with charts apps, ill go to their forums. some people type alot but never get to the point (IDK if this comment offends some posters, its a fact well know about this community)</rant>
 

Attachments

  • Screenshot 2023-12-17 140314.png
    Screenshot 2023-12-17 140314.png
    48.4 KB · Views: 258

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
and assume if we post under trunas SCALE, we are talking about SCALE stock apps and NOT CORE jails,
Sure glad you used your first post ever in this forum to rant and insult the folks here. Nobody--literally nobody--in this thread said anything about CORE jails until this post of yours. But to assume that anyone posting here is talking about iX apps rather than TrueCharts apps is just nonsensical--even if you know to ask on their forum (they have a forum now?), it's manifestly the case that a whole lot of people don't. So even in the minority of cases where iX has an app that TrueCharts also has, and someone's posting asking about one of those apps (like Nextcloud, for example), it would be foolish to just assume that the poster is asking about the iX rather than the TrueCharts app. But that also was not an issue in this thread.

So, thanks for your rant that had nothing at all to do with this thread, I guess.
 

arun2118

Cadet
Joined
Jan 5, 2024
Messages
5
Hi, I am confuse about the password about the su. when I use the command: su, the system requires me to enter su's password, but I don't know which password I should use. Thanks!
Did you find a answer i'm dealing with the same issue now.
 

mitzaotomitza

Dabbler
Joined
Jan 10, 2024
Messages
20
So the sudo command isn't installed in the container. What about su? The equivalent command would be su www-data -c 'php occ maintenance:mode --on'
When I run:
su www-data -c 'php occ maintenance:mode --on'
I get in the Nextcloud Pod Shell: " This account is currently not available".
 
Top