CMS Shell

From OpenCms Wiki
Revision as of 12:50, 19 May 2008 by Snatcho (Talk | contribs)
Jump to: navigation, search

Contents

What is it for? Purpose.

Shell script for Linux/Windows to start a shell prompt which gives you access to OpenCms.

This allows to perform a certain group of operations without logging into the OpenCms Workplace, useful for damaged workplaces or administrative tasks to be perfomed automatically through shell scripts.

Some possible actions are

  • creating folders
  • creating groups and users
  • exporting/importing resources or modules
  • purging jsp cache repository
  • rebuilding indexes

Linux

Under Linux I used the following commands to run the shell:

"cd" to the WEB-INF folder of the OpenCms web application. In that folder you will see the cmsshell.sh. "chmod 755" it if it's not an executable. Then copy the "servlet-api.jar" and "jsp-api.jar" to the "./lib/" folder. Using the following command you should now be able to start the shell.

Invalid language.

You need to specify a language like this: <source lang="html">...</source>

Supported languages for syntax highlighting:

actionscript, ada, apache, applescript, asm, asp, autoit, bash, blitzbasic, bnf, c, c_mac, caddcl, cadlisp, cfdg, cfm, cpp, cpp-qt, csharp, css, d, delphi, diff, div, dos, eiffel, fortran, freebasic, gml, groovy, html4strict, idl, ini, inno, io, java, java5, javascript, latex, lisp, lua, matlab, mirc, mpasm, mysql, nsis, objc, ocaml, ocaml-brief, oobas, oracle8, pascal, perl, php, php-brief, plsql, python, qbasic, reg, robots, ruby, sas, scheme, sdlbasic, smalltalk, smarty, sql, tcl, text, thinbasic, tsql, vb, vbnet, vhdl, visualfoxpro, winbatch, xml, z80

Note: I had trouble getting the -classpath to work with my JDK 1.6, so I used the "-Djava.ext.dirs=" instead. That's why I copy the two jars above into that folder. If someone has a method that works better please post the update here.

Windows

Under Windows, use the following simple steps:

  1. Change you current path to the WEB-INF folder of your OpenCms installation
  2. Run cmsshell.bat from the command line

I have had no trouble accesing the shell running these commands, if you find problems check the preceding section for possible .jar issues.

What do you get? Usage.

Once the shell is correctly run, you get something like

Invalid language.

You need to specify a language like this: <source lang="html">...</source>

Supported languages for syntax highlighting:

actionscript, ada, apache, applescript, asm, asp, autoit, bash, blitzbasic, bnf, c, c_mac, caddcl, cadlisp, cfdg, cfm, cpp, cpp-qt, csharp, css, d, delphi, diff, div, dos, eiffel, fortran, freebasic, gml, groovy, html4strict, idl, ini, inno, io, java, java5, javascript, latex, lisp, lua, matlab, mirc, mpasm, mysql, nsis, objc, ocaml, ocaml-brief, oobas, oracle8, pascal, perl, php, php-brief, plsql, python, qbasic, reg, robots, ruby, sas, scheme, sdlbasic, smalltalk, smarty, sql, tcl, text, thinbasic, tsql, vb, vbnet, vhdl, visualfoxpro, winbatch, xml, z80

, that is, the command line for the shell. This means you are not authenticated and therefore at project Online with Guest user (you can authenticate to get administrative credentials as requiered for certaing tasks with the "login" command.)

The basic commands are displayed when you start the shell, being:

  • help - Displays this brief abstract of possible commands
  • help * - Shows the signature of all available methods
  • help {string} - Shows the signature of all methods containing this string
  • exit or quit - Leaves the OpenCms Shell

Available commands

Under the shell you can execute commands like the following:

Invalid language.

You need to specify a language like this: <source lang="html">...</source>

Supported languages for syntax highlighting:

actionscript, ada, apache, applescript, asm, asp, autoit, bash, blitzbasic, bnf, c, c_mac, caddcl, cadlisp, cfdg, cfm, cpp, cpp-qt, csharp, css, d, delphi, diff, div, dos, eiffel, fortran, freebasic, gml, groovy, html4strict, idl, ini, inno, io, java, java5, javascript, latex, lisp, lua, matlab, mirc, mpasm, mysql, nsis, objc, ocaml, ocaml-brief, oobas, oracle8, pascal, perl, php, php-brief, plsql, python, qbasic, reg, robots, ruby, sas, scheme, sdlbasic, smalltalk, smarty, sql, tcl, text, thinbasic, tsql, vb, vbnet, vhdl, visualfoxpro, winbatch, xml, z80

