【ownCloud】之终极管理:OCC命令行工具

Posted by 橙叶 on Sun, Oct 2, 2016
在很早之前就知道ownCloud可以在命令行界面通过OCC命令进行管理,怎奈OCC文档写得相当晦涩,今天自己研究了下,终于会用了,分享出来。

一、简介

ownCloud的OCC(ownCloud Console)命令行工具,能够快捷有效地管理ownCloud服务器,可以执行诸如安装、升级、加密、增删用户、LDAP设置等工作。

你需要用网页服务器的用户登录,比如你用的是Apache做网页服务器

  • Debian/Ubuntu 里的用户是 www-data
  • Fedora/CentOS 里的用户是 apache
  • Arch Linux 里的用户是 http
  • openSUSE 里的用户是wwwrun, 组是 www

二、准备使用

切换用户:
#su 用户名

比如

# su apache

如果切换用户时出现This account is currently not available的提示。

 

2016-10-02-2

解决办法:

# vi /etc/passwd
2016-10-02-3

找到开头是apache的一行,将后面的/var/www:/sbin/nologin改为/var/www:/bin/bash

2016-10-02-4

ESC

:wq 保存退出


# su apache

其他系统的网站服务器用户在上面

现在,cd到你的owncloud安装目录下


$ cd /你的owncloud安装目录/

$ ls

./ 3rdparty/ config/ data/ l10n/ ocs-provider/ robots.txt updater/
../ AUTHORS console.php db_structure.xml lib/ public.php settings/ version.php
.htaccess COPYING-AGPL core/ index.html <span style="text-decoration: underline;">occ</span>* remote.php status.php
.user.ini apps/ cron.php index.php ocs/ resources/ themes/

看到名为occ的那个文件了没?今天的主角就是它。

三、使用OCC命令

OCC文件使用php编译,所以我们用php命令来执行这个脚本(请保持工作目录一直与occ文件位于同一目录)

$ php occ

ownCloud version 9.1.1

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.
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:list List all available 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
·
·
·
·
·
·
会显示好多提示,就不全部复制了

如果效果和上面的一样,那么你就成功了

比如我要添加一个owncloud用户“test”:

$ php occ user:add test

$ php occ user:add test
       Enter password:
       Confirm password:
       The user "test" was created successfull

 

Look,用户已经添加好了

2016-10-02-6

还有很多命令可以用········

 

ownCloud升级更简单了:


$ php occ upgrade

 

插件的相关命令

$ php occ app:check-code */检查代码
$ php occ app:disable +插件名 */禁用一个插件
$ php occ app:enable  +插件名 */激活一个插件 
$ php occ app:getpath +插件名 */获取插件目录
$ php occ app:list */列出所有插件(可以用这个命令查看插件名)

 

还有好多~

occ-command
如果你有任何问题,欢迎交流!

百度贴吧ID:科尔森的发际线

转载请注明来源



comments powered by Disqus