はじめに
NextcloudにはCLI環境としてoccというものがあり、さまざまな設定、管理を行うことができます。 ここでは occ で使える様々なコマンド群のうち、Nextcloud自体に対するコマンド群と、あわせて各コマンド共通で使うことができるオプション設定についてまとめてみます。
※occ の使い方については、【techblog】 Nextcloudの管理用CLI「occ」コマンドについて の記事を参照ください。
環境について
ここで記載するoccを実行するNextcloudのバージョンは、2019年2月18日現在で最新の15.0.4を利用します。
Nextcloud自体に対するコマンド群
Nextcloud自体に対するコマンドには以下のようなものがあります。
-
help
-
list
-
status
- check
-
upgrade
help
"help"コマンドは、コマンドに対するヘルプを表示します。
$ sudo -u nginx php /var/www/html/nextcloud/occ help Usage: help [options] [--] [<command_name>] Arguments: command The command to execute command_name The command name [default: "help"] Options: --format=FORMAT The output format (txt, xml, json, or md) [default: "txt"] --raw To output raw command help -h, --help Display this help message -q, --quiet Do not output any message -V, --version Display this application version --ansi Force ANSI output --no-ansi Disable ANSI output -n, --no-interaction Do not ask any interactive question --no-warnings Skip global warnings, show command output only -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug Help: The help command displays help for a given command: php /var/www/html/nextcloud/occ help list You can also output the help in other formats by using the --format option: php /var/www/html/nextcloud/occ help --format=xml list To display the list of available commands, please use the list command.
"--format"オプションを使うことによりさまざまなフォーマットで表示することができます。指定できるフォーマットは次のとおりです。
- txt (テキスト形式: デフォルト)
- xml (XML形式)
- json (JSON形式)
- md (Markdown形式)
"--raw"オプションを指定すると、加工されないコマンドのヘルプを出力します。
occ で使えるコマンドのリストを表示したい場合は"list"コマンドを使ってください。
■実行例① listコマンドのヘルプを表示
$ sudo -u nginx php /var/www/html/nextcloud/occ help list
Usage:
list [options] [--] [<namespace>]
Arguments:
namespace The namespace name
Options:
--raw To output raw command list
--format=FORMAT The output format (txt, xml, json, or md) [default: "txt"]
Help:
The list command lists all commands:
php /var/www/html/nextcloud/occ list
You can also display the commands for a specific namespace:
php /var/www/html/nextcloud/occ list test
You can also output the information in other formats by using the --format option:
php /var/www/html/nextcloud/occ list --format=xml
It's also possible to get raw list of commands (useful for embedding command runner):
php /var/www/html/nextcloud/occ list --raw
■実行例② XML形式でlistコマンドのヘルプを表示
$ sudo -u nginx php /var/www/html/nextcloud/occ help --format=xml list <?xml version="1.0" encoding="UTF-8"?> <command id="list" name="list" hidden="0"> <usages> <usage>list [--raw] [--format FORMAT] [--] [<namespace>]</usage> </usages> <description>Lists commands</description> <help>The <info>list</info> command lists all commands: <info>php /var/www/html/nextcloud/occ list</info> You can also display the commands for a specific namespace: <info>php /var/www/html/nextcloud/occ list test</info> You can also output the information in other formats by using the <comment>--format</comment> option: <info>php /var/www/html/nextcloud/occ list --format=xml</info> It's also possible to get raw list of commands (useful for embedding command runner): <info>php /var/www/html/nextcloud/occ list --raw</info></help> <arguments> <argument name="namespace" is_required="0" is_array="0"> <description>The namespace name</description> <defaults/> </argument> </arguments> <options> <option name="--raw" shortcut="" accept_value="0" is_value_required="0" is_multiple="0"> <description>To output raw command list</description> </option> <option name="--format" shortcut="" accept_value="1" is_value_required="1" is_multiple="0"> <description>The output format (txt, xml, json, or md)</description> <defaults> <default>txt</default> </defaults> </option> </options> </command>
■実行例③ JSON形式でlistコマンドのヘルプを表示
$ sudo -u nginx php /var/www/html/nextcloud/occ help --format=json list
{"name":"list","usage":["list [--raw] [--format FORMAT] [--] []"],"description":"Lists commands","help":"The list<\/info> command lists all commands:\n\n php \/var\/www\/html\/nextcloud\/occ list<\/info>\n\nYou can also display the commands for a specific namespace:\n\n php \/var\/www\/html\/nextcloud\/occ list test<\/info>\n\nYou can also output the information in other formats by using the --format<\/comment> option:\n\n php \/var\/www\/html\/nextcloud\/occ list --format=xml<\/info>\n\nIt's also possible to get raw list of commands (useful for embedding command runner):\n\n php \/var\/www\/html\/nextcloud\/occ list --raw<\/info>","definition":{"arguments":{"namespace":{"name":"namespace","is_required":false,"is_array":false,"description":"The namespace name","default":null}},"options":{"raw":{"name":"--raw","shortcut":"","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"To output raw command list","default":false},"format":{"name":"--format","shortcut":"","accept_value":true,"is_value_required":true,"is_multiple":false,"description":"The output format (txt, xml, json, or md)","default":"txt"}}},"hidden":false}
■実行例④ Markdown形式でlistコマンドのヘルプを表示
$ sudo -u nginx php /var/www/html/nextcloud/occ help --format=md list `list` ------ Lists commands ### Usage * `list [--raw] [--format FORMAT] [--] [<namespace>]` The list command lists all commands: php /var/www/html/nextcloud/occ list You can also display the commands for a specific namespace: php /var/www/html/nextcloud/occ list test You can also output the information in other formats by using the --format option: php /var/www/html/nextcloud/occ list --format=xml It's also possible to get raw list of commands (useful for embedding command runner): php /var/www/html/nextcloud/occ list --raw ### Arguments #### `namespace` The namespace name * Is required: no * Is array: no * Default: `NULL` ### Options #### `--raw` To output raw command list * Accept value: no * Is value required: no * Is multiple: no * Default: `false` #### `--format` The output format (txt, xml, json, or md) * Accept value: yes * Is value required: yes * Is multiple: no * Default: `'txt'`
list
occ で利用できるコマンドの一覧が表示できます。
$ sudo -u apache php /var/www/html/nextcloud/occ list
Nextcloud 15.0.4
Usage:
command [options] [arguments]
Options:
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
--no-warnings Skip global warnings, show command output only
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Available commands:
check check dependencies of the server environment
help Displays help for a command
list Lists commands
status show some status information
upgrade run upgrade routines after installation of a new release. The release has to be installed before.
activity
activity:send-mails Sends the activity notification mails
app
app:check-code check code to be compliant
app:disable disable an app
app:enable enable an app
app:getpath Get an absolute path to the app directory
app:install install an app
app:list List all available apps
app:remove remove an app
app:update update an app or all apps
background
background:ajax Use ajax to run background jobs
background:cron Use cron to run background jobs
background:webcron Use webcron to run background jobs
config
config:app:delete Delete an app config value
config:app:get Get an app config value
config:app:set Set an app config value
config:import Import a list of configs
config:list List all configs
config:system:delete Delete a system config value
config:system:get Get a system config value
config:system:set Set a system config value
dav
dav:create-addressbook Create a dav addressbook
dav:create-calendar Create a dav calendar
dav:remove-invalid-shares Remove invalid dav shares
dav:sync-birthday-calendar Synchronizes the birthday calendar
dav:sync-system-addressbook Synchronizes users to the system addressbook
db
db:add-missing-indices Add missing indices to the database tables
db:convert-filecache-bigint Convert the ID columns of the filecache to BigInt
db:convert-mysql-charset Convert charset of MySQL/MariaDB to use utf8mb4
db:convert-type Convert the Nextcloud database to the newly configured one
encryption
encryption:change-key-storage-root Change key storage root
encryption:decrypt-all Disable server-side encryption and decrypt all files
encryption:disable Disable encryption
encryption:enable Enable encryption
encryption:encrypt-all Encrypt all files for all users
encryption:list-modules List all available encryption modules
encryption:set-default-module Set the encryption default module
encryption:show-key-storage-root Show current key storage root
encryption:status Lists the current status of encryption
federation
federation:sync-addressbooks Synchronizes addressbooks of all federated clouds
files
files:cleanup cleanup filecache
files:scan rescan filesystem
files:scan-app-data rescan the AppData folder
files:transfer-ownership All files and folders are moved to another user - shares are moved as well.
group
group:add Add a group
group:adduser add a user to a group
group:delete Remove a group
group:list list configured groups
group:removeuser remove a user from a group
integrity
integrity:check-app Check integrity of an app using a signature.
integrity:check-core Check integrity of core code using a signature.
integrity:sign-app Signs an app using a private key.
integrity:sign-core Sign core using a private key.
l10n
l10n:createjs Create javascript translation files for a given app
log
log:file manipulate logging backend
log:manage manage logging configuration
maintenance
maintenance:data-fingerprint update the systems data-fingerprint after a backup is restored
maintenance:mimetype:update-db Update database mimetypes and update filecache
maintenance:mimetype:update-js Update mimetypelist.js
maintenance:mode set maintenance mode
maintenance:repair repair this installation
maintenance:theme:update Apply custom theme changes
maintenance:update:htaccess Updates the .htaccess file
migrations
migrations:execute Execute a single migration version manually.
migrations:generate
migrations:generate-from-schema
migrations:migrate Execute a migration to a specified version or the latest available version.
migrations:status View the status of a set of migrations.
notification
notification:generate Generate a notification for the given user
security
security:certificates list trusted certificates
security:certificates:import import trusted certificate
security:certificates:remove remove trusted certificate
sharing
sharing:cleanup-remote-storages Cleanup shared storage entries that have no matching entry in the shares_external table
trashbin
trashbin:cleanup Remove deleted files
trashbin:expire Expires the users trashbin
twofactorauth
twofactorauth:cleanup Clean up the two-factor user-provider association of an uninstalled/removed provider
twofactorauth:disable Disable two-factor authentication for a user
twofactorauth:enable Enable two-factor authentication for a user
twofactorauth:enforce Enabled/disable enforced two-factor authentication
twofactorauth:state Get the two-factor authentication (2FA) state of a user
update
update:check Check for server and app updates
user
user:add adds a user
user:delete deletes the specified user
user:disable disables the specified user
user:enable enables the specified user
user:info show user info
user:lastseen shows when the user was logged in last time
user:list list configured users
user:report shows how many users have access
user:resetpassword Resets the password of the named user
user:setting Read and modify user settings
versions
versions:cleanup Delete versions
versions:expire Expires the users file versions
特定のネームスペース(上記実行例の”activity”, “app”, ・・・)を指定することでこのネームスペースに属しているコマンドを表示することができます。
"--format"オプションを使うことによりさまざまなフォーマットで表示することができます。指定できるフォーマットは次のとおりです。
- txt (テキスト形式: デフォルト)
- xml (XML形式)
- json (JSON形式)
- md (Markdown形式)
"--raw"オプションを指定すると、加工されないコマンドのヘルプを出力します。
■実行例① ネームスペース”app”に属するコマンドの一覧を表示
$ sudo -u nginx php /var/www/html/nextcloud/occ list app
Nextcloud 15.0.4
Usage:
command [options] [arguments]
Options:
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
--no-warnings Skip global warnings, show command output only
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Available commands for the "app" namespace:
app:check-code check code to be compliant
app:disable disable an app
app:enable enable an app
app:getpath Get an absolute path to the app directory
app:install install an app
app:list List all available apps
app:remove remove an app
app:update update an app or all apps
status
"status"コマンドは、Nextcloudのステータス情報を出力します。
$ sudo -u nginx php /var/www/html/nextcloud/occ status - installed: true - version: 15.0.4.0 - versionstring: 15.0.4 - edition:
"--output"オプションを利用すると出力フォーマットを指定することができます。指定できるフォーマットは次のとおりです。
- plain (テキスト形式: デフォルト)
- json (JSON形式)
- json_pretty (整形されたJSON形式)
■実行例① 整形されたJSON形式でNextcloudのステータス情報を出力
$ sudo -u nginx php /var/www/html/nextcloud/occ status --output=json_pretty
{
"installed": true,
"version": "15.0.4.0",
"versionstring": "15.0.4",
"edition": ""
}
check
サーバー環境の依存関係を調べます。依存関係に問題がなければ何も出力はされません。
$ sudo -u apache php /var/www/html/nextcloud/occ check
"--output"オプションを利用すると出力フォーマットを指定することができます。指定できるフォーマットは次のとおりです。
- plain (テキスト形式: デフォルト)
- json (JSON形式)
- json_pretty (整形されたJSON形式)
upgrade
新たにリリースされたNextcoudのバージョンアップグレードルーティンを実行します。リリースされたNextcloudアプリケーション群はあらかじめインストールしておくことが必要です。
$ sudo -u nginx php /var/www/html/nextcloud/occ upgrade Nextcloud is already latest version
Nextcloudのアップグレードが完了している場合は上記のような表示となります。
Nextcloudをアップグレードすると以前のバージョンに戻すことはできませんので、実施する際は細心の注意をして実施をしてください。
コマンド共通で使用できるオプション群
occ の各コマンド共通で使用できるオプション群は次のとおりとなります。
-h, --help
コマンドに対するヘルプを表示します。
-q, --quiet
実行結果を何も表示しません。
-V, --version
このアプリケーションのバージョンを表示します。
--ansi
強制的にANSI出力(=色付きの表示)とします(デフォルト)。
--no-ansi
ANSI出力を無効にします。
-n, --no-interaction
対話型の質問(◯◯していいですか?(Y/N)的なもの)を行いません。
--no-warnings
全体的な警告を表示せずコマンド出力結果のみを表示します。
-v, --verbose / -vv / -vvv
より詳細なメッセージを表示します。
- -v, –verbose: 通常出力(デフォルト)
- -vv: より詳細な出力
- -vvv: デバッグ出力
