sync from commercial e8f86eb921b988c0f1dc42e29ce9343749d08611

This commit is contained in:
Michael Iedema 2014-12-04 21:50:28 +01:00
parent fec84a2001
commit 81df6d7ccd
25 changed files with 491 additions and 136 deletions

40
.gitignore vendored
View File

@ -1,31 +1,41 @@
._*
*.a
*.o
*.in
*.la
*.lo
*.cgi
.deps
.libs
Makefile
Makefile.in
depcomp
install-sh
missing
aclocal.m4
autom4te.cache/
build-arch-stamp
build-indep-stamp
comp128
config.guess
config.h
config.h.in
config.log
config.status
config.sub
configure
configure-stamp
debian/debhelper.log
debian/files
debian/substvars
debian/tmp/
sipauthserve
Makefile
aclocal.m4
config.guess
config.h
config.log
config.status
config.sub
configure
depcomp
install-sh
debian/sipauthserve.debhelper.log
debian/sipauthserve.substvars
debian/sipauthserve/
config.h.in~
libtool
ltmain.sh
missing
stamp-h1
apps/comp128
apps/sipauthserve
apps/subscriberRegistry.example.sql
apps/sipauthserve.example.sql
sipauthserve.example.sql
package/tmp

@ -1 +1 @@
Subproject commit 3ad343b97b137743283194a2d55622c26c6d4800
Subproject commit 11d8baa82662c9c862aa0fe8a5c585c2eb9cfb89

View File

@ -22,4 +22,4 @@
#include "config.h"
#include <Globals.h>
const char *gVersionString = "release " VERSION "+" REPO_REV " built " TIMESTAMP_ISO " ";
const char *gVersionString = "release " VERSION " built " TIMESTAMP_ISO " " REPO_REV " ";

View File

@ -21,14 +21,10 @@
include $(top_srcdir)/Makefile.common
AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES)
AM_CXXFLAGS = -Wall
noinst_LTLIBRARIES = libglobals.la
libglobals_la_SOURCES = Globals.cpp
noinst_PROGRAMS =
noinst_HEADERS = \
Globals.h
noinst_HEADERS = Globals.h

View File

@ -21,18 +21,17 @@
include $(top_srcdir)/Makefile.common
DESTDIR :=
AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) $(WITH_INCLUDES)
AM_CXXFLAGS = -Wall -pthread -ldl
DESTDIR ?=
# must be kept in sync with AC_CONFIG_MACRO_DIR in configure.ac
ACLOCAL_AMFLAGS = -I config
noinst_LTLIBRARIES = libSR.la
libSR_la_SOURCES = \
SubscriberRegistry.cpp
SubscriberRegistry.cpp
noinst_HEADERS = \
SubscriberRegistry.h
SubscriberRegistry.h
# Order must be preserved
SUBDIRS = \
@ -42,10 +41,4 @@ SUBDIRS = \
NodeManager \
apps
install: all
$(MAKE) -C ./apps install
dox: FORCE
doxygen doxconfig
FORCE:

View File

@ -19,11 +19,13 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
CXXFLAGS := -DTIMESTAMP_ISO=`date +'"%Y-%m-%dT%H:%M:%S"'`
CFLAGS := -DTIMESTAMP_ISO=`date +'"%Y-%m-%dT%H:%M:%S"'`
# must be kept in sync with AC_CONFIG_MACRO_DIR in configure.ac
# ACLOCAL_AMFLAGS = -I config
AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) $(WITH_INCLUDES)
AM_CXXFLAGS = -Wall -pthread -ldl
AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES)
AM_CXXFLAGS := -Wall -pthread -ldl -DTIMESTAMP_ISO=`date +'"%Y-%m-%dT%H:%M:%S"'`
REPOREV = -D'REPO_REV="$(shell ./$(top_builddir)/Globals/GrabRepoInfo.sh $(top_builddir))"'
COMMON_INCLUDEDIR = $(top_srcdir)/CommonLibs
GLOBALS_INCLUDEDIR = $(top_srcdir)/Globals
@ -31,8 +33,6 @@ NODEMANAGER_INCLUDEDIR = $(top_srcdir)/NodeManager
JSONBOX_INCLUDEDIR = $(top_srcdir)/NodeManager/JsonBox-0.4.3/include
JSONDB_INCLUDEDIR = $(top_srcdir)/NodeManager/JSONDB
REPOREV = -D'REPO_REV="$(shell ./$(top_builddir)/Globals/GrabRepoInfo.sh $(top_builddir))"'
STD_DEFINES_AND_INCLUDES = \
$(REPOREV) \
-I$(COMMON_INCLUDEDIR) \

