Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Info

Information

Dialogic NaturalAccess Software is use to create development and runtime environment for creating voice, fxs, conferencing and video application using the Dialogic CG Series Media Boards

Introduction

In contrast to the Microsoft Windows version, the Dialogic® NaturalAccess™ for Linux package does not install ctdaemon into the operating system as a service. It must be started manually, with root privileges. This article describes how to implement a standard Linux boot script that starts ctdaemon during system start-up. After a soft or hard reset, no physical actions are required to bring-up the NaturalAccess software layer, leaving the platform ready to run the hosted telecom applications.

Background

Once a system is powered on, or there is a hard reset, and the OS loader has completed its task, the kernel is running on the platform. The kernel's task is to launch the first (user) process, namely /sbin/init, which, by reading the contents of the /etc/inittab file, determines which services must be brought up and run at a given run level. Since it is not convenient to manage all services using one single file, inittab specifies which directories to search for scripts that start/stop the individual services. For example, developers can view and edit the /etc/rc.sysinit and /etc/rc script files on their system in the /etc directory.

...

The /sbin/init process does not actually go through the above mentioned files, but instead uses a set of soft-links, which names the directories, and are ordered sequentially, e.g.:

Code Block
/etc/init.d/rcX.d
SYZservice_name ->../init.d/service_name
KYZservice_name ->../init.d/service_name

Where X is the run level. YZ is the launch priority of the service "service_name" at the run level X. K-files are used when a service has to be stopped, S-files when it has to be started. To determine the appropriate run level and launch sequence (with respect to other services), standard lexicographic order applies (limited to the first three letters of the file). Most Linux distribution provide a simple command-line tool, chkconfig, which among other functionalities, populates the directories /etc/init.d/rcX.d with the soft-links pointing to the single service script, in /etc/init.d/.

Procedure

The DIalogic NaturalAccess™ Software for Linux provides a sample file, /etc/init.d/nmsctdaemon, which sets the required environment variables and OS-dependent parameters to correctly start and stop ctdaemon. In order to maintain system files unmodified, it is recommended that developers make their own copy whenever they wish to add new functionalities.

...

  1. Copy the sample file below into /etc/init.d/myservicectdaemon (or any other valid name), on the local hard drive.

  2. Make it executable/read-only for everyone except root.

Code Block
chmod 755 myservicectdaemon

  1. Run chkconfig.

Code Block
chkconfig --add myservicectdaemon

  1. Verify that the new service is properly registered:

Code Block
chkconfig --list myservicectdaemon
myservicectdaemon 0:off 1: off 2: off 3: off 4: off 5:on 6: off
#

The run level is automatically configured via chkconfig, which uses the pragma contained in the myservicectdaemon file:

Code Block
# chkconfig: <runlevelsNumbers> <start priority> <shutdown priority>

or here

Code Block
# chkconfig: 5 98 02

(02 is high shutdown priority)

chkconfig will automatically create the soft-links in the corresponding /etc/rcX.d/ folders:

Code Block
in /etc/rc5.d,
S98myservicectdaemon -> ../init.d/myservicectdaemon
in /etc/rc6.d,
K02myservicectdaemon -> ../init.d/myservicectdaemon

It is worth noting that a 98 (low) priority and a run level #5 are required, so that ctdaemon is effectively started after the NaturalAccess 'nms_' scripts have loaded the board drivers:

Code Block
S96nms_naabstrct -> /etc/rc.d/init.d/nms_naabstrct
S96nms_nadriver -> /etc/rc.d/init.d/nms_nadriver
S97nms_cx2000 -> /etc/rc.d/init.d/nms_cx2000

Using this method, a Linux platform can benefit from the auto-start and auto-stop features of ctdaemon, provided the following keywords:

Code Block
AutoStart=Yes
AutoStop=Yes
 
[Supervisor]
AutoStartEnabled = Yes
AutoStopEnabled = Yes

are defined in their configuration files.

Sample Boot Script

A simple boot script was implemented to register NaturalAccess ctdaemon as a Linux service. Once copied in the /etc/init.d/ directory, and the correct soft-links are created in the /etc/rcX.d folders, the Linux boot sequence launches ctdaemon automatically at the run level #5. This method can be used to enable board auto-start on the platform, making it quickly operational to run hosted telecom applications.

The boot sequence described in this support tip applies to SYSV-R4 based systems, which currently cover most UNIX flavours. Though the chkconfig command-line tool is Linux-specific, the paths to service scripts remain unchanged. Therefore, the same method can be used, for example, on Solaris platforms.

Sample Script

Code Block
* THIS SCRIPT IS PROVIDED ON AN "AS IS" BASIS,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
* INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE
* IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE
* OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND
* PERFORMANCE OF THE COVERED CODE IS WITH YOU.
 
#!/bin/bash
#
# description: This script starts and stops ctdaemon, provided it has
# been registered as a Linux service. The file should be copied into
# /etc/init.d/myservicectdaemon,
# made executable for everyone except root,
# chmod 755 /etc/init.d/myservicectdaemon
# and the service registered by,
# chkconfig --add myservicectdaemon
#
# processname: /opt/nms/bin/ctdaemon
# chkconfig: 5 98 02
# CTACCESS environment variables
. /etc/profile.d/nms_profile.sh
# Source function library.
. /etc/init.d/functions
 
RETVAL=0
 
prog="ctdaemon"
 
start(){
echo -n $"Starting $prog... "
echo 16384 >/proc/sys/fs/file-max
ulimit -n 16384 &>/dev/null
(sleep 15; /opt/nms/bin/ctdaemon)&
touch /var/lock/subsys/nmsctdaemon
echo
}
 
stop(){
echo -n $"Stopping $prog... "
/opt/nms/bin/ctdaemon -s
/opt/nms/bin/ctdaemon -k
echo
rm -f /var/lock/subsys/nmsctdaemon
}
 
restart(){
stop
#sleep to avoid possible race conditions
sleep 3
start
}
 
# See how we were called.
# Note: the status function must be used about 10 seconds after the
# service has been launched, so that full process start is
# effectively ensured.
 
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status $prog
;;
restart)
restart
;;
*)
echo $"Usage: $0 {start|stop|status|restart}"
RETVAL=1
esac
 
exit $RETVAL