From 9e1c2a680a391dff63d5abc114cbed97e9fffd35 Mon Sep 17 00:00:00 2001 From: Simon Pamies Date: Thu, 25 Apr 2013 11:49:56 +0200 Subject: [PATCH] Updated build script and added scripts to test UDP connections (useful if not sure if firewall is open or a great firewall restricts access) --- configuration/buildAndUpdateProduct.sh | 23 +++++++++++++++++++++++ configuration/udpsender.py | 13 +++++++++++++ configuration/udpserver.py | 13 +++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 configuration/udpsender.py create mode 100644 configuration/udpserver.py diff --git a/configuration/buildAndUpdateProduct.sh b/configuration/buildAndUpdateProduct.sh index 76ecd3f9ca4..07ce86b3c30 100755 --- a/configuration/buildAndUpdateProduct.sh +++ b/configuration/buildAndUpdateProduct.sh @@ -160,6 +160,11 @@ if [[ "$@" == "hot-deploy" ]]; then # check telnet port connection TELNET_ACTIVE=`netstat -tlnp 2>/dev/null | grep ":$OSGI_TELNET_PORT"` + if [[ $TELNET_ACTIVE == "" ]]; then + # some BSD systems do not support -p + TELNET_ACTIVE=`netstat -an | grep ".$OSGI_TELNET_PORT"` + fi + if [[ $OSGI_TELNET_PORT == "" ]] || [[ $TELNET_ACTIVE == "" ]]; then echo "" echo "ERROR: Could not find any process running on port $OSGI_TELNET_PORT. Make sure your server has been started with -console $OSGI_TELNET_PORT" @@ -178,12 +183,21 @@ if [[ "$@" == "hot-deploy" ]]; then fi # first get bundle ID + echo -n "Connecting to OSGi server..." NC_CMD="nc -t 127.0.0.1 $OSGI_TELNET_PORT" + echo "OK" OLD_BUNDLE_INFORMATION=`echo -n ss | $NC_CMD | grep ${OSGI_BUNDLE_NAME}_` BUNDLE_ID=`echo $OLD_BUNDLE_INFORMATION | cut -d " " -f 1` OLD_ACTIVATED_NAME=`echo $OLD_BUNDLE_INFORMATION | cut -d " " -f 3` echo "Could identify bundle-id $BUNDLE_ID for $OLD_ACTIVATED_NAME" + read -s -n1 -p "I will now stop bundle $OLD_BUNDLE_INFORMATION with id $BUNDLE_ID - is this right? (y/N): " answer + case $answer in + "Y" | "y") echo "Continuing";; + *) echo "Aborting..." + exit;; + esac + # stop and uninstall echo -n stop $BUNDLE_ID | $NC_CMD > /dev/null echo -n uninstall $BUNDLE_ID | $NC_CMD > /dev/null @@ -278,6 +292,14 @@ if [[ "$@" == "install" ]] || [[ "$@" == "all" ]]; then mkdir $ACDIR/plugins fi + if [ ! -d "$ACDIR/logs" ]; then + mkdir $ACDIR/logs + fi + + if [ ! -d "$ACDIR/tmp" ]; then + mkdir $ACDIR/tmp + fi + if [ ! -d "$ACDIR/configuration" ]; then mkdir $ACDIR/configuration fi @@ -316,6 +338,7 @@ if [[ "$@" == "install" ]] || [[ "$@" == "all" ]]; then cp -v $PROJECT_HOME/java/target/start $ACDIR/ cp -v $PROJECT_HOME/java/target/stop $ACDIR/ + cp -v $PROJECT_HOME/java/target/udpmirror $ACDIR/ echo "Installation complete. You may now start the server using ./start" fi diff --git a/configuration/udpsender.py b/configuration/udpsender.py new file mode 100644 index 00000000000..a5372c06190 --- /dev/null +++ b/configuration/udpsender.py @@ -0,0 +1,13 @@ +import socket + +UDP_IP = "195.227.44.85" +UDP_PORT = 2013 +MESSAGE = "Hello, World!" + +print "UDP target IP:", UDP_IP +print "UDP target port:", UDP_PORT +print "message:", MESSAGE + +sock = socket.socket(socket.AF_INET, # Internet + socket.SOCK_DGRAM) # UDP +sock.sendto(MESSAGE, (UDP_IP, UDP_PORT)) diff --git a/configuration/udpserver.py b/configuration/udpserver.py new file mode 100644 index 00000000000..fb9a29c94a0 --- /dev/null +++ b/configuration/udpserver.py @@ -0,0 +1,13 @@ +import socket + +UDP_IP = "195.227.44.85" +UDP_PORT = 2013 + +sock = socket.socket(socket.AF_INET, # Internet + socket.SOCK_DGRAM) # UDP +sock.bind((UDP_IP, UDP_PORT)) + +print "Listening on 195.227.44.85 port %s" % UDP_PORT +while True: + data, addr = sock.recvfrom(1024) # buffer size is 1024 bytes + print "received message:", data