Updating a customized IPT

This post originally appeared on the Canadensys blog and is a follow-up of the post Customizing the IPT.

As mentioned at the very end of my post about customizing the IPT, I face a problem when I want to install a new version of the GBIF Integrated Publishing Toolkit: installing it will overwrite all my customized files! Luckily Tim Robertson gave me a hint on how to solve this: a shell script to reapply my customization.

Here's how it works (for Mac and Linux systems only):

Comparing the customized files with the default files

First of all, I need to compare my customized files with the files from the new IPT. They might have changed to include new functionalities or fix bugs. So, I installed the newest version of IPT on my localhost, opened the default files and compared them with my files. Although there are tools to compare files, I mostly did this manually. The biggest change in version 2.0.3 was the addition of localization, for which I'm using a different UI, so I had to tweak some things here and there. It took me about 3 hours until I was satisfied with the new customized IPT version on my localhost.

I also subscribed to the RSS of the IPT Google Code website, to be notified of any changes in the code of "my" files, but I was just using this as a heads-up for coming changes. It is more efficient to change everything at once, when a stable version of IPT is out.

Setting up a file structure

This is how we've organized the files on our server. I've created a folder called ipt-customization, which contains all my customized files. That way, they can never be overwritten by a new IPT installation, which gets deployed in webapps. The folder also contains a script to apply the customization and a folder to backup the default files currently used by IPT.

  • ipt-data

  • webapps

    • ipt


  • ipt-customization

    • backup-default

    • apply-customization.sh

    • revert-customization.sh

    • header.ftl

    • header_setup.ftl

    • menu.ftl

    • footer.ftl

    • main.css

    • custom.js


Creating the shell script

The apply-customization.sh script works in two steps:

  1. Backup the default files, by copying them from IPT to the folder backup-default. The script will ask if I want to overwrite any previously backed up files. The last part is important if I'm running the script several times. In that case I do not want to overwrite the backups with the already customized files.

  2. Overwrite the files currently used by IPT with the customized files, by copying them from my ipt-customization folder to the correct folder in IPT

# backup files of new IPT installation

cp -i ../webapps/ipt/WEB-INF/pages/inc/footer.ftl ../ipt-customization/backup-default/

cp -i ../webapps/ipt/WEB-INF/pages/inc/header_setup.ftl ../ipt-customization/backup-default/

cp -i ../webapps/ipt/WEB-INF/pages/inc/header.ftl ../ipt-customization/backup-default/

cp -i ../webapps/ipt/WEB-INF/pages/inc/menu.ftl ../ipt-customization/backup-default/

cp -i ../webapps/ipt/styles/main.css ../ipt-customization/backup-default/



# apply customization

cp footer.ftl ../webapps/ipt/WEB-INF/pages/inc/

cp header_setup.ftl ../webapps/ipt/WEB-INF/pages/inc/

cp header.ftl ../webapps/ipt/WEB-INF/pages/inc/

cp menu.ftl ../webapps/ipt/WEB-INF/pages/inc/

cp main.css ../webapps/ipt/styles/

cp custom.js ../webapps/ipt/js/


I also created a script revert-customization.sh, to revert the customization to the default IPT, in case something is broken. It moves the backed up files back to IPT:

# revert customization

cp backup-default/footer.ftl ../webapps/ipt/WEB-INF/pages/inc/

cp backup-default/header_setup.ftl ../webapps/ipt/WEB-INF/pages/inc/

cp backup-default/header.ftl ../webapps/ipt/WEB-INF/pages/inc/

cp backup-default/menu.ftl ../webapps/ipt/WEB-INF/pages/inc/

cp backup-default/main.css ../webapps/ipt/styles/

rm ../webapps/ipt/js/custom.js


Running the script

From the command line, I login to my server, navigate to the folder ipt-customization and make my script executable:

chmod +x apply-customization.sh

I only have to do this the first time I want to use my script. From then on I can use:

sh ./apply-customization.sh

To execute the script and customize my new version of IPT!

Comments

Popular posts from this blog

Optimizing Writes in HBase

Lots of columns with Hive and HBase

Darwin Core Archives for Species Checklists