Total Pageviews

Sunday, December 22, 2013

How to install Jira 6.0.6 on a QNAP TS-569 Pro

The QNAP TS-569 Pro is a Intel Atom based NAS system. Therefore it should be no problem to run any Java based application on it.
I managed to get JDK 7 up and running as well, so Jira should be possible too. I installed version 6.0.6, 32 bit edition, but newer versions should run as well.
Keep in mind that the QNAP TS-569 Pro is running a 32 Bit Linux, despite the fact that the underlying architecture is 64 bit.
I upgraded my RAM to 4GB because running Java server applications like Jira or Confluence need more than the stock 1GB.

Assumptions:

  1. All commands are executed using a ssh connection (admin user) to the TS-569 Pro
  2. I did not use a bash environment. Only the built in sh shell was used.
  3. In general you don't need a separate installation of Java 6 or 7, because Jira comes with a bundled JRE 7. My NAS already had a JDK 7 installation with JAVA_HOME pointing to that location. But in principle this should not be necessary.
  4. To configure the MySQL service I used the phpmyadmin QPKG installation
  5. To make things a little bit easier for me and to have more Linux feeling I installed Optware IPKG 
Brief installation instructions:
  1. Create an installation directory for Jira. I chose /share/MD0_Data/Opt/jira but this is totally free and up to you.
  2. Download the 32 Bit installer version of Jira. and save it to a folder on your NAS. It is a script which contains the complete Jira distribution. You don't have to extract anything manual. 
  3. Change into the directory where the downloaded file resides
  4. If not already done make the script executable: chmod +x atlassian-jira-6.0.6-x32.bin
  5. Start the script by executing: ./atlassian-jira-6.0.6-x32.bin
  6. You will get an error saying:
    Sorry, but I could not find gunzip in path. Aborting
  7. I found the solution for that problem in this forum post:
    The gunzip Version on the QNAP seems to be a different one than the script is expecting. The option -V is not recognized by the QNAP gunzip version.
    So just load the script into an editor of your choice (I used the ipkg emacs version) and remove these lines from the script and save it afterwards:
  8.  gunzip -V > /dev/null 2>&1  
     if [ "$?" -ne "0" ]; then  
      echo "Sorry, but I could not find gunzip in path. Aborting."  
      exit 1  
     fi  
    
  9. Start the script again and wait a couple of minutes (yes indeed, it took 2-3 minutes on my NAS)
  10. The console installer starts after the script extracted the installation files and you can continue your Jira installation just like described in the official Jira installation documentation.
  11. You may tweak the JVM settings in the setenv.sh file of your Jira installation to adjust memory settings.
  12. That's it. The next thing would be to create start/stop scripts for the runlevels to make the Jira service start whenever the NAS is starting. This is stuff for one of the next articles.

Monday, December 09, 2013

Useful Subversion pre-commit hook script for Linux servers

Looking for useful subversion pre-commit hooks? Maybe this script is for you. It's a Linux bash shell script and makes also use of python.
The script does the following:

  1. Checks whether the commit message is not empty
  2. Checks whether the commit message consists of at least 5 characters
  3. Checks if the committed files are UTF-8 compliant
  4. Checks whether the svn:eol-style property is set to LF on newly added files
  5. Checks if the committed files have no TAB characters

The UTF-8 and TAB checks are performed on the following file suffixes
  • *.java
  • *.js
  • *.xhtml
  • *.css
  • *.xml
  • *.properties (only check for TABs here, no check for UTF-8 compliance)
It should be easy to adjust those settings to your needs.

 #!/bin/bash  
   
 REPOS="$1"  
 TXN="$2"  
   
   
 # Make sure that the log message contains some text.  
 SVNLOOK=/usr/bin/svnlook  
 ICONV=/usr/bin/iconv  
   
 SVNLOOKOK=1  
 $SVNLOOK log -t "$TXN" "$REPOS" | \  
 grep "[a-zA-Z0-9]" > /dev/null || SVNLOOKOK=0  
 if [ $SVNLOOKOK = 0 ]; then  
  echo "Empty log messages are not allowed. Please provide a proper log message." >&2  
  exit 1  
 fi  
   
 # Comments should have more than 5 characters  
 LOGMSG=$($SVNLOOK log -t "$TXN" "$REPOS" | grep [a-zA-Z0-9] | wc -c)  
   
 if [ "$LOGMSG" -lt 6 ]; then  
  echo -e "Please provide a meaningful comment when committing changes." 1>&2  
  exit 1  
 fi  
   
 # Make sure that all files to be committed are encoded in UTF-8.  
 while read changeline;   
 do  
   
   # Get just the file (not the add / update / etc. status).  
   file=${changeline:4}  
   
   # Only check source files.  
   if [[ $file == *.java || $file == *.xhtml || $file == *.css || $file == *.xml || $file == *.js ]] ; then  
     $SVNLOOK cat -t "$TXN" "$REPOS" "$file" | $ICONV -f UTF-8 -t UTF-8 -o /dev/null  
     if [ "${PIPESTATUS[1]}" != 0 ] ; then  
       echo "Only UTF-8 files can be committed ("$file")" 1>&2  
       exit 1  
     fi  
   fi  
 done < <($SVNLOOK changed -t "$TXN" "$REPOS")  
   
 # Check files for svn:eol-style property  
 # Exit on all errors.  
 set -e  
 EOL_STYLE="LF"  
 echo "`$SVNLOOK changed -t "$TXN" "$REPOS"`" | while read REPOS_PATH  
 do  
  if [[ $REPOS_PATH =~ A[[:blank:]]{3}(.*)\.(java|css|properties|xhtml|xml|js) ]]  
  then  
   if [ ${#BASH_REMATCH[*]} -ge 2 ]  
     then  
   FILENAME=${BASH_REMATCH[1]}.${BASH_REMATCH[2]};  
   
   # Make sure every file has the right svn:eol-style property set  
    if [ $EOL_STYLE != "`$SVNLOOK propget -t \"$TXN\" \"$REPOS\" svn:eol-style \"$FILENAME\" 2> /dev/null`" ]  
     then  
     ERROR=1;  
       echo "svn ps svn:eol-style $EOL_STYLE \"$FILENAME\"" >&2  
    fi  
   fi  
  fi  
  test -z $ERROR || (echo "Please execute above commands to correct svn property settings. EOL Style LF must be used!" >& 2; exit 1)  
 done  
   
   
   
 # Block commits with tabs  
 # This is coded in python  
 # Exit on all errors  
 set -e  
   
 $SVNLOOK diff -t "$TXN" "$REPOS" | python /dev/fd/3 3<<'EOF'  
 import sys  
 ignore = True  
 SUFFIXES = [ ".java", ".css", ".xhtml", ".js", ".xml", ".properties" ]  
 filename = None  
   
 for ln in sys.stdin:  
   
     if ignore and ln.startswith("+++ "):  
         filename = ln[4:ln.find("\t")].strip()  
         ignore = not reduce(lambda x, y: x or y, map(lambda x: filename.endswith(x), SUFFIXES))  
   
     elif not ignore:  
         if ln.startswith("+"):  
           
            if ln.count("\t") > 0:  
               sys.stderr.write("\n*** Transaction blocked, %s contains tab character:\n\n%s" % (filename, ln))  
               sys.exit(1)  
   
         if not (ln.startswith("@") or \  
            ln.startswith("-") or \  
            ln.startswith("+") or \  
            ln.startswith(" ")):  
   
            ignore = True  
   
 sys.exit(0)  
 EOF  
   
 # All checks passed, so allow the commit.  
 exit 0