Traditionally the CmsShell had to be run in a separate process. In case you have an OpenCms server running, this means that the server and the CmsShell would be 2 different processes with no shared runtime settings. So with the traditional CmsShell it is not possible to manipulate a running server.
Enter the CmsRemoteShell. This is an RMI based version of the CmsShell that is optionally started by the OpenCms server. If the CmsRemoteShell has been activated, it is possible to connect to the server and run a set of shell command in the server process.
The CmsRemoteShell can be accessed only from the server where the OpenCms instance is running. This is a security feature. The reasoning is that in case you do remote server management, you should already have an environment that allows you to trigger scripts on your OpenCms server in a secure way.
The CmsRemoteShell can be enabled in the
opencms-system.xml configuration file.
Insert this XML at the last position before the closing
<shell-server enabled="true" port="1101" />To call the CmsRemoteShell, use the following command:
java -cp $OPENCMS_WEBAPP_DIR/WEB-INF/lib/opencms.jar org.opencms.rmi.CmsRemoteShellClient [options]Description of options with examples:
- Runs the commands from
filename.txtinstead of reading commands interactively. Important: In case you run a script, make sure the last command in the script is
exit, otherwise the shell will not terminate.
- The port to use for the RMI connection.
- A class that provides additional shell commands.
Interface Summary Interface Description I_CmsRemoteShellRemote interface for executing shell commands. I_CmsRemoteShellProviderUsed to create new instances of I_CmsRemoteShell.
Class Summary Class Description CmsRemoteShellRMI object which wraps a CmsShell and can be used for shell command execution. CmsRemoteShellClientClient application used to connect locally to the CmsShell server. CmsRemoteShellConstantsConstants used by both the shell server and the client application. CmsRemoteShellProviderRemote object responsible for creating new remote shell instances. CmsRemoteShellServerThis class is used to initialize the RMI mechanism and export the object used to access the remote shell. CmsShellCommandResultAn object containing the output of a remote shell command and also the updated values for some of the internal state fields of the client application.