Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- login as: opensips
- opensips@192.168.32.57's password:
- Linux OpenSIPs 4.9.0-6-amd64 #1 SMP Debian 4.9.82-1+deb9u3 (2018-03-02) x86_64
- The programs included with the Debian GNU/Linux system are free software;
- the exact distribution terms for each program are described in the
- individual files in /usr/share/doc/*/copyright.
- Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
- permitted by applicable law.
- Last login: Sat Jul 4 12:54:44 2020
- opensips@OpenSIPs:~$ locate opensips.cfg
- /usr/local/share/man/man5/opensips.cfg.5
- /usr/src/opensips-3.0/opensips.cfg.5
- /usr/src/opensips-3.0/etc/opensips.cfg
- /usr/src/opensips-3.0/modules/osp/etc/sample-osp-opensips.cfg
- /usr/src/opensips-3.0/modules/sipcapture/examples/opensips.cfg
- opensips@OpenSIPs:~$ vi /etc/opensips.cfg
- opensips@OpenSIPs:~$ vi /usr/src/opensips-3.0/etc/opensips.cfg
- if (is_method("REGISTER")) {
- if (!save("location"))
- sl_reply_error();
- exit;
- }
- if ($rU==NULL) {
- # request with no Username in RURI
- send_reply(484,"Address Incomplete");
- exit;
- }
- # do lookup with method filtering
- if (!lookup("location","m")) {
- t_reply(404, "Not Found");
- exit;
- }
- # when routing via usrloc, log the missed calls also
- do_accounting("log","missed");
- route(relay);
- }
- route[relay] {
- # for INVITEs enable some additional helper routes
- if (is_method("INVITE")) {
- t_on_branch("per_branch_ops");
- t_on_reply("handle_nat");
- t_on_failure("missed_call");
- }
- if (!t_relay()) {
- send_reply(500,"Internal Error");
- }
- exit;
- }
- branch_route[per_branch_ops] {
- xlog("new branch at $ru\n");
- }
- onreply_route[handle_nat] {
- xlog("incoming reply\n");
- }
- failure_route[missed_call] {
- if (t_was_cancelled()) {
- exit;
- }
- # uncomment the following lines if you want to block client
- # redirect based on 3xx replies.
- ##if (t_check_status("3[0-9][0-9]")) {
- ##t_reply(404,"Not found");
- ## exit;
- ##}
- }
- --------------------------------------------------------------------------------------------------------------------------------------
- -------------------------------------------------------------------------------------------------------------------------------------
- --------------------------------------------------------------------------------------------------------------------------------------
- --------------------------------------------------------------------------------------------------------------------------------------
- /etc/init.d
- #!/bin/sh
- #
- ### BEGIN INIT INFO
- # Provides: opensips
- # Required-Start: $syslog $network $local_fs $time $remote_fs
- # Required-Stop: $syslog $network $local_fs $remote_fs
- # Default-Start: 2 3 4 5
- # Default-Stop: 0 1 6
- # Short-Description: Start the OpenSIPS SIP server
- # Description: Start the OpenSIPS SIP server
- ### END INIT INFO
- #
- # TODO:
- # The following fields should be added (and completed):
- # Should-Start: postgresql mysql radius
- # Should-Stop: postgresql mysql radius
- set -e
- PATH_EXTRA=
- #PATH=/sbin:/bin:/usr/sbin:/usr/bin${PATH_EXTRA:+:${PATH_EXTRA}}
- PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin
- DAEMON=/user/local/sbin/opensips
- NAME=opensips
- DESC=opensips
- CFGFILE=/usr/local/etc/opensips/opensips_trunk.cfg
- M4CFGFILE=/etc/opensips/opensips.m4
- M4ARCHIVEDIR=/etc/opensips/archive
- HOMEDIR=/var/run/opensips
- PIDFILE=$HOMEDIR/$NAME.pid
- DEFAULTS=/etc/default/opensips
- RUN_OPENSIPS=no
- [ -e "/lib/lsb/init-functions" ] && . /lib/lsb/init-functions
- test -f $DAEMON || exit 0
- # Load startup options if available
- if [ -f $DEFAULTS ]; then
- . $DEFAULTS || true
- fi
- if [ "$RUN_OPENSIPS" != "yes" ]; then
- echo "OpenSIPS not yet configured. Edit /etc/default/opensips first."
- exit 0
- fi
- check_opensips_config ()
- {
- # Check if opensips configuration is valid before starting the server
- set +e
- out=$($DAEMON -c -f $CFGFILE 2>&1 > /dev/null)
- retcode=$?
- set -e
- if [ "$retcode" != '0' ]; then
- echo "Not starting $DESC: invalid configuration file!"
- echo -e "\n$out\n"
- exit 1
- fi
- }
- create_radius_seqfile ()
- {
- # Create a radius sequence file to be used by the radius client if
- # radius accounting is enabled. This is needed to avoid any issue
- # with the file not being writable if opensips first starts as user
- # root because DUMP_CORE is enabled and creates this file as user
- # root and then later it switches back to user opensips and cannot
- # write to the file. If the file exists before opensips starts, it
- # won't change it's ownership and will be writable for both root
- # and opensips, no matter what options are chosen at install time
- RADIUS_SEQ_FILE=/var/run/opensips/opensips_radius.seq
- if [ -d /var/run/opensips ]; then
- chown ${USER}:${GROUP} /var/run/opensips
- if [ ! -f $RADIUS_SEQ_FILE ]; then
- touch $RADIUS_SEQ_FILE
- fi
- chown ${USER}:${GROUP} $RADIUS_SEQ_FILE
- chmod 660 $RADIUS_SEQ_FILE
- fi
- }
- S_MEMORY=$((`echo $S_MEMORY | sed -e 's/[^0-9]//g'`))
- P_MEMORY=$((`echo $P_MEMORY | sed -e 's/[^0-9]//g'`))
- [ -z "$USER" ] && USER=opensips
- [ -z "$GROUP" ] && GROUP=opensips
- [ $S_MEMORY -le 0 ] && S_MEMORY=32
- [ $P_MEMORY -le 0 ] && P_MEMORY=32
- if test "$DUMP_CORE" = "yes" ; then
- # set proper ulimit
- ulimit -c unlimited
- # directory for the core dump files
- # COREDIR=/home/corefiles
- # [ -d $COREDIR ] || mkdir $COREDIR
- # chmod 777 $COREDIR
- # echo "$COREDIR/core.%e.sig%s.%p" > /proc/sys/kernel/core_pattern
- fi
- OPTIONS="-P $PIDFILE -m $S_MEMORY -M $P_MEMORY -u $USER -g $GROUP -f $CFGFILE"
- case "$1" in
- start)
- check_opensips_config
- create_radius_seqfile
- # dirs under /var/run will go away on reboot.
- mkdir -p "$HOMEDIR"
- chmod 775 "$HOMEDIR"
- chown "$USER:$GROUP" "$HOMEDIR" >/dev/null 2>&1 || true
- # Generate config from M4
- if [ -f $M4CFGFILE ]; then
- m4 -Q $M4CFGFILE >$CFGFILE.tmp
- if [ $? != 0 ]; then
- echo "Cannot process m4 macro"
- rm "$CFGFILE.tmp"
- exit 1
- fi
- [ -e $CFGFILE ] || touch $CFGFILE
- # compare configs
- if [ `md5sum $CFGFILE|awk '{print $1}'` != `md5sum $CFGFILE.tmp|awk '{print $1}'` ]; then
- mkdir -p "$M4ARCHIVEDIR"
- mv "$CFGFILE" "$M4ARCHIVEDIR/$NAME.cfg-`date +%Y%m%d_%H%M%S`"
- fi
- mv "$CFGFILE.tmp" "$CFGFILE"
- chown $USER:$GROUP $CFGFILE
- chmod 640 $CFGFILE
- fi
- log_daemon_msg "Starting $DESC" "$NAME"
- start-stop-daemon --start --quiet --pidfile $PIDFILE \
- --exec $DAEMON -- $OPTIONS || echo -n " already running"
- log_end_msg $?
- ;;
- stop)
- log_daemon_msg "Stopping $DESC" "$NAME"
- start-stop-daemon --oknodo --stop --quiet --pidfile $PIDFILE \
- --exec $DAEMON
- log_end_msg $?
- ;;
- restart|force-reload)
- check_opensips_config
- create_radius_seqfile
- log_daemon_msg "Restarting $DESC" "$NAME"
- start-stop-daemon --oknodo --stop --quiet --pidfile \
- $PIDFILE --exec $DAEMON
- sleep 1
- start-stop-daemon --start --quiet --pidfile \
- $PIDFILE --exec $DAEMON -- $OPTIONS
- log_end_msg $?
- ;;
- status)
- status_of_proc -p $PIDFILE "$DAEMON" "$NAME"
- ;;
- *)
- N=/etc/init.d/$NAME
- echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
- exit 1
- ;;
- esac
- exit 0
- ____________-----
- _____________________________________________________________________________-----
- /etc/default/opensips
- #
- # OpenSIPS startup options
- #
- # Set to yes to enable opensips, once configured properly.
- RUN_OPENSIPS=yes
- # User to run as
- USER=opensips
- # Group to run as
- GROUP=opensips
- # Amount of shared memory to allocate for the running OpenSIPS server (in Mb)
- S_MEMORY=64
- # Amount of pkg memory to allocate for the running OpenSIPS server (in Mb)
- P_MEMORY=4
- # Enable the server to leave a core file when it crashes.
- # Set this to 'yes' to enable OpenSIPS to leave a core file when it crashes
- # or 'no' to disable this feature. This option is case sensitive and only
- # accepts 'yes' and 'no' and only in lowercase letters.
- # On some systems (e.g. Ubuntu 6.10, Debian 4.0) it is necessary to specify
- # a directory for the core files to get a dump. Look into the opensips
- # init file for an example configuration.
- DUMP_CORE=no
- # Any additional OpenSIPS options
- OPTIONS=""
Add Comment
Please, Sign In to add comment