※2019/2/18 一部記載を修正しました。
はじめに
NextcloudにはCLI環境としてocc
というものがあり、さまざまな設定、管理を行うことができます。
ここでは occ で使える様々なコマンド群のうち、Nextcloud自体に対するコマンド群についてまとめてみます。
環境について
ここで記載するoccを実行するNextcloudのバージョンは、2019年2月18日現在で最新の15.0.4
を利用します。
Nextcloud自体に対するコマンド群
Nextcloud自体に対するコマンドには以下のようなものがあります。
- help
- list
- status
- check
- upgrade
help
occ の使い方のヘルプを確認できます。
$ sudo -u apache 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.
list
occ で利用できるコマンドの一覧が表示できます。
おまけとして、最初の行に現在インストールされているNextcloudのバージョンも確認できます。
$ 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
list コマンドでは --format
オプションで表示形式が選択できます。表示形式は以下から選択できます。
- txt (デフォルトの表示形式)
- xml (XML形式)
- json (JSON形式)
- md (Markdown形式)
$ sudo -u apache php /var/www/html/nextcloud/occ list --format=json
{"application":{"name":"Nextcloud","version":"15.0.4"},"commands":[{"name":"_completion","usage":["_completion [-g|--generate-hook] [-p|--program PROGRAM] [-m|--multiple] [--shell-type [SHELL-TYPE]]"],・・・
Markdown形式(オプション=md)の出力は、各コマンドのオプションの解説が細かく出力されるので、出力内容をMarkdownエディタとかビューワに読み込ませればこれだけでocc CLIドキュメントができたりします f(^^;
status
Nextcloudのインストール状態、バージョンなどを確認することができます。
$ sudo -u apache php /var/www/html/nextcloud/occ status
- installed: true
- version: 15.0.4.0
- versionstring: 15.0.4
- edition:
status コマンドでは --output
オプションで表示形式が選択できます。表示形式は以下から選択できます。
- plain (デフォルトの表示形式)
- json (JSON形式)
- json_pretty (成形されたJSON形式)
$ sudo -u apache php /var/www/html/nextcloud/occ status --output=json_pretty
{
"installed": true,
"version": "15.0.4.0",
"versionstring": "15.0.4",
"edition": ""
}
check
サーバー環境の依存関係を確認をします。Nextcloudのインストール作業を行った後、様々なミドルウェアの設定がNextcloudを動作させるための正しい設定になっているかが確認できます。
$ sudo -u apache php /var/www/html/nextcloud/occ check
何も問題なければ、メッセージは表示されずにコマンドプロンプトに戻ります。
upgrade
Nextcloudのバージョンアップを行った後にデータベースの変更など必要なアップグレード処理を完了させるために使用します。
Nextcloudはバージョンアップを行った後は原則的にダウングレードはできませんので注意してください。
★この記事は、スタイルズ社のNextcloudサイト の Nextcloudブログにも公開しております!