  	export PATH=$PATH:$JAVA_HOME/bin
  	if [ ! -e /etc/config/log4j.xml ] ; then
  		cp $CFG_TEMPLATE_DIR/log4j.xml /etc/config
-@@ -20,8 +33,8 @@
+@@ -18,15 +33,15 @@
+ }
+ 
  start() {
- 	echo -n "Starting HMServer: "
+-	echo -n "Starting HMServer: "
++	echo -n "Starting ${HM_SERVER_TYPE}: "
  	init
 -	start-stop-daemon -S -q -m -p $PIDFILE --exec java -- -Xmx64m -Dlog4j.configuration=file:///etc/config/log4j.xml -Dfile.encoding=ISO-8859-1 -jar /opt/HMServer/HMIPServer.jar /etc/crRFD.conf &
 -	echo "Waiting for HMServer to get ready"

+[[ ${HM_MODE} == "HMLGW" ]] && exit 0
+
+if [[ ${HM_MODE} == "HmIP" ]]; then
+  HM_SERVER=/opt/HMServer/HMIPServer.jar
+  HM_SERVER_ARGS="/etc/crRFD.conf"
+  PIDFILE=/var/run/HMServer.pid
+else
+  HM_SERVER=/opt/HMServer/HMServer.jar
+  HM_SERVER_ARGS=""
+  PIDFILE=/var/run/HMIPServer.pid
+fi
+
 init() {

 
--- homematic/HMserver/etc/init.d.orig
+++ homematic/HMserver/etc/init.d
@@ -5,12 +5,27 @@
 
 LOGLEVEL_HMServer=5
 CFG_TEMPLATE_DIR=/etc/config_templates
