diff --git a/data/daemontools/run b/data/daemontools/run index 64a81b844..a8f8f6639 100755 --- a/data/daemontools/run +++ b/data/daemontools/run @@ -1,4 +1,4 @@ #!/bin/sh -echo Running CGRateS engine -exec /usr/bin/cgr-engine -config /etc/cgrates/cgrates.cfg +echo Firing up CGRateS engine +exec setuidgid cgrates /usr/bin/cgr-engine -config /etc/cgrates/cgrates.cfg diff --git a/data/pkg/debian/cgrates.apt.list b/data/pkg/debian/cgrates.apt.list deleted file mode 100644 index 2e8c3240e..000000000 --- a/data/pkg/debian/cgrates.apt.list +++ /dev/null @@ -1,7 +0,0 @@ -## CGRateS official APT repository. -# Place this source file into your /etc/apt/sources.list.d/ folder and execute commands from bellow -# wget -O - http://apt.itsyscom.com/repos/apt/conf/cgrates.gpg.key|apt-key add - -# apt-get update && apt-get install cgrates -deb http://apt.itsyscom.com/repos/apt/debian wheezy main -deb http://apt.itsyscom.com/repos/apt/debian squeeze main - diff --git a/data/pkg/pkg_cgrates_deb.sh b/data/pkg/pkg_cgrates_deb.sh deleted file mode 100755 index 71aac74cb..000000000 --- a/data/pkg/pkg_cgrates_deb.sh +++ /dev/null @@ -1,26 +0,0 @@ -#! /usr/bin/env sh - -if [ -z "$1" ] -then - echo "" - echo "Package version not provided, exiting ..." - echo "" - exit 0 -fi - -PKG_DIR=/tmp/cgrates_$1 -rm -rf $PKG_DIR -cp -r skel $PKG_DIR -chmod -R a-s $PKG_DIR/DEBIAN/ -mkdir -p $PKG_DIR/etc/cgrates -cp ../conf/cgrates.cfg $PKG_DIR/etc/cgrates/cgrates.cfg -mkdir -p $PKG_DIR/usr/share/cgrates -cp -r ../../data/ $PKG_DIR/usr/share/cgrates/ -mkdir -p $PKG_DIR/usr/bin -cp /usr/local/goapps/bin/cgr-* $PKG_DIR/usr/bin/ -mkdir -p $PKG_DIR/var/log/cgrates/cdr/cdrc/in -mkdir -p $PKG_DIR/var/log/cgrates/cdr/cdrc/out -mkdir -p $PKG_DIR/var/log/cgrates/cdr/cdrexport/csv -mkdir -p $PKG_DIR/var/log/cgrates/history -dpkg-deb --build $PKG_DIR - diff --git a/data/pkg/skel/DEBIAN/control b/data/pkg/skel/DEBIAN/control deleted file mode 100644 index 1506c59b4..000000000 --- a/data/pkg/skel/DEBIAN/control +++ /dev/null @@ -1,10 +0,0 @@ -Package: cgrates -Version: 0.9.1-rc3 -Section: base -Priority: optional -Architecture: amd64 -Depends: daemontools, daemontools-run, git -Maintainer: DanB -Description: Carrier Grade Rating System - CGRateS is a very fast and easy scalable rating engine for Telecom environments. - diff --git a/data/pkg/skel/etc/service/cgrates/run b/data/pkg/skel/etc/service/cgrates/run deleted file mode 100755 index a8f8f6639..000000000 --- a/data/pkg/skel/etc/service/cgrates/run +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -echo Firing up CGRateS engine -exec setuidgid cgrates /usr/bin/cgr-engine -config /etc/cgrates/cgrates.cfg - diff --git a/mediator/mediator.go b/mediator/mediator.go index 536a6e4fe..bee664665 100644 --- a/mediator/mediator.go +++ b/mediator/mediator.go @@ -129,12 +129,12 @@ func (self *Mediator) rateCDR(cdr *utils.RatedCDR) error { // Forks original CDR based on original request plus runIds for extra mediation func (self *Mediator) MediateRawCDR(dbcdr utils.RawCDR) error { - engine.Logger.Info(fmt.Sprintf("Mediating rawCdr: %v, duration: %d",dbcdr, dbcdr.GetDuration())) + //engine.Logger.Debug(fmt.Sprintf("Mediating rawCdr: %v, duration: %d",dbcdr, dbcdr.GetDuration())) rtCdr, err := utils.NewRatedCDRFromRawCDR(dbcdr) if err != nil { return err } - engine.Logger.Info(fmt.Sprintf("Have converted raw into rated: %v", rtCdr)) + //engine.Logger.Debug(fmt.Sprintf("Have converted raw into rated: %v", rtCdr)) cdrs := []*utils.RatedCDR{rtCdr} // Start with initial dbcdr, will add here all to be mediated for runIdx, runId := range self.cgrCfg.MediatorRunIds { forkedCdr, err := dbcdr.AsRatedCdr(self.cgrCfg.MediatorRunIds[runIdx], self.cgrCfg.MediatorReqTypeFields[runIdx], self.cgrCfg.MediatorDirectionFields[runIdx], diff --git a/pkg/debian/cgrates.default b/pkg/debian/cgrates.default new file mode 100644 index 000000000..a7d49cbce --- /dev/null +++ b/pkg/debian/cgrates.default @@ -0,0 +1,17 @@ +# defaults file for CGRateS real-time charging system + +# start CGRateS init.d script? +# starts with "true" +ENABLE=false + +# Start with specific user/group +USER=cgrates +GROUP=cgrates + +# what extra options to give cgrates binary? +# See cgr-engine -h for options +ENGINE_OPTS='' + +# Don't forget to create an appropriate config file, +# else the CGRateS system will not start. + diff --git a/pkg/debian/cgrates.init b/pkg/debian/cgrates.init new file mode 100644 index 000000000..0c0834c81 --- /dev/null +++ b/pkg/debian/cgrates.init @@ -0,0 +1,161 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: cgrates +# Required-Start: $remote_fs $syslog +# Required-Stop: $remote_fs $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: CGRateS real-time charging system +# Description: Control CGRateS - carrier grade real-time charging system +### END INIT INFO + +# Author: DanB +# +# Do NOT "set -e" + +# PATH should only include /usr/* if it runs after the mountnfs.sh script +PATH=/sbin:/usr/sbin:/bin:/usr/bin +DESC="CGRateS real-time charging system" +NAME=cgrates +DAEMON=/usr/bin/cgr-engine +USER=cgrates +GROUP=cgrates +ENGINE_OPTS="" +PIDFILE=/var/run/$NAME/cgr-engine.pid +SCRIPTNAME=/etc/init.d/$NAME +DEFAULTS=/etc/default/$NAME +ENABLE=false + +# Exit if the package is not installed +[ -x "$DAEMON" ] || exit 0 + +# Read configuration variable file if it is present +[ -r $DEFAULTS ] && . $DEFAULTS + +# Load the VERBOSE setting and other rcS variables +. /lib/init/vars.sh + +# Define LSB log_* functions. +# Depend on lsb-base (>= 3.2-14) to ensure that this file is present +# and status_of_proc is working. +. /lib/lsb/init-functions + +if [ "$ENABLE" != "true" ]; then + echo "$DESC not yet configured. Edit $DEFAULTS first." + exit 0 +fi + + +# +# Function that starts the daemon/service +# +do_start() +{ + # Return + # 0 if daemon has been started + # 1 if daemon was already running + # 2 if daemon could not be started + start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \ + || return 1 + start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile --exec $DAEMON --chuid $USER:$GROUP --background -- \ + $ENGINE_OPTS \ + || return 2 +} + +# +# Function that stops the daemon/service +# +do_stop() +{ + # Return + # 0 if daemon has been stopped + # 1 if daemon was already stopped + # 2 if daemon could not be stopped + # other if a failure occurred + start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME + RETVAL="$?" + [ "$RETVAL" = 2 ] && return 2 + # Wait for children to finish too if this is a daemon that forks + # and if the daemon is only ever run from this initscript. + # If the above conditions are not satisfied then add some other code + # that waits for the process to drop all resources that could be + # needed by services started subsequently. A last resort is to + # sleep for some time. + start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON + [ "$?" = 2 ] && return 2 + # Many daemons don't delete their pidfiles when they exit. + rm -f $PIDFILE + return "$RETVAL" +} + +# +# Function that sends a SIGHUP to the daemon/service +# +do_reload() { + # + # If the daemon can reload its configuration without + # restarting (for example, when it is sent a SIGHUP), + # then implement that here. + # + start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME + return 0 +} + +case "$1" in + start) + [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" + do_start + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + stop) + [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" + do_stop + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + status) + status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $? + ;; + #reload|force-reload) + # + # If do_reload() is not implemented then leave this commented out + # and leave 'force-reload' as an alias for 'restart'. + # + #log_daemon_msg "Reloading $DESC" "$NAME" + #do_reload + #log_end_msg $? + #;; + restart|force-reload) + # + # If the "reload" option is implemented then remove the + # 'force-reload' alias + # + log_daemon_msg "Restarting $DESC" "$NAME" + do_stop + case "$?" in + 0|1) + do_start + case "$?" in + 0) log_end_msg 0 ;; + 1) log_end_msg 1 ;; # Old process is still running + *) log_end_msg 1 ;; # Failed to start + esac + ;; + *) + # Failed to stop + log_end_msg 1 + ;; + esac + ;; + *) + echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 + exit 3 + ;; +esac + +: diff --git a/pkg/debian/changelog b/pkg/debian/changelog new file mode 100644 index 000000000..04d97cc8f --- /dev/null +++ b/pkg/debian/changelog @@ -0,0 +1,5 @@ +cgrates (0.9.1-rc3) UNRELEASED; urgency=low + + * RC3. + + -- DanB Fri, 03 Jan 2014 17:37:31 +0100 diff --git a/pkg/debian/compat b/pkg/debian/compat new file mode 100644 index 000000000..7f8f011eb --- /dev/null +++ b/pkg/debian/compat @@ -0,0 +1 @@ +7 diff --git a/pkg/debian/control b/pkg/debian/control new file mode 100644 index 000000000..d661ff676 --- /dev/null +++ b/pkg/debian/control @@ -0,0 +1,14 @@ +Source: cgrates +Section: base +Priority: optional +Maintainer: DanB +Build-Depends: debhelper, git +Standards-Version: 3.9.1 +Homepage: http://cgrates.org + +Package: cgrates +Architecture: amd64 +Suggests: git, redis-server, mysql-server +Version: 0.9.1-rc3 +Description: Carrier Grade Real-time Charging System + CGRateS is a very fast and easy scalable real-time charging system for Telecom environments. diff --git a/pkg/debian/copyright b/pkg/debian/copyright new file mode 100644 index 000000000..7d1076f61 --- /dev/null +++ b/pkg/debian/copyright @@ -0,0 +1,12 @@ +Original packaging work by: + Gustavo Niemeyer on Wed, 02 Feb 2011 11:38:38 -0200 + +Downloaded from: + http://launchpad.net/lbox + +The Debian packaging is: + Copyright (C) 2011 Canonical Ltd. + +Further development: + Copyright (C) 2014 ITsysCOM + diff --git a/pkg/debian/docs b/pkg/debian/docs new file mode 100644 index 000000000..e69de29bb diff --git a/data/pkg/skel/DEBIAN/postinst b/pkg/debian/postinst similarity index 100% rename from data/pkg/skel/DEBIAN/postinst rename to pkg/debian/postinst diff --git a/pkg/debian/rules b/pkg/debian/rules new file mode 100755 index 000000000..889fbd6cb --- /dev/null +++ b/pkg/debian/rules @@ -0,0 +1,45 @@ +#!/usr/bin/make -f +# -*- makefile -*- + +# Uncomment this to turn on verbose mode. +export DH_VERBOSE=1 + +export GOPATH=$(CURDIR) + +PKGDIR=debian/cgrates +SRCDIR=src/github.com/cgrates/cgrates + +%: + dh $@ + +clean: + dh_clean + rm -rf $(GOPATH)/bin/* $(GOPATH)/pkg/* + #cd $(GOPATH)/src && find * -name '*.go' -exec dirname {} \; | xargs -n1 go clean + rm -f $(GOPATH)/goinstall.log + +binary-arch: clean + dh_prep + dh_installdirs + exec $(SRCDIR)/update_external_libs.sh + cd $(SRCDIR) && go install + mkdir -p $(PKGDIR)/usr/bin + cp $(GOPATH)/bin/cgr-* $(PKGDIR)/usr/bin/ + mkdir -p $(PKGDIR)/etc/cgrates + cp $(SRCDIR)/data/conf/cgrates.cfg $(PKGDIR)/etc/cgrates/ + mkdir -p $(PKGDIR)/usr/share/cgrates + cp -r $(SRCDIR)/data/* $(PKGDIR)/usr/share/cgrates/ + mkdir -p $(PKGDIR)/var/log/cgrates/cdr/cdrc/in + mkdir -p $(PKGDIR)/var/log/cgrates/cdr/cdrc/out + mkdir -p $(PKGDIR)/var/log/cgrates/cdr/cdrexport/csv + mkdir -p $(PKGDIR)/var/log/cgrates/history + dh_strip + dh_compress + dh_fixperms + dh_installinit + dh_installdeb + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-arch diff --git a/pkg/debian/source/format b/pkg/debian/source/format new file mode 100644 index 000000000..89ae9db8f --- /dev/null +++ b/pkg/debian/source/format @@ -0,0 +1 @@ +3.0 (native) diff --git a/pkg/debian/source/options b/pkg/debian/source/options new file mode 100644 index 000000000..38bb1abc2 --- /dev/null +++ b/pkg/debian/source/options @@ -0,0 +1,5 @@ +tar-ignore = .hg +tar-ignore = .git +tar-ignore = .bzr +tar-ignore = .gitignore +tar-ignore = .travis.yml diff --git a/pkg/pkg_cgrates_deb.sh b/pkg/pkg_cgrates_deb.sh new file mode 100755 index 000000000..7cd21679c --- /dev/null +++ b/pkg/pkg_cgrates_deb.sh @@ -0,0 +1,18 @@ +#! /usr/bin/env sh + +if [ -z "$1" ] +then + echo "" + echo "Package version not provided, exiting ..." + echo "" + exit 0 +fi + +WORK_DIR=/tmp/cgrates_$1 +rm -rf $WORK_DIR +mkdir -p $WORK_DIR +cp -r debian $WORK_DIR/debian +cd $WORK_DIR +git clone https://github.com/cgrates/cgrates.git src/github.com/cgrates/cgrates +dpkg-buildpackage -us -uc +rm -rf $WORK_DIR