These are two samples of the long list of possible commands. The available commands are public methods in the classes:

  • org.opencms.main.CmsShellCommands
  • org.opencms.file.CmsRequestContext
  • org.opencms.file.CmsObject

For obvious reasons only certain parameter types can be used in a command line, so only public methods in the mentioned classes that use supported data types can be called. Supported data types are:

  • String
  • CmsUUID
  • boolean
  • int
  • long
  • double
  • float

To know more about a certain method you should look at your version's OpenCms Javadoc (at OpenCms's Official Javadoc or even more complete at JavaDoc APIs provided by Synyx GmbH & Co. KG) (by the way I do not work for Synyx nor do I have any hidden interest in this company, it's just the best OpenCms Javadoc reference I know and that I use all the time - they have the 'Use' link active on top of each class and for me that makes a big deal of difference).

Complete method list

A complete availabe methods list as provided with command help * is (OpenCms 6.2.3):

Available methods in org.opencms.main.CmsShellCommands:

  • addWebUser(String, String, String, String)
  • cd(String)
  • chacc(String, String, String, String)
  • clearCaches()
  • copyright()
  • createDefaultProject(String, String)
  • createFolder(String, String)
  • createGroup(String, String)
  • createPropertydefinition(String)
  • createUser(String, String, String)
  • createUser(String, String, String, String, String, String)
  • deleteBackups(int)
  • deleteModule(String)
  • deleteProject(String)
  • deletepropertydefinition(String)
  • echo(String)
  • exit()
  • exportAllResources(String)
  • exportModule(String)
  • exportResources(String, String)
  • exportResourcesAndUserdata(String, String)
  • getAcl(String)
  • getLocales()
  • help()
  • help(String)
  • importModule(String)
  • importModuleFromDefault(String)
  • importModulesFromSetupBean()
  • importResources(String, String)
  • importResourcesWithTempProject(String)
  • listModules()
  • login(String, String)
  • ls()
  • lsacc(String)
  • lsacc(String, String)
  • perf()
  • prompt(String)
  • purgeJspRepository()
  • pwd()
  • quit()
  • readFileContent(String)
  • readGroupOfProject(int)
  • readManagerGroup(int)
  • readOwnerOfProject(int)
  • rebuildAllIndexes()
  • rebuildIndex(String)
  • replaceModule(String, String)
  • replaceModuleFromDefault(String, String)
  • setCurrentProject(int)
  • setCurrentProject(String)
  • setLocale(String)
  • shellExit()
  • shellStart()
  • unlockCurrentProject()
  • uploadFile(String, String, String, String)
  • version()
  • whoami()

Available methods in org.opencms.file.CmsRequestContext:

  • addSiteRoot(String)
  • addSiteRoot(String, String)
  • currentProject()
  • currentUser()
  • getAdjustedSiteRoot(String)
  • getAttribute(String)
  • getDirectoryTranslator()
  • getEncoding()
  • getFileTranslator()
  • getFolderUri()
  • getLocale()
  • getRemoteAddress()
  • getRequestTime()
  • getSiteRoot()
  • getUri()
  • isUpdateSessionEnabled()
  • removeSiteRoot(String)
  • restoreSiteRoot()
  • saveSiteRoot()
  • setEncoding(String)
  • setRequestTime(long)
  • setSiteRoot(String)
  • setUpdateSessionEnabled(boolean)
  • setUri(String)

Available methods in org.opencms.file.CmsObject:

  • addUserToGroup(String, String)
  • backupProject(int, long)
  • chacc(String, String, String, String)
  • chacc(String, String, String, int, int, int)
  • changeLastModifiedProjectId(String)
  • changeLock(String)
  • changeResourcesInFolderWithProperty(String, String, String, St
  • changeUserType(String, int)
  • changeUserType(CmsUUID, int)
  • chflags(String, int)
  • chtype(String, int)
  • copyResource(String, String)
  • copyResource(String, String, int)
  • copyResourceToProject(String)
  • countLockedResources(String)
  • countLockedResources(int)
  • cpacc(String, String)
  • createGroup(String, String, int, String)
  • createProject(String, String, String, String)
  • createProject(String, String, String, String, int)
  • createPropertyDefinition(String)
  • createResource(String, int)
  • createTempfileProject()
  • deleteAllStaticExportPublishedResources(int)
  • deleteGroup(String)
  • deleteGroup(CmsUUID, CmsUUID)
  • deleteProject(int)
  • deleteProperty(String, String)
  • deletePropertyDefinition(String)
  • deleteResource(String, int)
  • deleteStaticExportPublishedResource(String, int, String)
  • deleteUser(CmsUUID)
  • deleteUser(String)
  • deleteUser(CmsUUID, CmsUUID)
  • deleteWebUser(CmsUUID)
  • existsResource(String)
  • getAccessControlEntries(String)
  • getAccessControlEntries(String, boolean)
  • getAccessControlList(String)
  • getAccessControlList(String, boolean)
  • getAllAccessibleProjects()
  • getAllBackupProjects()
  • getAllManageableProjects()
  • getBackupTagId()
  • getChild(String)
  • getChilds(String)
  • getConfigurations()
  • getDirectGroupsOfUser(String)
  • getFilesInFolder(String)
  • getGroups()
  • getGroupsOfUser(String)
  • getGroupsOfUser(String, String)
  • getLock(String)
  • getLostAndFoundName(String)
  • getParent(String)
  • getPermissions(String)
  • getPermissions(String, String)
  • getPublishList()
  • getRequestContext()
  • getResourcesInTimeRange(String, long, long)
  • getSubFolders(String)
  • getTaskService()
  • getUsers()
  • getUsers(int)
  • getUsersOfGroup(String)
  • hasPublishPermissions(String)
  • isAdmin()
  • isInsideCurrentProject(String)
  • isManagerOfProject()
  • lockResource(String)
  • lockResource(String, int)
  • loginUser(String, String)
  • loginUser(String, String, String)
  • loginUser(String, String, String, int)
  • loginWebUser(String, String)
  • lookupPrincipal(String)
  • lookupPrincipal(CmsUUID)
  • moveResource(String, String)
  • moveToLostAndFound(String)
  • publishProject()
  • publishResource(String)
  • readAllBackupFileHeaders(String)
  • readAllPropertyDefinitions()
  • readAncestor(String, int)
  • readBackupFile(String, int)
  • readBackupProject(int)
  • readFile(String)
  • readFileHeader(String)
  • readFolder(String)
  • readGroup(CmsUUID)
  • readGroup(String)
  • readProject(String)
  • readProject(int)
  • readProjectView(int, int)
  • readProperties(String)
  • readProperties(String, boolean)
  • readProperty(String, String)
  • readProperty(String, String, boolean)
  • readProperty(String, String, boolean, String)
  • readPropertyDefinition(String)
  • readPropertyObject(String, String, boolean)
  • readPropertyObjects(String, boolean)
  • readPublishedResources(CmsUUID)
  • readResource(String)
  • readResourcesWithProperty(String)
  • readResourcesWithProperty(String, String)
  • readResourcesWithProperty(String, String, String)
  • readStaticExportPublishedResourceParameters(String)
  • readStaticExportResources(int, long)
  • readUser(String)
  • readUser(CmsUUID)
  • readUser(String, String)
  • readUser(String, int)
  • readWebUser(String)
  • readWebUser(String, String)
  • removeResourceFromProject(String)
  • removeUserFromGroup(String, String)
  • renameResource(String, String)
  • restoreResourceBackup(String, int)
  • rmacc(String, String, String)
  • setDateExpired(String, long, boolean)
  • setDateLastModified(String, long, boolean)
  • setDateReleased(String, long, boolean)
  • setParentGroup(String, String)
  • setPassword(String, String)
  • setPassword(String, String, String)
  • touch(String, long, long, long, boolean)
  • undeleteResource(String)
  • undoChanges(String, boolean)
  • unlockProject(int)
  • unlockResource(String)
  • userInGroup(String, String)
  • validatePassword(String)
  • writeProperty(String, String, String)
  • writeProperty(String, String, String, boolean)
  • writeStaticExportPublishedResource(String, int, String, long)
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox