#!/bin/bash

# This script updates an already existing variable in default.props.
# If the variable name is found more than ones it will be updated in all places
# Run this like: updatePropertyValue <propertyName> <propertyValue>

# Check number of parameters to be two
if [ "$#" != 2 ]; then
    echo "Usage:"
    echo "updatePropertyValue <propertyName> <propertyValue>"
    exit
fi

propertyName=$1
propertyValue=$2

# Find variable in file and change its assignment to propertyValue.
sed -i  "s,^\($propertyName=\).*,\1$propertyValue," /srv/tomcat/webapps/um/WEB-INF/classes/props/default.props
