Update a specific Magento module that has been installed with modman

A bash script that updates a specific modman module.
created by on 2013-10-10

update-magento-module.bash

#!/usr/bin/env bash

# deploy the magento module with the supplied name

# check the command arguments
if [ $# -eq 0 ]; then
	echo "No module name supplied. Please specify a module name."
	exit 1
fi

# get the module name
modulename="$1"

if [ -z "$modulename" ]; then
	echo "No module name supplied. Please specify a module name."
	exit 1
fi

# get the working directory
wd=${PWD}

# get the modman folder
modmanfolder=$wd/.modman

if [ ! -d "$modmanfolder" ]; then
	echo "No modman folder found. Make sure to execute the script within a magento root that is modman-ready."
	exit 1
fi

# get the module folder
modulefolder="$modmanfolder/$modulename"

if [ ! -d "$modulefolder" ]; then
	echo "The module '$modulename' is not installed."
	exit 1
fi

echo "Deploying magento module '$modulename' in folder '$wd'."

# clean the repository
echo "Preparing update ..."
cd $modulefolder
git checkout .
git clean -df
cd $wd

# execute the update
modman update $modulename

# reassing the permissions
find $wd -group deployment -exec chgrp magento-runtime {} \;

# make the cron.sh script executatble
chmod +x $wd/cron.sh

I used this script in conjunction with postdeploy in order to respond to Bitbucket commit hooks. This enabled very quick deployments.

Tags: