Tuesday, September 8, 2015

Generating self-signed SSL cert and PEM

Sign in as root then run this

cd /etc/ssl
openssl req -x509 -new -nodes -newkey rsa:2048 -keyout haproxy.key -out haproxy.crt
cat ./haproxy.crt ./haproxy.key > ./haproxy.pem

You can  name the files whatever you want instead of using "haproxy", which I use since I like to have SSL termination in my haproxy server.

Wednesday, September 2, 2015

Injection GIT branch / tag name into config.properties file

Prerequisite: In your project you need the file src/main/resources/config.properties

Of course you can adapt to using whatever file you want.

Note that this assumes you're using a "version=" property in your config.properties file


Step 1: Add the maven plugin to run an executable

1:  #!/usr/bin/env bash  
2:    
3:  # Get the git branch / tag name  
4:    
5:  # first, see of we have branch information (this will not be available if we checked out a tag)  
6:  TAG_OR_BRANCH="$(git rev-parse --abbrev-ref HEAD | egrep -o '([0-9]{1,}\.)+[0-9]{1,}')"  
7:    
8:  if [ "$TAG_OR_BRANCH" == "" ]; then  
9:    
10:    # if we can't get branch info, then we must be in a tag, so use that  
11:    TAG_OR_BRANCH="$(git describe | egrep -o '([0-9]{1,}\.)+[0-9]{1,}+(-b[0-9]{1,})')"  
12:  fi  
13:    
14:  # Remove the version from the properties file  
15:  sed -i '/^version=/ d' src/main/resources/static/version  
16:    
17:  # Add the version to the properties file  
18:  echo "Writing version $TAG_OR_BRANCH"  
19:  echo "version=$TAG_OR_BRANCH" >> src/main/resources/static/version