2013-07-07 00:37:09 -07:00
|
|
|
#!/bin/sh
|
|
|
|
# postinst script for test
|
|
|
|
#
|
|
|
|
# see: dh_installdeb(1)
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# summary of how this script can be called:
|
|
|
|
# * <postinst> `configure' <most-recently-configured-version>
|
|
|
|
# * <old-postinst> `abort-upgrade' <new version>
|
|
|
|
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
|
|
|
|
# <new-version>
|
|
|
|
# * <postinst> `abort-remove'
|
|
|
|
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
|
|
|
|
# <failed-install-package> <version> `removing'
|
|
|
|
# <conflicting-package> <version>
|
|
|
|
# for details, see http://www.debian.org/doc/debian-policy/ or
|
|
|
|
# the debian-policy package
|
|
|
|
|
|
|
|
configure()
|
|
|
|
{
|
2013-07-08 22:14:34 -07:00
|
|
|
DB_LOC=/etc/OpenBTS/sipauthserve.db
|
|
|
|
DATE=$(date +'%Y-%m-%d.%H:%M:%S')
|
|
|
|
CONFIG_BACKUP=$DB_LOC.dump-$DATE
|
2013-07-07 00:37:09 -07:00
|
|
|
|
|
|
|
|
2013-07-08 22:14:34 -07:00
|
|
|
if [ -e $DB_LOC ]; then
|
|
|
|
sqlite3 $DB_LOC ".dump" > $CONFIG_BACKUP
|
2013-07-07 00:37:09 -07:00
|
|
|
fi
|
|
|
|
|
|
|
|
#create the SR config db
|
2013-07-08 22:14:34 -07:00
|
|
|
sqlite3 $DB_LOC ".read /etc/OpenBTS/sipauthserve.example.sql" > /dev/null 2>&1
|
2013-07-07 00:37:09 -07:00
|
|
|
|
2013-07-08 22:14:34 -07:00
|
|
|
SR_DIR=/var/lib/asterisk/sqlite3dir
|
|
|
|
SRPATH=$SR_DIR/sqlite3.db
|
2013-07-07 00:37:09 -07:00
|
|
|
SR_CONFIG_BACKUP=$SRPATH.dump-$DATE
|
|
|
|
|
2013-07-08 22:14:34 -07:00
|
|
|
if [ ! -d $SR_DIR ]; then
|
|
|
|
mkdir -p $SR_DIR
|
2013-07-07 00:37:09 -07:00
|
|
|
fi
|
2013-07-08 22:14:34 -07:00
|
|
|
chown -R root:www-data $SR_DIR
|
|
|
|
chmod 775 $SR_DIR
|
|
|
|
|
|
|
|
sqlite3 $SRPATH ".read /etc/OpenBTS/subscriberRegistryInit.sql" > /dev/null 2>&1
|
2013-07-07 00:37:09 -07:00
|
|
|
|
|
|
|
if [ -e $SRPATH ]; then
|
|
|
|
if [ ! -e $SR_CONFIG_BACKUP ]; then
|
|
|
|
sqlite3 $SRPATH ".dump" > $SR_CONFIG_BACKUP
|
|
|
|
fi
|
|
|
|
|
|
|
|
HASPREPAID=`sqlite3 $SRPATH "PRAGMA table_info(sip_buddies)" | grep prepaid`
|
|
|
|
if [ "$HASPREPAID" = "" ]; then
|
|
|
|
sqlite3 $SRPATH "alter table sip_buddies add prepaid int(1) DEFAULT 0 not null"
|
|
|
|
fi
|
|
|
|
|
|
|
|
HASBALANCE=`sqlite3 $SRPATH "PRAGMA table_info(sip_buddies)" | grep account_balance`
|
|
|
|
if [ "$HASBALANCE" = "" ]; then
|
|
|
|
sqlite3 $SRPATH "alter table sip_buddies add column account_balance int(9) default 0"
|
|
|
|
fi
|
|
|
|
|
|
|
|
sqlite3 $SRPATH "insert or ignore into 'rates' values ('in-network-SMS', 0)"
|
|
|
|
sqlite3 $SRPATH "insert or ignore into 'rates' values ('out-of-network-SMS', 0)"
|
|
|
|
sqlite3 $SRPATH "insert or ignore into 'rates' values ('in-network-call', 0)"
|
|
|
|
sqlite3 $SRPATH "insert or ignore into 'rates' values ('out-of-network-call', 0)"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# set up permissions for webui, temporary fix until ui is replumbed to use json
|
|
|
|
# directory permissions
|
2013-07-08 22:14:34 -07:00
|
|
|
if [ -e $SRPATH ]; then
|
|
|
|
chmod 664 $SR_DIR/sqlite3*
|
2013-07-07 00:37:09 -07:00
|
|
|
fi
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
configure)
|
|
|
|
configure
|
|
|
|
;;
|
|
|
|
|
|
|
|
abort-upgrade|abort-remove|abort-deconfigure)
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
echo "postinst called with unknown argument \`$1'" >&2
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# dh_installdeb will replace this with shell code automatically
|
|
|
|
# generated by other debhelper scripts.
|
|
|
|
|
|
|
|
#DEBHELPER#
|
|
|
|
|
|
|
|
exit 0
|