@ -1 +1 @@
Subproject commit 836ae03d868bdc09601f66fc926b7610fb1cb782
Subproject commit 7fce01fa896f84349f4fb9d5926ada4bd922f5f4

View File

@ -719,7 +719,6 @@ SubscriberRegistry::Status SubscriberRegistry::addUser(const char* IMSI, const c
}
char *SubscriberRegistry::mapCLIDGlobal(const char *local)
{
if (!local) {

View File

@ -27,31 +27,24 @@ ourlibs = \
$(COMMON_LA) \
$(NODEMANAGER_LA)
bin_PROGRAMS = sipauthserve comp128
sbin_PROGRAMS = sipauthserve comp128
bin_SCRIPTS = syslogextractor hexmapper
confdir = /etc/OpenBTS
conf_DATA = sipauthserve.example.sql
sipauthserve_SOURCES = sipauthserve.cpp ../servershare.cpp ../SubscriberRegistry.cpp \
sipauthserve_SOURCES = sipauthserve.cpp \
../servershare.cpp \
../SubscriberRegistry.cpp \
../NodeManager/JSONDB/JSONDB.cpp
sipauthserve_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES)
sipauthserve_LDADD = $(ourlibs) -losipparser2 -losip2
comp128_SOURCES = comp128.c
comp128_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES)
comp128_SOURCES = comp128.c
comp128_LDADD = $(ourlibs)
EXTRA_DIST = \
subscriberRegistry.example.sql \
sipauthserve.conf
sipauthserve.example.sql: sipauthserve
( ./sipauthserve --gensql > sipauthserve.example.sql || true )
tmp_DB = /tmp/SR.db
TESTS = checkdb.sh
CLEANFILES = $(tmp_DB)
# Populating comp128 in both locations for backwards compat
install: sipauthserve comp128
mkdir -p "$(DESTDIR)/OpenBTS/"
install comp128 "$(DESTDIR)/OpenBTS/"
install sipauthserve "$(DESTDIR)/OpenBTS/"
mkdir -p "$(DESTDIR)/usr/local/bin/"
install comp128 "$(DESTDIR)/usr/local/bin/"
install syslogextractor "$(DESTDIR)/usr/local/bin/"
install hexmapper "$(DESTDIR)/usr/local/bin/"
mkdir -p "$(DESTDIR)/etc/init/"
install sipauthserve.conf "$(DESTDIR)/etc/init/"
mkdir -p "$(DESTDIR)/etc/OpenBTS/"
install subscriberRegistry.example.sql "$(DESTDIR)/etc/OpenBTS/"

14
apps/checkdb.sh Executable file
View File

@ -0,0 +1,14 @@
#!/bin/sh
set -e
tmp_DB='/tmp/SR.db'
conf_DATA='./sipauthserve.example.sql'
if [ ! -f ${conf_DATA} ]; then
exit 1
fi
echo "* check integrity of ${conf_DATA}"
sqlite3 -bail ${tmp_DB} ".read ${conf_DATA}" > /dev/null
exit $?

View File

