CMS Shell
From OpenCms Wiki
Contents |
[edit] 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
[edit] 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.
java -Djava.ext.dirs=./lib/ org.opencms.main.CmsShellNote: 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.
[edit] Windows
Under Windows, use the following simple steps:
- Change you current path to the WEB-INF folder of your OpenCms installation
- 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.
[edit] What do you get? Usage.
Once the shell is correctly run, you get something likeGuest@Online:|/>
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
[edit] Available commands
Under the shell you can execute commands like the following:
login "Admin" "password" createDefaultProject "Offline" "The Offline Project"
These are two samples of the long list of possible commands. The available commands are public methods in the classes:
- org.opencms.main.CmsShellCommands (see all available methods)
- org.opencms.file.CmsRequestContext (see all available methods)
- org.opencms.file.CmsObject (see all available methods)
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).
[edit] Complete method list
A complete availabe methods list as provided with command help * is (OpenCms 6.2.3):
[edit] 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()
[edit] 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)
[edit] 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)

