14
16

More than 5 years have passed since last update.

Nextcloudの管理用CLI「occ」コマンドについて

Last updated at Posted at 2019-01-03

はじめに

Nextcloudの設定画面では様々な設定を行うことができますが、設定手順の定型化、効率化にあたってはCLI(コマンドラインインターフェース)が使えると何かとはかどります。
NextcloudにはこのCLIとしてoccというものがあり、ユーザー管理、暗号化、パスワード、LDAP設定など様々なことを行うことができます。
※ownCloudを利用されたことがある方はご存知かと思いますが、あのoccと同じです。Nextcloud公式サイト上でも

Nextcloud’s occ command (origins from “ownCloud Console”)

と記載されており、元ネタがownCloudコンソールであることが明記されています。
# 「occは"occ is Nextcloud's Console"の略です」とかなら面白かったですけど。

サーバ環境について

ここで記載する実行コマンド群は次の環境で確認しております。
Nextcloudのバージョンは2019年1月2日現在で最新の15.0.0を利用します。

①【CentOS7+Apache2.4+PHP7.2】

$ cat /etc/redhat-release 
CentOS Linux release 7.6.1810 (Core) 
$ uname -a
Linux localhost.localdomain 3.10.0-957.1.3.el7.x86_64 #1 SMP Thu Nov 29 14:49:43 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
$ httpd -v
Server version: Apache/2.4.6 (CentOS)
Server built:   Nov  5 2018 01:47:09
$ php -v
PHP 7.2.12 (cli) (built: Nov 11 2018 14:54:16) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.12, Copyright (c) 1999-2018, by Zend Technologies

※Nextcloudは/var/www/html/nextcloudディレクトリにインストールされているものとします。

②【Ubuntu16(snapパッケージ版)】

$ cat /etc/os-release 
NAME="Ubuntu"
VERSION="16.04.5 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04.5 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
VERSION_CODENAME=xenial
UBUNTU_CODENAME=xenial
$ uname -a
Linux vagrant 4.4.0-131-generic #157-Ubuntu SMP Thu Jul 12 15:51:36 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

occコマンドの実行方法

occコマンドは以下のとおりで実行できます。オプションを何もつけない状態では使い方やオプション、コマンドの一覧が表示されます。

①CentOS7環境
$ sudo -u apache php /var/www/html/nextcloud/occ
②Ubuntu(snapパッケージ版)
$ sudo nextcloud.occ

「①CentOS7環境」の実行方法にphpと書かれているとおり、occコマンドはPHPのスクリプトとなっております。以下のコマンドを実行してoccファイルに実行権限を追加することで、phpなしでも実行できるようになります。

①CentOS7環境
$ sudo chmod +x /var/www/html/nextcloud/occ
$ sudo -u apache /var/www/html/nextcloud/occ

occコマンドについて

occコマンドには大きく分けて以下のコマンドがあります。occコマンドだけで結構いろいろ触れるようになっておりますが、数がとても多いので、個別の解説は別の機会に記事にしようと思います。

Nextcloud自体に対するコマンド
  check
  help
  list
  status
  upgrade
Nextcloudで動作しているアプリに対するコマンド
activity
  activity:send-mails
 app
  app:check-code
  app:disable
  app:enable
  app:getpath
  app:install
  app:list
  app:remove
  app:update
 background
  background:ajax
  background:cron
  background:webcron
 config
  config:app:delete
  config:app:get
  config:app:set
  config:import
  config:list
  config:system:delete
  config:system:get
  config:system:set
 dav
  dav:create-addressbook
  dav:create-calendar
  dav:remove-invalid-shares
  dav:sync-birthday-calendar
  dav:sync-system-addressbook
 db
  db:add-missing-indices
  db:convert-filecache-bigint
  db:convert-mysql-charset
  db:convert-type
 encryption
  encryption:change-key-storage-root
  encryption:decrypt-all
  encryption:disable
  encryption:enable
  encryption:encrypt-all
  encryption:list-modules
  encryption:set-default-module
  encryption:show-key-storage-root
  encryption:status
 federation
  federation:sync-addressbooks
 files
  files:cleanup
  files:scan
  files:scan-app-data
  files:transfer-ownership
 group
  group:add
  group:adduser
  group:delete
  group:list
  group:removeuser
 integrity
  integrity:check-app
  integrity:check-core
  integrity:sign-app
  integrity:sign-core
 l10n
  l10n:createjs
 log
  log:file
  log:manage
 maintenance
  maintenance:data-fingerprint
  maintenance:mimetype:update-db
  maintenance:mimetype:update-js
  maintenance:mode
  maintenance:repair
  maintenance:theme:update
  maintenance:update:htaccess
 migrations
  migrations:execute
  migrations:generate
  migrations:generate-from-schema
  migrations:migrate
  migrations:status
 notification
  notification:generate
 security
  security:certificates
  security:certificates:import
  security:certificates:remove
 sharing
  sharing:cleanup-remote-storages
 trashbin
  trashbin:cleanup
  trashbin:expire
 twofactorauth
  twofactorauth:cleanup
  twofactorauth:disable
  twofactorauth:enable
  twofactorauth:enforce
  twofactorauth:state
 user
  user:add
  user:delete
  user:disable
  user:enable
  user:info
  user:lastseen
  user:list
  user:report
  user:resetpassword
  user:setting
 versions
  versions:cleanup
  versions:expire

使い方の例

例1. Nextcloudのバージョン情報などを確認する。

①CentOS7環境
$ sudo -u apache php /var/www/html/nextcloud/occ status
②Ubuntu(snapパッケージ版)
$ sudo nextcloud.occ status

例2. Nextcloudの設定情報(Config)を確認する。

①CentOS7環境
$ sudo -u apache php /var/www/html/nextcloud/occ config:list
②Ubuntu(snapパッケージ版)
$ sudo nextcloud.occ config:list

例3. ユーザーID"admin"のユーザ情報を確認する。

①CentOS7環境
$ sudo -u apache php /var/www/html/nextcloud/occ user:info admin
②Ubuntu(snapパッケージ版)
$ sudo nextcloud.occ user:info admin

あとがき

occコマンドでは本当にいろいろなことができます。私自身もoccコマンドはあまりよくわかっていないので、今後勉強していきながらコマンドの詳細について少しずつ記事にしていければと思います。

★この記事は、スタイルズ社のNextcloudサイトNextcloudブログにも公開しております!

14
16
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
14
16