@ -1,20 +0,0 @@
--
-- This file was generated using: ./sipauthserve --gensql
-- binary version: release 5.0.0-prealpha+a5121d81ec CommonLibs:7e5af6cff7 built 2014-07-08T20:45:15
--
-- Future changes should not be put in this file directly but
-- rather in the program's ConfigurationKey schema.
--
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE IF NOT EXISTS CONFIG ( KEYSTRING TEXT UNIQUE NOT NULL, VALUESTRING TEXT, STATIC INTEGER DEFAULT 0, OPTIONAL INTEGER DEFAULT 0, COMMENTS TEXT DEFAULT '');
INSERT OR IGNORE INTO "CONFIG" VALUES('Control.NumSQLTries','3',0,0,'Number of times to retry SQL queries before declaring a database access failure.');
INSERT OR IGNORE INTO "CONFIG" VALUES('Log.Alarms.Max','20',0,0,'Maximum number of alarms to remember inside the application.');
INSERT OR IGNORE INTO "CONFIG" VALUES('Log.File','',0,0,'Path to use for textfile based logging. By default, this feature is disabled. To enable, specify an absolute path to the file you wish to use, eg: /tmp/my-debug.log. To disable again, execute "unconfig Log.File".');
INSERT OR IGNORE INTO "CONFIG" VALUES('Log.Level','NOTICE',0,0,'Default logging level when no other level is defined for a file.');
INSERT OR IGNORE INTO "CONFIG" VALUES('SubscriberRegistry.A3A8','/OpenBTS/comp128',0,0,'Path to the program that implements the A3/A8 algorithm.');
INSERT OR IGNORE INTO "CONFIG" VALUES('SubscriberRegistry.Port','5064',0,0,'Port used by the SIP Authentication Server.');
INSERT OR IGNORE INTO "CONFIG" VALUES('SubscriberRegistry.db','/var/lib/asterisk/sqlite3dir/sqlite3.db',0,0,'The location of the sqlite3 database holding the subscriber registry.');
COMMIT;

View File

@ -19,17 +19,18 @@ dnl You should have received a copy of the GNU General Public License
dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
dnl
AC_INIT(subscriberregistry,5.0.0-prealpha)
AC_PREREQ(2.57)
AC_CONFIG_SRCDIR([config/Makefile.am])
AC_CONFIG_AUX_DIR([.])
AM_CONFIG_HEADER(config.h)
AC_INIT(sipauthserve,5.0-master)
AC_CANONICAL_BUILD
AC_CANONICAL_HOST
AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE
AC_CONFIG_AUX_DIR([.])
AM_INIT_AUTOMAKE([-Wno-portability])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([config])
AC_CONFIG_SRCDIR([SubscriberRegistry.cpp])
AM_PROG_AS
AC_PROG_CXX

4
debian/changelog vendored
View File

@ -1,5 +1,5 @@
sipauthserve (5.0) unstable; urgency=low
sipauthserve (5.0-master) unstable; urgency=low
* Test
-- Donald C. Kirker <donald.kirker@rangenetworks.com> Mon, 22 Apr 2013 00:11:00 -0700
-- Range Packager <buildmeister@rangenetworks.com> Thu, 25 Sep 2014 00:17:42 -0700

1
debian/compat vendored Normal file
View File

@ -0,0 +1 @@
7

3
debian/dirs vendored Normal file
View File

@ -0,0 +1,3 @@
var/lib/asterisk/sqlite3dir
etc/OpenBTS
OpenBTS

2
debian/links vendored Normal file
View File

@ -0,0 +1,2 @@
usr/local/sbin/comp128 OpenBTS/comp128
usr/local/sbin/sipauthserve OpenBTS/sipauthserve

32
debian/postinst vendored
View File

