Alfresco Modules
Recently we came across a situation whereby we needed to uninstall a previously installed module for one of customers but we did not have a window to restart alfresco. So we thought why not write a simple blog about how we can uninstall a module without restarting alfresco using the Module Management Tool (MMT) and also explore the other commands of MMT.
Alfresco Module Package (AMP)
The Alfresco Module Package (AMP) file format is the standard mechanism to package Modules for deployment in production environments. An AMP is essentially a Zip file with a specific layout, containing all of the files required for a specific extension, including data you might to upload to the repository. AMP can be deployed in two ways, either by using the apply_amps.sh script or using the Module Management Tool (MMT) located in the $ALFRESCO_HOME/bin directory. The apply_amps.sh script applies all the AMPs found in the amps and amps_share folders found in the $ALFRESCO_HOME directory. While using the apply_amps.sh provides a very quick way of deploying amps, it provides less control and requires an alfresco restart. So let’s have a look at our second option which is the MMT.
Module Management Tool (MMT)
The Module Management Tool (MMT) provides a more controlled way to install and manage modules packaged as AMP files. The MMT program (alfresco-mmt.jar) is available from $ALFRESCO_HOME/bin directory.
MMT Commands
Command |
Description |
Syntax |
install |
Installs an AMP file into an Alfresco WAR file, updates if an older version is already installed. |
install <AMPFileLocation> <WARFileLocation> [options] |
[options] |
|
|
-verbose |
enable verbose output |
|
-directory |
Indicates that the amp file location specified is a directory. All amp files found in the directory and its sub directories are installed. |
|
-force |
forces installation of AMP regardless of currently installed module version |
|
-preview |
previews installation of AMP without modifying WAR file |
|
-nobackup |
indicates that no backup should be made of the WAR |
|
uninstall |
Uninstalls a module from the Alfresco WAR file. |
uninstall <ModuleId> <WARFileLocation> |
|
|
|
Installing a Module in Alfresco
The ‘install’ command installs the files found in the AMP file into the Alfresco or Share WAR if it a new AMP and if an older version is already installed then the files relating to the older version are removed from the WAR and replaced with the newer files.
In order to install a new module do the following steps;
1. Go to $ALFRESCO_HOME/bin directory
2. Run the following command to see the modifications that will be made to the WAR without making any physical changes. Note the use of the preview option.
java -jar $ALFRESCO_HOME bin/alfresco-mmt.jar install auditshare-module-alfresco $ALFRESCO_HOME/tomcat/webapps/alfresco –preview
3. Then to run the above command without the –preview option to physically install the module.
Note
The MMT makes a copy of the original WAR in the same directory before an AMP is installed into the WAR unless the -nobackup option is used.
Uninstalling a Module in Alfresco
Since an AMP file relates to a specific module and version, a module can be uninstalled using the MMT tool based on the module id and war file location.
In order to uninstall a module do the following steps;
1. Go to $ALFRESCO_HOME/bin directory
2. Run the following command to get the list of installed modules in the alfresco war
java -jar $ALFRESCO_HOME/bin alfresco-mmt.jar list $ALFRESCO_HOME/tomcat/webapps/alfresco
Repeat for share war as well
3. Note down id for the module you want to uninstall and then run the following command
java -jar $ALFRESCO_HOME bin/alfresco-mmt.jar uninstall auditshare-module-alfresco $ALFRESCO_HOME/tomcat/webapps/alfresco
Repeat for share war as well
Note
- In our case, the module id was auditshare-module-alfresco.
- Sometimes the tomcat cache is required to be cleared for the system to work efficiently and there is not other option besides restarting tomcat.
Reference
http://docs.alfresco.com/4.2/index.jsp