Wednesday, April 25, 2012

P2 support for Nexus OSS


 
Working with latest OSGi technology I use Tycho + Maven for my CI builds. This makes it necessary to deal with P2. To speed things up it is a good idea to proxy your P2 repositories. You can easily achieve this by "upgrading" Sonatype Nexus OSS edition to provide P2 capabilities.

Go to the Sonatype RSO repository and download the following bundles:
  • nexus-p2-repository-plugin
  • nexus-p2-bridge-plugin
If necessary also download a recent version of the nexus-capabilities-plugin.
Stop your Nexus instance and copy the downloaded bundles to NEXUS_HOME/nexus/WEB-INF/plugin-repository

Now you are done and can startup Nexus and will have P2 support.
As a first step I highly recommend to mirror/proxy the Eclipse P2 repository:
http://download.eclipse.org/releases/indigo/

Tuesday, February 28, 2012

Learning Go

Go is the new kid in town which wants to superseed the programming language C.

So let's have a brief overview of what Go brings to the table:
  • typesafety
  • garbage collection
  • concurrency
  • clean and concise syntax
  • error handling via panic/recover
Let's take a ride with Go on Debian GNU/Linux with Eclipse:

sudo apt-get install golang-weekly

I assume you have already installed Eclipse. Go is supported with Eclipse via the Goclipse plugin.

Install Goclipse via the following update site:
http://goclipse.googlecode.com/svn/trunk/goclipse-update-site/

Now hook your Go installation up with the Goeclipse plugin goto Window>Preferences>Go and apply the following path settings:

Now we are ready to create a classical hello world.
  • change to Go perspective
  • create a new Go Project and name it HelloGo
  • within HelloGo/src/cmd create a new main.go (see content below)
  • now run main.go(right click Run As>Run Go Application)

package main

import (
 "fmt"
)

func main() {
 fmt.Printf("Hello World!")
}

So that's it for now have fun :-)

Sunday, February 26, 2012

Installing Oracle JDK7 on Debian GNU Linux

Since Oracle does not allow anymore to ship its "orignal" JDK7 with Linux distributions developers are to either use OpenJDK7 or manually install Oracle JDK7. Fortunately the oldtimer debian tool java-package got revived which makes it pretty easy to create an installable deb of the Oracle JDK tarball.


So here we go:

First download Oracle JDK7 tarball (not rpm!) e.g. jdk-7u3-linux-x64.tar.gz then fire up a shell.

sudo apt-get install java-package
make-jpkg jdk-7u3-linux-x64.tar.gz
sudo dpkg -i oracle-j2sdk1.7_1.7.0+update3_amd64.deb
sudo update-java-alternatives -l
sudo update-java-alternatives --jre --plugin -s  j2sdk1.7-oracle

Monday, December 26, 2011

Securing SSH

If you are having a machine exposed to the Internet via SSH you should secure your system.
Here is a quick recipe how this can be achieved:

Modify your SSH server configuration /etc/ssh/sshd_config:
  • change the default port
  • do not allow root login
  • do not allow password login
Port 221234
PermitRootLogin no
ChallengeResponseAuthentication no
PasswordAuthentication no
PermitEmptyPasswords no

Before you disable password authentication make sure you have copied your public key to the server. This can be achieved via ssh-copy-id command.

# ssh-copy-id myuser@server

In addition install denyhosts to block brute-force SSH login requests.
Denyhosts will continuously update your hosts.deny file with bad IPs / Hosts.

Thursday, December 15, 2011

SCM-Manager

SCM-Manager is a cool Jetty based HTTP-server for managing your source code repositories. Just one single mangement instance for dealing with various SCMs which makes it a lot easier to maintain your projects.

SCM-Manager supports Mercurial, Git, and Subversion. You can manage all your users and their permissions very easily.  Of course SCM-Manager also provides bridges for different kinds of authentication like PAM, LDAP and Active Direcotry.

With a bunch of plugins  and the possibilty to write your own plugins there are basically no limitations with this great software. Highly recommended is the Jenkins plugin which allows to inform your CI whenever there are changes on your repo so there is no need for dump polling.

Installation on Debian / Ubuntu:
  •     download latest release of scm-server
  •     unpack to /opt/scm-server
  •     add the script below to /etc/init.d/scmserver
  •     add a user scmserver
  •     run update-rc.d-insserv scmserver defaults
  •     /etc/init.d/scmserver start

#!/bin/sh
#
### BEGIN INIT INFO
# Provides:          scmserver
# Required-Start:    $remote_fs $syslog $network
# Required-Stop:     $remote_fs $syslog $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start scmserver at boot time
# Description:       Control Repositories
### END INIT INFO

# Source function library.
if [ -x /etc/rc.d/init.d/functions ]; then
. /etc/rc.d/init.d/functions
fi

# Check for and source configuration file otherwise set defaults
RETVAL=0

appname=ScmServerDaemon

# See how we were called.
start() {
    # Call the scm-server script as our user
    /bin/su - scmserver -c "/opt/scm-server/bin/scm-server start >> /opt/scm-home/logs/scm-manager-output.log 2>&1 & "

}

stop() {
    if [ ! status = 0 ]
    then
          SCM_PID=$( ps auxwww | grep  java | grep ${appname} | awk '{print $2 }' )
          kill -9 $SCM_PID
    else
      echo "SCM is not running"
    fi

}

status() {
    ps auxwww | grep  java | grep ${appname} || echo "SCM is not running"

}

restart() {
    stop
    SECONDS=0
    STAT=$( ps auxwww | grep  java | grep ${appname} |  wc -l )
    while [ $STAT -ne 0 ]
    do
      sleep 3
        if [ $SECONDS -gt 300 ]
        then
          SCM_PID=$( ps auxwww | grep  java | grep ${appname} | awk '{ print$2 }' )
          kill -9 $SCM_PID
        fi
      STAT=$( ps auxwww | grep  java | grep ${appname} |  wc -l )
    done
    start

}

# See how we were called.
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart)
        restart
        ;;
  status)
        status
        ;;
  *)
        echo "Usage: $0 {start|stop|restart}"
        exit 1
esac

exit $RETVAL

Wednesday, December 14, 2011

Make Nexus startup script LSB compliant

I recently ran into the following error with  Nexus and Debian:

warning: script 'nexus' missing LSB tags and overrides insserv... 

which causes a loop within insserv. This is due to a non LSB compliant startup script of Nexus. To make your nexus startup script LSB compliant add the following stuff at the beginning:

#! /bin/sh

### BEGIN INIT INFO
# Provides:          nexus
# Required-Start:    $remote_fs $syslog $network
# Required-Stop:     $remote_fs $syslog $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Nexus Maven Proxy
# Description:       Nexus Maven Proxy
### END INIT INFO
Then run:
# insserv nexus 
and you are done.

Insserv is now aware of preconditions for properly starting and stopping Nexus.

Here I am

I am a Java Software Developer and  Debian Linux user always trying out new stuff and also facing problems. Here I will share my experience and solutions to problems I had to deal with.