@ -19,29 +19,22 @@ set -e
configure()
{
WEBUSER=www-data
DATE=$(date --rfc-3339='date')
CONFIG_BACKUP=/etc/OpenBTS/OpenBTS.dump-$DATE
CONFIG_BACKUP=/etc/OpenBTS/sipauthserve.dump-$DATE
if [ ! -e $CONFIG_BACKUP ]; then
sqlite3 /etc/OpenBTS/OpenBTS.db ".dump" > $CONFIG_BACKUP
sqlite3 /etc/OpenBTS/sipauthserve.db ".dump" > $CONFIG_BACKUP
fi
sqlite3 /etc/OpenBTS/OpenBTS.db ".read /etc/OpenBTS/subscriberRegistry.example.sql" > /dev/null 2>&1
if [ ! -d /var/lib/asterisk/sqlite3dir ]; then
mkdir -p /var/lib/asterisk/sqlite3dir
fi
sqlite3 /etc/OpenBTS/sipauthserve.db ".read /etc/OpenBTS/sipauthserve.example.sql" > /dev/null 2>&1
SRPATH=/var/lib/asterisk/sqlite3dir/sqlite3.db
DATE=$(date --rfc-3339='date')
SR_CONFIG_BACKUP=$SRPATH.dump-$DATE
SR_BACKUP=$SRPATH.dump-$DATE
if [[ -e $SRPATH && "`sqlite3 $SRPATH "PRAGMA table_info(sip_buddies)" || true`" != "" ]]; then
if [ ! -e $SR_CONFIG_BACKUP ]; then
sqlite3 $SRPATH ".dump" > $SR_CONFIG_BACKUP
if [ ! -e $SR_BACKUP ]; then
sqlite3 $SRPATH ".dump" > $SR_BACKUP
fi
HASPREPAID=`sqlite3 $SRPATH "PRAGMA table_info(sip_buddies)" | grep prepaid || true`
@ -61,15 +54,10 @@ if [[ -e $SRPATH && "`sqlite3 $SRPATH "PRAGMA table_info(sip_buddies)" || true`"
sqlite3 $SRPATH "insert or ignore into 'rates' values ('out-of-network-call', 1)"
fi
# set up permissions for webui, temporary fix until ui is replumbed to use json
# directory permissions
chown -R root:www-data /var/lib/asterisk/sqlite3dir
chmod 775 /var/lib/asterisk/sqlite3dir/
if [ -e /var/lib/asterisk/sqlite3dir/sqlite3.db ]; then
chmod 664 /var/lib/asterisk/sqlite3dir/sqlite3*
fi
chown -R root:${WEBUSER} /var/lib/asterisk/sqlite3dir
chmod -R ug+rw /var/lib/asterisk/sqlite3dir/
chmod -R o-w /var/lib/asterisk/sqlite3dir/
}
case "$1" in

9
debian/prerm vendored
View File

@ -16,14 +16,11 @@ set -e
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package
# remove()
# {
# killall runloop.sipauthserve.sh &>/dev/null
# }
case "$1" in
remove|upgrade|deconfigure)
# remove
set +e
stop sipauthserve
set -e
;;
failed-upgrade)

33
debian/rules vendored
View File

