Using Nextcloud apps with the occ command on FreeBSD

Nextcloud is the best cloud solution and worth trying. You can use Nextcloud to store data and documents that you don't want to share with third-party services. Nextcloud is quite easy to install on commonly used hardware, such as computers, cellphones or others and also on services hosted in the cloud. Nextcloud is the ideal solution for individuals or your growing business.

Most of the people install and run Nextcloud with GUI, which makes it easier to use and user friendly. However, there are times when you may not be able to access the GUI or there are special tasks that can only be completed with the command line. Using this command line will make it easier for users to run Nextcloud.

Since Nextcloud originates from ownCloud, ownCloud Console tools like occ are also available in Nextcloud. The occ utility is a Nextcloud command line interface that allows admins to manage things like upgrading Nextcloud, managing users, LDAP settings, encryption, passwords, two-factor authentication, disabling apps, and many more benefits of occ.

On FreeBSD occ is in the /usr/local/www/nextcloud directory. Occ is a PHP script wrapped into Nextcloud, when you want to use occ you must run it as an HTTP user to ensure that the correct permissions are maintained on your Nextcloud files and directories.

The occ command is a PHP script from OwnCloud that is used to make it easier for you to set up and run Nextcloud

1. How to use the occ command

The occ command can only be executed by users who have installed Nextcloud on their computer or cloud hosting. for example on FreeBSD servers, Ubuntu, MacOS and others. Most people configure Nextcloud using the Web interface, which is not only easy but also not tedious. But you can also update and configure Nextcloud with the occ command line. In this article, we will learn the general use of occ to run and manage Nextcloud on a FreeBSD server.

a. Check Status

In the first part, we will check the Nextcloud server status.

Check Status
root@ns3:/usr/local/www/nextcloud # occ status
  - installed: true
  - version:
  - versionstring: 28.0.3
  - edition:
  - maintenance: false
  - needsDbUpgrade: false
  - productname: Nextcloud
  - extendedSupport: false

b. Reset Password Nextcloud

You can reset your Nextcloud password with the occ command.

Check Status
root@ns3:/usr/local/www/nextcloud # occ user:resetpassword datainchi
Enter a new password: router_12345
Confirm the new password: router_12345
Successfully reset password for datainchi
In the command above, datainchi is the Nextcloud username, and the new password is router_12345.

c. Scan Files

With the occ command, you can also scan files.

Scan Files
root@ns3:/usr/local/www/nextcloud # occ files:scan -v --all
root@ns3:/usr/local/www/nextcloud # occ files:scan -v datainchi

d. Upgrade Nextcloud

For those who are used to the command line, the Nextcloud upgrade process is easier, because it doesn't require as many clicks as in the GUI.

root@ns3:/usr/local/www/nextcloud # occ update:check
root@ns3:/usr/local/www/nextcloud # occ upgrade

e. Turn maintenance mode

In this process there are only two options, namely off or on.

Maintenance mode
root@ns3:/usr/local/www/nextcloud # occ maintenance:mode --on
root@ns3:/usr/local/www/nextcloud # occ maintenance:mode --off

f. Add missing indices

Add missing indices
root@ns3:/usr/local/www/nextcloud # occ db:add-missing-indices

g. Convert to bigint

Convert to bigint
root@ns3:/usr/local/www/nextcloud # occ db:convert-filecache-bigint
All tables already up to date!

h. Fix interupted upgrades

Fix interupted upgrades
root@ns3:/usr/local/www/nextcloud # occ maintenance:repair

2. Install apps from the Command Line

There are lots of Apps you can install on Nextcloud, most people use the standalone installer via the GUI, you can also use the occ command line to download and install apps on your Nextcloud server.

Occ is a powerful utility that makes it easy for you to find, download, install, update, and even remove applications on your Nextcloud installation with just a few command lines, reducing the number of steps required using GUI methods.

a. Displaying Applications

Before you install the App, first check what is installed on Nextcloud. The command below will display a list of all enabled and disabled applications on your Nextcloud server.

List current apps
root@ns3:/usr/local/www/nextcloud # occ app:list
  - activity: 2.20.0
  - circles: 28.0.0-dev
  - cloud_federation_api: 1.11.0
  - comments: 1.18.0
  - contactsinteraction: 1.9.0
  - dashboard: 7.8.0
  - lookup_server_connector: 1.16.0 
  - serverinfo: 1.18.0
  - settings: 1.10.1 
  - text: 3.9.1
  - admin_audit: 1.18.0
  - bruteforcesettings: 2.8.0
  - encryption: 2.16.0
  - files_external: 1.20.0
  - suspicious_login: 6.0.0
  - twofactor_totp: 10.0.0-beta.2
  - user_ldap: 1.19.0

b. Install New Apps

In this section, we will use the calendar and contacts applications as learning examples. To install it, run the following occ command.

Install contacts & calendar
root@ns3:/usr/local/www/nextcloud # occ app:install contacts
root@ns3:/usr/local/www/nextcloud # occ app:install calendar

c. Enable Apps

Contact and calendar applications that you install, cannot be used if you have not activated the application. Run the following command to activate the application on Nextcloud.

Enable contacts & calendar
root@ns3:/usr/local/www/nextcloud # occ app:enable contacts
contacts already enabled
root@ns3:/usr/local/www/nextcloud # occ app:enable calendar
calendar already enabled

d. Disable Apps

You can turn off every application on Nextcloud, so you cannot use the application. Use the command below to disable the app.

Disable contacts & calendar
root@ns3:/usr/local/www/nextcloud # occ app:disable contacts
contacts 5.5.3 disabled
root@ns3:/usr/local/www/nextcloud # occ app:disable calendar
calendar 4.6.6 disabled

e. Remove Apps

You can delete each application you installed if you no longer need it. If you want to delete an application, disable it and then run the rm -rf command.

Remove contacts & calendar
root@ns3:/usr/local/www/nextcloud # occ app:disable contacts
root@ns3:/usr/local/www/nextcloud # occ app:disable calendar
root@ns3:/usr/local/www/nextcloud # rm -rf apps/contacts
root@ns3:/usr/local/www/nextcloud # rm -rf apps/calendar

f. Update Apps

It is certain, every year the Nextcloud application has a new version, you can update it with the OCC command line.

Update contacts & calendar
root@ns3:/usr/local/www/nextcloud # occ app:update contacts
root@ns3:/usr/local/www/nextcloud # occ app:update calendar
If you want to update all applications on Nextcloud, run the following command.

Update All Apps
root@ns3:/usr/local/www/nextcloud # occ app:update --all

g. Integrity Check

Apps which have an official tag MUST be code signed with Nextcloud. Unsigned official apps won’t be installable anymore. 

Integrity Check
root@ns3:/usr/local/www/nextcloud # occ integrity:check-app --path=/usr/local/www/nextcloud/apps contacts
root@ns3:/usr/local/www/nextcloud # occ integrity:check-app --path=/usr/local/www/nextcloud/apps calendar
As we mentioned before, there are many more occ commands that you can use and the ones I have selected are just a glance, especially those related to how to manage applications on Nextcloud. But I hope this article can help you understand and use the occ command in FreeBSD.
Iwan Setiawan

I Like Adventure: Mahameru Mount, Rinjani Mount I Like Writer FreeBSD

Post a Comment

Previous Post Next Post