Posts Tagged port

PORTING KANNEL TO HP UX

(Tested with version 11.11)

Before we begin, it would be useful to have the backspace key on hand so do:
#stty erase [BACKSPACE KEY]
or just install bash.

1. Before compiling kannel, we first need to put the HP UX application layer on steroids. So, download libxml2, gcc-4.1.1, libiconv, gettext, bison, flex etc and all the related dependencies from the following link:
http://hpux.connect.org.uk/

Note: When installing hp depot files, ensure you type in the whole path to the depot, or else it will complain about not being able to see the package. For example to install gcc, assuming the depot file was in /opt, you would type this:

#cd opt
#gunzip gcc-4.1.1-hppa-11.11.depot.gz
#swinstall -s /opt/gcc-4.1.1-hppa-11.11.depot gcc

Do an swinstall for all the other related packages. You can check for the related dependencies by referring to the hpux.connect.org.uk porting and archiving center site listed dependencies for each package.

2. Inside your /etc/profile file, add the following lines (SHLIB_PATH is used in 32-bit machines while LD_LIBRARY_PATH is used in 64-bit HP machines; just put both in to be sure)


export LD_LIBRARY_PATH=/usr/local/lib:/lib:/usr/lib:/opt/gnome/lib/
export SHLIB_PATH=/usr/local/lib:/lib:/usr/lib:/opt/gnome/lib/

Now do:
#env

and ensure the variables above are set. If not, you can run them manually for now. However, since you have put these variables inside the /etc/profile file, the next time you login they will be automatically set in the environment.

3. Once you are through, installing gcc and all the related dependencies, download kannel and follow the steps below (The version we used was: gateway-1.4.1):
(Please ensure that inside the configure file, the CC variable refered to is gcc and not the HP UX cc, or else your configure will fail!)

(We are configuring kannel with minimal options in this case. You may also wish to add database support eg for MySQL)

#./configure --with-malloc=native --enable-sdb

4. Configure will complete successfully. However, before running the gmake (Please do not run make as this will use HP make and your compilation of kannel will fail! Please ensure you run gmake not make!), edit the files
gw/smsc/smsc_smpp.c
gw/smsc/smsc_soap.c

If you are on a 32-bit machine, replace all occurences of the strtoll method in kannel with strtoimax
If you are on a 64-bit machine, replace all occurences of the strtoll method in kannel with strtol

Do this so gmake will succeed in compiling kannel. This is because HP UX does not have any definitions for strtoll function.

5. Run gmake

#gmake

6. Once you have successfully run gmake, run a gmake install. I always like installing kannel in /usr/local/sbin (actually that’s the default kannel install directory!) so I specify my bindir like this:

#gmake --bindir=/usr/local/sbin

When starting kannel, it will complain about not being able to find the shared library libiconv in /usr/local/lib, so add the following symbolic link:
#ln -s /opt/gnome/lib/libiconv.sl.2 /usr/local/lib/libiconv.sl.2

7. Next put the kannel init.d script below in the /sbin/init.d directory.

#!/sbin/sh
#
# NOTE: This script is not configurable! Any changes made to this
# scipt will be overwritten when you upgrade to the next
# release of HP-UX.
#
# WARNING: Changing this script in any way may lead to a system that
# is unbootable. Do not modify this script.
#

#
# Start kannel
#

PATH=/sbin:/usr/sbin:/usr/bin
export PATH

KANNEL_CONFIG=/usr/kannel/kannel.conf
KANNEL_BASE=/usr/local/sbin

rval=0
set_return() {
x=$?
if [ $x -ne 0 ]; then
echo "ERROR CODE $x"
rval=1
fi
}

case $1 in
start_msg)
echo "Start kannel daemon"
;;

stop_msg)
echo "Stop kannel daemon"
;;

'start')
if [ -f /etc/rc.config.d/kannel ] ; then
. /etc/rc.config.d/kannel
else
echo "ERROR: /etc/rc.config.d/kannel defaults file MISSING"
fi

${KANNEL_BASE}/bearerbox $KANNEL_CONFIG 2>/dev/null 1>/dev/null &
${KANNEL_BASE}/smsbox $KANNEL_CONFIG 2>/dev/null 1>/dev/null &

set_return
;;

'stop')
#
# Determine PID of kannel process(es) to stop
#
smsboxpid=`ps -ef | awk '/smsbox/ && !/awk/ {print $2}'`
kill -9 $smsboxpid
bearerboxpid=`ps -ef | awk '/bearerbox/ && !/awk/ {print $2}'`
kill -9 $bearerboxpid
;;

*)
echo "usage: $0 {start|stop}"
;;
esac

exit $rval

8. Now follow these steps:
#chmod 755 /sbin/init.d/kannel

Link it to the rcX.d directories ie:
#ln -s /sbin/init.d/kannel /sbin/rc3.d/S500kannel
#ln -s /sbin/init.d/kannel /sbin/rc2.d/K500kannel

Create the /etc/rc.config.d/kannel file:
#echo START_INN=1 >/etc/rc.config.d/kannel

10. Now, configure the KANNEL_BASE and KANNEL_CONFIG variables in the init.d file as suitable to your system. Then;

To start kannel:
#/sbin/init.d/kannel start
To stop kannel,
#/sbin/init.d/kannel stop

Kannel successfully ported to HP UX.

Comments (9)