@ -11,7 +11,7 @@
# build-arch and build-indep targets by Bill Allombert 2001
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
export DH_VERBOSE=0
# Never distribute source control meta information
export DH_ALWAYS_EXCLUDE=.svn:.git
@ -20,44 +20,41 @@ export DH_ALWAYS_EXCLUDE=.svn:.git
export DH_OPTIONS
configure:
./autogen.sh
./autogen.sh # --verbose
config: configure-stamp
configure-stamp: configure
dh_testdir
# Add here commands to configure the package.
autoreconf -i
./configure $(confflags)
touch configure-stamp
#Architecture
build: build-arch build-indep
build: config build-arch build-indep
build-arch: build-arch-stamp
build-arch-stamp: configure-stamp
build-arch-stamp:
# Add here commands to compile the arch part of the package.
#$(MAKE)
touch $@
build-indep: build-indep-stamp
build-indep-stamp: configure-stamp
build-indep-stamp:
# Add here commands to compile the indep part of the package.
#$(MAKE) doc
touch $@
clean: config
clean:
dh_testdir
dh_testroot
rm -f build-arch-stamp build-indep-stamp configure-stamp
# Add here commands to clean up after the build process.
$(MAKE) clean
# dh_clean deletes toplevel *-stamp files
dh_clean
install: install-indep install-arch
install: install-arch install-indep
install-indep:
dh_testdir
dh_testroot
@ -67,7 +64,7 @@ install-indep:
# Add here commands to install the indep part of the package into
# debian/<package>-doc.
#INSTALLDOC#
# $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
dh_auto_test # runs 'make check'
dh_install -i
install-arch:
@ -77,8 +74,8 @@ install-arch:
dh_installdirs -s
# Add here commands to install the arch part of the package into
# debian/tmp.
$(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
# debian/{package}.
$(MAKE) DESTDIR=$(CURDIR)/debian/sipauthserve install
dh_install -s
@ -89,7 +86,7 @@ binary-common:
dh_testdir
dh_testroot
# dh_installchangelogs ChangeLog
dh_installdocs
# dh_installdocs
# dh_installexamples
# dh_installmenu
# dh_installdebconf
@ -98,7 +95,7 @@ binary-common:
# dh_installpam
# dh_installmime
# dh_python
dh_installinit
dh_installinit --upstart-only --noscripts
# dh_installcron
# dh_installinfo
dh_installman
@ -121,6 +118,6 @@ binary-indep: build-indep install-indep
binary-arch: build-arch install-arch
$(MAKE) -f debian/rules DH_OPTIONS=-s binary-common
binary: binary-arch binary-indep
.PHONY: build clean binary-indep binary-arch binary install install-indep install-arch config
binary: config binary-arch binary-indep
.PHONY: build clean binary-indep binary-arch binary install install-indep install-arch config

82
package/after-install-deb.sh Executable file
View File

@ -0,0 +1,82 @@
#!/bin/bash
# Copyright 2014 Range Networks, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set -e
WEBGROUP=www-data
CONFIG_DB='/etc/OpenBTS/sipauthserve.db'
SR_PATH='/var/lib/asterisk/sqlite3dir'
SR_DB='sqlite3.db'
DATE=$(date +'%Y-%m-%dT%H-%M') # was $(date --rfc-3339='date')
backup()
{
CONFIG_BACKUP="/etc/OpenBTS/sipauthserve.sql-${DATE}"
if [ -f ${CONFIG_DB} ] && [ ! -e ${CONFIG_BACKUP} ]; then
echo "backing up SAS configuration DB..."
sqlite3 ${CONFIG_DB} ".dump" > ${CONFIG_BACKUP}
echo "done"
fi
SR_BACKUP="sqlite3.sql-${DATE}"
if [ -f ${SR_PATH}/${SR_DB} ] && [ ! -e ${SR_BACKUP} ]; then
echo "backing up Subscriber Registry DB..."
sqlite3 ${SR_PATH}/${SR_DB} ".dump" > ${SR_PATH}/${SR_BACKUP}
echo "done"
fi
}
updatedb() {
HASPREPAID=`sqlite3 ${SR_PATH}/${SR_DB} "PRAGMA table_info(sip_buddies)" | grep prepaid || true`
if [ "$HASPREPAID" = "" ]; then
sqlite3 ${SR_PATH}/${SR_DB} "alter table sip_buddies add prepaid int(1) DEFAULT 0 not null"
fi
HASBALANCE=`sqlite3 ${SR_PATH}/${SR_DB} "PRAGMA table_info(sip_buddies)" | grep account_balance || true`
if [ "$HASBALANCE" = "" ]; then
sqlite3 ${SR_PATH}/${SR_DB} "alter table sip_buddies add column account_balance int(9) default 0"
fi
sqlite3 ${SR_PATH}/${SR_DB} "create table if not exists rates (service varchar(30) unique not null, rate integer not null)"
sqlite3 ${SR_PATH}/${SR_DB} "insert or ignore into 'rates' values ('in-network-SMS', 10)"
sqlite3 ${SR_PATH}/${SR_DB} "insert or ignore into 'rates' values ('out-of-network-SMS', 20)"
sqlite3 ${SR_PATH}/${SR_DB} "insert or ignore into 'rates' values ('in-network-call', 1)"
sqlite3 ${SR_PATH}/${SR_DB} "insert or ignore into 'rates' values ('out-of-network-call', 1)"
}
config() {
# setup configuration db
sqlite3 ${CONFIG_DB} ".read /etc/OpenBTS/sipauthserve.example.sql" > /dev/null 2>&1
set +e
if [ -e ${SR_PATH}/${SR_DB} ]; then
if [ "$(sqlite3 ${SR_PATH}/${SR_DB} '.tables sip_buddies' | wc -l)" = "1" ]; then
updatedb
else
echo "Unknown Subscriber Registry database format, exiting..."
exit 1
fi
fi
set -e
chown -R asterisk:${WEBGROUP} ${SR_PATH}
chmod -R ug+rw ${SR_PATH}
chmod -R o-w ${SR_PATH}
}
backup
config

82
package/after-install-rpm.sh Executable file
View File

@ -0,0 +1,82 @@
#!/bin/bash
# Copyright 2014 Range Networks, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set -e
WEBGROUP=apache
CONFIG_DB='/etc/OpenBTS/sipauthserve.db'
SR_PATH='/var/lib/asterisk/sqlite3dir'
SR_DB='sqlite3.db'
DATE=$(date +'%Y-%m-%dT%H-%M') # was $(date --rfc-3339='date')
backup()
{
CONFIG_BACKUP="/etc/OpenBTS/sipauthserve.sql-${DATE}"
if [ -f ${CONFIG_DB} ] && [ ! -e ${CONFIG_BACKUP} ]; then
echo "backing up SAS configuration DB..."
sqlite3 ${CONFIG_DB} ".dump" > ${CONFIG_BACKUP}
echo "done"
fi
SR_BACKUP="sqlite3.sql-${DATE}"
if [ -f ${SR_PATH}/${SR_DB} ] && [ ! -e ${SR_BACKUP} ]; then
echo "backing up Subscriber Registry DB..."
sqlite3 ${SR_PATH}/${SR_DB} ".dump" > ${SR_PATH}/${SR_BACKUP}
echo "done"
fi
}
updatedb() {
HASPREPAID=`sqlite3 ${SR_PATH}/${SR_DB} "PRAGMA table_info(sip_buddies)" | grep prepaid || true`
if [ "$HASPREPAID" = "" ]; then
sqlite3 ${SR_PATH}/${SR_DB} "alter table sip_buddies add prepaid int(1) DEFAULT 0 not null"
fi
HASBALANCE=`sqlite3 ${SR_PATH}/${SR_DB} "PRAGMA table_info(sip_buddies)" | grep account_balance || true`
if [ "$HASBALANCE" = "" ]; then
sqlite3 ${SR_PATH}/${SR_DB} "alter table sip_buddies add column account_balance int(9) default 0"
fi
sqlite3 ${SR_PATH}/${SR_DB} "create table if not exists rates (service varchar(30) unique not null, rate integer not null)"
sqlite3 ${SR_PATH}/${SR_DB} "insert or ignore into 'rates' values ('in-network-SMS', 10)"
sqlite3 ${SR_PATH}/${SR_DB} "insert or ignore into 'rates' values ('out-of-network-SMS', 20)"
sqlite3 ${SR_PATH}/${SR_DB} "insert or ignore into 'rates' values ('in-network-call', 1)"
sqlite3 ${SR_PATH}/${SR_DB} "insert or ignore into 'rates' values ('out-of-network-call', 1)"
}
config() {
# setup configuration db
sqlite3 ${CONFIG_DB} ".read /etc/OpenBTS/sipauthserve.example.sql" > /dev/null 2>&1
set +e
if [ -e ${SR_PATH}/${SR_DB} ]; then
if [ "$(sqlite3 ${SR_PATH}/${SR_DB} '.tables sip_buddies' | wc -l)" = "1" ]; then
updatedb
else
echo "Unknown Subscriber Registry database format, exiting..."
exit 1
fi
fi
set -e
chown -R asterisk:${WEBGROUP} ${SR_PATH}
chmod -R ug+rw ${SR_PATH}
chmod -R o-w ${SR_PATH}
}
backup
config

189
package/build.sh Executable file
View File

@ -0,0 +1,189 @@
#!/bin/bash
# Copyright 2014 Range Networks, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# use this script to build Debian or RPM packages using fpm
set -e
BUILDVERSION='5.1-master'
RPMBUILDVERSION='5.1_master'
BUILDITERATION=1
function usage() {
echo "# usage: $0 [destination]"
echo " where destination = folder where the package will be saved"
exit 1
}
function get_linux_flavor() {
if [ -f /etc/os-release ] && grep "ID=ubuntu" /etc/os-release &> /dev/null ; then
OS_FLAVOR='ubuntu'
OS_VERSION=`lsb_release -r -s`
fi
if [ -f /etc/centos-release ]; then
OS_FLAVOR='centos'
OS_VERSION=`cat /etc/centos-release | sed 's/^.* release //g' | sed 's/(.*$//g'`
fi
OS_MAJOR=`echo $OS_VERSION | cut -d '.' -f 1`
OS_ARCH=`arch`
}
echo == Building SIPAuthServe package
srcrepodir='COMMERCIAL-subscriberRegistry'
builddir='package/tmp'
here=`pwd`
dirname=`basename ${here}`
# place the resulting package in $packagedir (or simply one folder up if not specified)
if [ -z "$1" ]; then
packagedir='..'
elif [ "$1" == "--help" ]; then
usage
else
packagedir=$1
if [ ! -d "$packagedir" ]; then
echo " $packagedir is not a valid directory. Exiting..."
exit 1
fi
fi
if [ x$dirname != x$srcrepodir ]; then
echo "cd to $srcrepodir and try again. Exiting..."
exit 1
fi
echo " # checking your OS flavor:"
get_linux_flavor
case "${OS_FLAVOR}" in
ubuntu) echo " * It is Ubuntu ${OS_VERSION}, ${OS_ARCH}, we are building a Debian package"
;;
centos) echo " * It is CentOS ${OS_VERSION}, ${OS_ARCH}, we are building an RPM package"
;;
*) echo "!! Unsupported OS, exiting..."
exit 1
;;
esac
echo
echo " # making a home for this build in ${here}/${builddir}:"
rm -rf ${builddir}
mkdir -p ${builddir}/build
mkdir -p ${builddir}/package
cp package/*.sh ${builddir}/package/
cp package/inputs ${builddir}/package/
case "${OS_FLAVOR}" in
ubuntu) mkdir ${builddir}/deb
;;
centos) mkdir ${builddir}/rpm
;;
*) exit 1
;;
esac
echo
echo " # building the component:"
./autogen.sh
./configure
make clean
make
make check
make install DESTDIR=${here}/${builddir}/build
cd ${builddir}/build
mkdir -p var/lib/asterisk/sqlite3dir
mkdir -p OpenBTS
cd OpenBTS
ln -s ../usr/local/sbin/comp128
ln -s ../usr/local/sbin/sipauthserve
cd ${here}
echo
echo " # creating a package:"
BUILDREPOREV=`git rev-parse --short=10 HEAD`
case "${OS_FLAVOR}" in
ubuntu) fpm -s dir -t deb -n sipauthserve -C ${builddir}/build \
-p ${packagedir}/sipauthserve_VERSION-sha1.${BUILDREPOREV}_ARCH.deb \
--description 'Range Networks - SIP Authorization Server' \
--version ${BUILDVERSION} \
--iteration ${BUILDITERATION} \
--deb-ignore-iteration-in-dependencies \
--category 'comm' \
--license 'AGPLv3' \
--vendor 'Range Packager <buildmeister@rangenetworks.com>' \
--maintainer 'Range Packager <buildmeister@rangenetworks.com>' \
--url 'http://www.rangenetworks.com' \
-d 'sqlite3' -d 'libosip2-dev' -d 'libc6' -d 'libzmq3' \
--deb-build-depends 'build-essential, debhelper (>= 7), libtool, autoconf, pkg-config, libsqlite3-dev, libzmq3-dev' \
--after-install package/after-install-deb.sh \
--pre-uninstall package/pre-uninstall.sh \
--directories 'var/lib/asterisk/sqlite3dir OpenBTS' \
--deb-upstart ${here}/debian/sipauthserve.upstart \
--deb-priority 'optional' \
--workdir ${here}/${builddir}/deb \
--inputs package/inputs
# --verbose
;;
centos)
# place the upstart script manually
mkdir -p ${builddir}/build/etc/init
cp ${here}/debian/sipauthserve.upstart ${builddir}/build/etc/init/sipauthserve.conf
# (oley) do not create a symlink in init.d; this is not a common practice on CentOS 6.5
# mkdir -p ${builddir}/build/etc/init.d
# cd ${builddir}/build/etc/init.d
# ln -s /lib/init/upstart-job sipauthserve
# cd ${here}
# Bump up the iteration if necessary
while [ -f "${packagedir}/sipauthserve_${RPMBUILDVERSION}-sha1.${BUILDREPOREV}-${BUILDITERATION}.${OS_ARCH}.rpm" ]; do
BUILDITERATION=$((BUILDITERATION + 1))
done
echo "New build iteration: ${BUILDITERATION}"
fpm -s dir -t rpm -n sipauthserve -C ${builddir}/build \
-p ${packagedir}/sipauthserve_VERSION-sha1.${BUILDREPOREV}-${BUILDITERATION}.ARCH.rpm \
--description 'Range Networks - SIP Authorization Server' \
--version ${BUILDVERSION} \
--iteration ${BUILDITERATION} \
--rpm-ignore-iteration-in-dependencies \
--category 'comm' \
--license 'AGPLv3' \
--vendor 'Range Packager <buildmeister@rangenetworks.com>' \
--maintainer 'Range Packager <buildmeister@rangenetworks.com>' \
--url 'http://www.rangenetworks.com' \
-d 'sqlite' -d 'libosip2' -d 'glibc' -d 'zeromq' \
-d 'rpm-build' -d 'redhat-rpm-config' -d 'libtool' -d 'autoconf' -d 'pkgconfig' -d 'sqlite-devel >= 3' -d 'libosip2-devel' -d 'zeromq-devel' \
--after-install package/after-install-rpm.sh \
--pre-uninstall package/pre-uninstall.sh \
--directories 'var/lib/asterisk/sqlite3dir OpenBTS' \
--no-rpm-sign \
--workdir ${here}/${builddir}/rpm \
--inputs package/inputs \
etc/init/sipauthserve.conf
# etc/init.d/sipauthserve
# --verbose \
;;
*)
;;
esac
echo
# echo " # cleaning up:"
# make clean
# echo
echo "== All done."

8
package/inputs Normal file
View File

@ -0,0 +1,8 @@
usr/local/bin/hexmapper
usr/local/bin/syslogextractor
usr/local/sbin/comp128
usr/local/sbin/sipauthserve
etc/OpenBTS/sipauthserve.example.sql
OpenBTS/comp128
OpenBTS/sipauthserve
var/lib/asterisk/sqlite3dir

20
package/pre-uninstall.sh Executable file
View File

@ -0,0 +1,20 @@
#!/bin/bash
# Copyright 2014 Range Networks, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set +e
stop sipauthserve
set -e