#!/bin/sh # # $Id: sc.dbtext 2297 2007-05-25 15:00:09Z bogdan_iancu $ # # sc: openser control; tool for maintaining openser's databases # # History: # -------- # 2005-03-25 - SC with DBText support (cesc santasusana) # 2005-07-08 - Removed all non-DBText functions (daniel) # 2006-05-16 - added ability to specify MD5 from a configuration file # FreeBSD does not have the md5sum function (norm) # #=================================================================== ### include resource files, if any if [ -f /etc/openser/.openscdbtextrc ]; then . /etc/openser/.openscdbtextrc fi if [ -f /usr/local/etc/openser/.openscdbtextrc ]; then . /usr/local/etc/openser/.openscdbtextrc fi if [ -f ~/.openscdbtextrc ]; then . ~/.openscdbtextrc fi ### version fo this script VERSION='1.1 - $Revision: 2297 $' ##### ----------------------------------------------- ##### ### SQL config if [ -z $DBTEXT_PATH ]; then DBTEXT_PATH="/usr/local/etc/openser/dbtext" export DBTEXT_PATH fi ##### ----------------------------------------------- ##### ### binaries if [ -z "$LAST_LINE" ] ; then LAST_LINE='tail -1' fi if [ -z "$MD5" ]; then MD5="md5sum" fi ##### ----------------------------------------------- ##### ### path to useful tools if [ -z "$EGREP" ] ; then EGREP="egrep" fi if [ -z "$AWK" ] ; then AWK="awk" fi ##### ----------------------------------------------- ##### # ACL name verification if [ -z "$VERIFY_ACL" ] ; then VERIFY_ACL=1 fi if [ -z "$ACL_GROUPS" ] ; then ACL_GROUPS="local ld int voicemail free-pstn" fi ##### ----------------------------------------------- ##### #### table names # UsrLoc Table if [ -z "$UL_TABLE" ] ; then UL_TABLE=location fi USER_COLUMN=username CALLID_COLUMN=callid # subscriber table if [ -z "$SUB_TABLE" ] ; then SUB_TABLE=subscriber fi REALM_COLUMN=domain HA1_COLUMN=HA1 HA1B_COLUMN=HA1B PASSWORD_COLUMN=password RPID_COLUMN=rpid SUBSCRIBER_COLUMN='username' EMAIL_COLUMN=email_address SUB_CREATED_COLUMN=datetime_created SUB_MODIFIED_COLUMN=datetime_modified PHP_LIB_COLUMN=phplib_id # acl table if [ -z "$ACL_TABLE" ] ; then ACL_TABLE=grp fi ACL_USER_COLUMN=username ACL_DOMAIN_COLUMN=domain ACL_GROUP_COLUMN=grp ACL_MODIFIED_COLUMN=last_modified ACL_DOMAIN_COLUMN=domain # aliases table if [ -z "$ALS_TABLE" ] ; then ALS_TABLE=aliases fi A_USER_COLUMN=username A_CONTACT_COLUMN=contact A_EXPIRES_COLUMN=expires A_Q_COLUMN=q A_CALLID_COLUMN=callid A_CSEQ_COLUMN=cseq A_LAST_MODIFIED_COLUMN=last_modified # domain table if [ -z "$DOMAIN_TABLE" ] ; then DOMAIN_TABLE=domain fi # URI table if [ -z "$URI_TABLE" ] ; then URI_TABLE=uri fi URIUSER_COLUMN=uri_user MODIFIED_COLUMN=last_modified # dbaliases table if [ -z "$DA_TABLE" ] ; then DA_TABLE=dbaliases fi DA_USER_COLUMN=username DA_DOMAIN_COLUMN=domain DA_ALIAS_USER_COLUMN=alias_username DA_ALIAS_DOMAIN_COLUMN=alias_domain # speeddial table if [ -z "$SD_TABLE" ] ; then SD_TABLE=speed_dial fi SD_USER_COLUMN=username SD_DOMAIN_COLUMN=domain SD_SD_USER_COLUMN=sd_username SD_SD_DOMAIN_COLUMN=sd_domain SD_NEW_URI_COLUMN=new_uri SD_DESC_COLUMN=description # avp table if [ -z "$AVP_TABLE" ] ; then AVP_TABLE=usr_preferences fi AVP_UUID_COLUMN=uuid AVP_USER_COLUMN=username AVP_DOMAIN_COLUMN=domain AVP_ATTRIBUTE_COLUMN=attribute AVP_VALUE_COLUMN=value AVP_TYPE_COLUMN=type AVP_MODIFIED_COLUMN=modified # lcr table if [ -z "$LCR_TABLE" ] ; then LCR_TABLE=lcr fi # gw table if [ -z "$GW_TABLE" ] ; then GW_TABLE=gw fi # gw_grp table if [ -z "$GW_GRP_TABLE" ] ; then GW_GRP_TABLE=gw_grp fi #=================================================================== #Set variables to dbtext's files ... if [ -z "$UL_FILE" ] ; then UL_FILE=$DBTEXT_PATH/$UL_TABLE fi if [ -z "$DOMAIN_FILE" ] ; then DOMAIN_FILE=$DBTEXT_PATH/$DOMAIN_TABLE fi if [ -z "$ALS_FILE" ] ; then ALS_FILE=$DBTEXT_PATH/$ALS_TABLE fi if [ -z "$SUB_FILE" ] ; then SUB_FILE=$DBTEXT_PATH/$SUB_TABLE fi if [ -z "$URI_FILE" ] ; then URI_FILE=$DBTEXT_PATH/$URI_TABLE fi if [ -z "$ACL_FILE" ] ; then ACL_FILE=$DBTEXT_PATH/$ACL_TABLE fi if [ -z "$LCR_FILE" ] ; then LCR_FILE=$DBTEXT_PATH/$LCR_TABLE fi if [ -z "$GW_FILE" ] ; then GW_FILE=$DBTEXT_PATH/$GW_TABLE fi if [ -z "$GW_GRP_FILE" ] ; then GW_GRP_FILE=$DBTEXT_PATH/$GW_GRP_TABLE fi #=================================================================== usage() { CMD=`basename $0` if [ "0$VERIFY_ACL" -eq 1 ] ; then EXTRA_TEXT="ACL privileges are: $ACL_GROUPS" fi cat < .. add a new subscriber (*) passwd ......... change user's password (*) rm ...................... delete a user (*) mail .................... send an email to a user rpid add ......... add rpid for a user (*) rpid rm ................. remove rpid for a user (*) rpid show ............... show rpid of a user * access control lists * acl show [] .............. show user membership acl grant ....... grant user membership (*) acl revoke [] .... grant user membership(s) (*) * usrloc * showdb [] ................ show online users flushed in DB * domains * domain show ........................ show list of served domains domain add ............ add a new served domain domain rm ............. remove a served domain * lcr * * IP addresses must be entered in dotted quad format e.g. 1.2.3.4 * * and must be entered in integer or text, * * e.g. transport '2' is identical to transport 'tcp'. * * scheme: 1=sip, 2=sips; transport: 1=udp, 2=tcp, 3=tls * * Examples: openser_dbtext_ctl lcr addgw_grp usa 1 * * openser_dbtext_ctl lcr addgw level3 1.2.3.4 5080 sip tcp 1 * * openser_dbtext_ctl lcr addroute +1 '' 1 1 * lcr show ...................................... show routes, gateways and groups lcr addgw_grp ............. add gateway group with grp_id lcr rmgw_grp ........................ delete the gw_grp lcr addgw ........... add a gateway lcr addgw .. add a gateway with prefix lcr rmgw ..................................................... delete a gateway lcr addroute .. add a route ( use '' to match anything in ) lcr rmroute .. delete a route * control and diagnostics * dbtext [dbtext_path] ... create the needed dbtext files (default location is /usr/local/etc/openser/dbtext) * Database Selection * The exact location of the dbtext files to use must be set. Export DBTEXT_PATH="/path/to/dbtext" (no trailing slash). No password is needed for dbtext. All these parameters can also be set in the "serctl" script file directly. Note that dbtext tries to mimic the results of a MySQL DB, but it is not always possible to reproduce them 100%. DBText files field order is the same as in the MySQL database. $EXTRA_TEXT EOF } # determine host name, typically for use in printing UAC # messages; we use today a simplistic but portable uname -n way -- # no domain name is displayed ; fifo_uac expands !! to host # address only for optional header fields; uname output without # domain is sufficient for informational header fields such as # From # get_my_host() { uname -n } chown_openser() { if [ -n "$OPENSER_USER" -a -n "$OPENSER_GROUP" ] ; then chown $OPENSER_USER:$OPENSER_GROUP $1 fi } # calculate name and domain of current user set_user() { SERUSER=`echo $1|$AWK -F@ '{print $1}'` SERDOMAIN=`echo $1|$AWK -F@ '{print $2}'` if [ -z "$SERDOMAIN" ] ; then SERDOMAIN="$SIP_DOMAIN" fi if [ -z "$SERDOMAIN" ] ; then echo -e "\nDomain unknown: use usernames with domain or set default domain in SIP_DOMAIN\n" exit 1 fi } # check the parameter if it is a valid SIP URI # quite simplified now -- it captures just very basic # errors check_uri() { echo "$1" | $EGREP "^sip(s)?:([a-zA-Z0-9_]+@)?.*\..*" > /dev/null if [ $? -ne 0 ] ; then echo -e "\nerror: invalid URI: $1\n" > /dev/stderr exit 1 fi } rpid() { if [ "$#" -lt 2 ] ; then echo -e "\nrpid: too few parameters\n" usage exit 1 fi shift; case $1 in show) echo if [ $# -eq 2 ] ; then set_user $2 is_user if [ $? -ne 0 ] ; then echo -e "\nnon-existent user\n" exit 1; fi CLAUSE=":$SERUSER:$SERDOMAIN:" elif [ $# -ne 1 ] ; then usage exit 1 fi echo -e "RPID show ... " if [ -z $CLAUSE ]; then CLAUSE="" fi #19 is the rpid field cat $SUB_FILE | $EGREP "$CLAUSE" | cut -s -d : -f 2,19 echo ;; add|rm) MODE=$1; if [ "$MODE" = "add" ] ; then ARG_NUM=3; else ARG_NUM=2; fi if [ $# -lt $ARG_NUM ] ; then usage exit 1 fi set_user $2 is_user if [ $? -ne 0 ] ; then echo -e "\nnon-existent user\n" exit 1 fi shift 2 if [ "$MODE" = "add" ] ; then RPID_VAL="'$1'"; else RPID_VAL=""; fi old_line=`cat $SUB_FILE | $EGREP :$SERUSER:$SERDOMAIN: | head -n 1` pre_rpid=`echo $old_line | cut -s -d : -f 1-18` post_rpid=`echo $old_line | cut -s -d : -f 20-25` new_line=$pre_rpid:$RPID_VAL:$post_rpid cat $SUB_FILE | sed s/$old_line/$new_line/g >> $SUB_FILE.tmp mv -f $SUB_FILE.tmp $SUB_FILE echo -e "RPID added/removed ... showing current value\n" $0 rpid show $SERUSER@$SERDOMAIN ;; *) usage exit 1 ;; esac } domain() { case $1 in show) # QUERY="select * FROM $DOMAIN_TABLE ; " # sql_ro_query "$QUERY" fifo_cmd domain_dump ;; add) shift if [ $# -ne 1 ] ; then echo -e "\nmissing domain to be added\n" exit 1 fi line="$1:$date_now" echo "$line" >> $DOMAIN_FILE echo -e "\nDomain $1 saved into DBTEXT ... now trying to force OpenSER to reload it into memory\n" #FIXME: domain_reload command not supported yet #fifo_cmd domain_reload ;; rm) shift if [ $# -ne 1 ] ; then echo -e "\nmissing domain to be removed\n" exit 1 fi cat $DOMAIN_FILE | $EGREP -v "^$1:" > $DOMAIN_FILE.tmp mv -f $DOMAIN_FILE.tmp $DOMAIN_FILE echo -e "\nDomain $1 removed from DBTEXT ... now trying to force SER to remove it from memory\n" #FIXME: domain_reload command not supported yet #fifo_cmd domain_reload ;; *) usage exit 1 esac } lcr() { case $1 in show) echo lcr routes lines=`wc -l $LCR_FILE | cut -d " " -f 1` let "lines=$lines-1" tail -n $lines $LCR_FILE echo lcr gateway groups lines=`wc -l $GW_GRP_FILE | cut -d " " -f 1` let "lines=$lines-1" tail -n $lines $GW_GRP_FILE echo lcr gateways lines=`wc -l $GW_FILE | cut -d " " -f 1` let "lines=$lines-1" tail -n $lines $GW_FILE ;; addgw_grp) shift if [ $# -lt 2 ] ; then echo too few paramters usage exit 1 fi GRP_ID=$2 cat $GW_GRP_FILE | $EGREP ^$GRP_ID: > /dev/null if [ $? -eq 0 ] ; then echo -e "\nerror: group already present\n" > /dev/stderr exit 1 fi echo $2:$1 >> $GW_GRP_FILE chown_openser $GW_GRP_FILE #FIXME: lcr_reload command not supported yet #fifo_cmd lcr_reload ;; rmgw_grp) shift if [ $# -ne 1 ] ; then echo missing grp_id to be removed exit 1 fi cat $GW_GRP_FILE | $EGREP -v "^$1:" > $GW_GRP_FILE.tmp mv -f $GW_GRP_FILE.tmp $GW_GRP_FILE chown_openser $GW_GRP_FILE #FIXME: lcr_reload command not supported yet #fifo_cmd lcr_reload ;; addgw) shift if [ $# -lt 6 ] ; then echo too few paramters usage exit 1 fi if [ $# -gt 6 ] ; then GW_PREFIX=$7 if [ $# -gt 7 ] ; then STRIP=$8 else STRIP=0 fi else GW_PREFIX="" STRIP=0 fi GW_NAME=$1 GW_IP=$2 GW_PORT=$3 GW_URI_SCHEME=$4 if [ $GW_URI_SCHEME = 'sip' ]; then GW_URI_SCHEME=1 elif [ $GW_URI_SCHEME = 'sips' ]; then GW_URI_SCHEME=2 fi GW_TRANSPORT=$5 if [ $GW_TRANSPORT = 'udp' ]; then GW_TRANSPORT=1 elif [ $GW_TRANSPORT = 'tcp' ]; then GW_TRANSPORT=2 elif [ $GW_TRANSPORT = 'tls' ]; then GW_TRANSPORT=3 fi GW_GRP_ID=$6 echo $GW_NAME:$GW_GRP_ID:$GW_IP:$GW_PORT:$GW_URI_SCHEME:$GW_TRANSPORT:$STRIP:$GW_PREFIX >> $GW_FILE chown_openser $GW_FILE #FIXME: lcr_reload command not supported yet #fifo_cmd lcr_reload ;; rmgw) shift if [ $# -ne 1 ] ; then echo missing gateway to be removed exit 1 fi cat $GW_FILE | $EGREP -v "^$1:" > $GW_FILE.tmp mv -f $GW_FILE.tmp $GW_FILE chown_openser $GW_FILE #FIXME: lcr_reload command not supported yet #fifo_cmd lcr_reload ;; addroute) shift if [ $# -ne 4 ] ; then echo too few paramters usage exit 1 fi echo $1:$2:$3:$4 >> $LCR_FILE chown_openser $LCR_FILE #FIXME: lcr_reload command not supported yet #fifo_cmd lcr_reload ;; rmroute) shift if [ $# -ne 4 ] ; then echo too few paramters usage exit 1 fi cat $LCR_FILE | $EGREP -v "^$1:$2:$3:$4\$" > $LCR_FILE.tmp mv -f $LCR_FILE.tmp $LCR_FILE chown_openser $LCR_FILE #FIXME: lcr_reload command not supported yet #fifo_cmd lcr_reload ;; *) usage exit 1 esac } acl() { case $1 in show) if [ $# -eq 2 ] ; then set_user $2 is_user if [ $? -ne 0 ] ; then echo -e "\nNon-existent user. Still proceeding? [Y|N] " > /dev/stderr read answer if [ "$answer" = "y" -o "$answer" = "Y" ] ; then echo -e "\nProceeding with non-local user\n" else exit 1 fi fi EGREP_COND="^$SERUSER:$SERDOMAIN:" elif [ $# -ne 1 ] ; then usage exit 1 fi if [ -z $EGREP_COND ]; then EGREP_COND="" fi echo -e "\nuser*domain**group*lastmodified" | tr "*" "\t" cat $ACL_FILE | $EGREP -v "username" | $EGREP "$EGREP_COND" | tr ":" "\t" ;; grant) if [ $# -lt 3 ] ; then usage exit 1 fi set_user $2 is_user if [ $? -ne 0 ] ; then echo -e "\nNon-existent user. Still proceeding? [Y|N] " > /dev/stderr read answer if [ "$answer" = "y" -o "$answer" = "Y" ] ; then echo -e "\nProceeding with non-local user\n" else exit 1 fi fi shift 2 while [ $# -gt 0 ] ; do if [ $VERIFY_ACL -eq 1 ] ; then found=0 for i in $ACL_GROUPS ; do if [ "$1" = "$i" ] ; then found=1 break fi done if [ $found -eq 0 ] ; then echo -e "\nInvalid privilege: $1 ignored\n" shift continue fi fi line="$SERUSER:$SERDOMAIN:$1:$date_now" echo $line >> $ACL_FILE shift done $0 acl show $SERUSER@$SERDOMAIN ;; revoke) if [ $# -eq 3 ] ; then CLAUSE="$3:" elif [ $# -ne 2 ] ; then usage exit 1 fi set_user $2 cat $ACL_FILE | $EGREP -v "^$SERUSER:$SERDOMAIN:$CLAUSE" >> $ACL_FILE.tmp mv -f $ACL_FILE.tmp $ACL_FILE $0 acl show $2 ;; *) usage exit 1 ;; esac } # params: user # output: false if exists, true otherwise is_user() { CNT=`cat $SUB_FILE | $EGREP :$SERUSER:$SERDOMAIN: | wc -w` if [ "0$CNT" -eq 0 ] ; then false else true fi } # params: user, password # output: HA1, HA1B credentials() { set_user $1 HA1=`echo -n "$SERUSER:$SERDOMAIN:$2" | $MD5 | $AWK '{ print $1 }'` if [ $? -ne 0 ] ; then echo -e "\nHA1 calculation failed\n" exit 1 fi HA1B=`echo -n "$SERUSER@$SERDOMAIN:$SERDOMAIN:$2" | $MD5 | $AWK '{ print $1 }'` if [ $? -ne 0 ] ; then echo -e "\nHA1B calculation failed\n" exit 1 fi } #================================================================ # if the script calls itself ... export PW echo case $1 in passwd) if [ $# -ne 3 ] ; then usage exit 1 fi shift credentials $1 $2 is_user $1 if [ $? -ne 0 ] ; then echo -e "\nnon-existent user\n" exit 1 fi line1=`cat $SUB_FILE | $EGREP :$SERUSER:$SERDOMAIN: | head -n 1` #9 is the date_created field line1_keep1=`echo $line1 | cut -s -d : -f 5,6,7,8,9` line1_keep2=`echo $line1 | cut -s -d : -f 11,12,13,14` line1_keep3=`echo $line1 | cut -s -d : -f 17,18,19,20,21` line2_update="$HA1:$SERUSER:$SERDOMAIN:$2:$line1_keep1:$date_now:$line1_keep2:$HA1:$HA1B:$line1_keep3" cat $SUB_FILE | sed s/"$line1"/"$line2_update"/g >> $SUB_FILE.tmp mv -f $SUB_FILE.tmp $SUB_FILE echo -e "\nPassword change succeeded (DBTEXT)\n" ;; add) if [ $# -ne 4 ] ; then usage exit 1 fi shift credentials $1 $2 is_user $1 if [ $? -eq 0 ] ; then echo -e "\nuser already exists\n" exit 1 fi #Add to SUBSCRIBER file #phplib_id(str) username(str) domain(str) password(str) #first_name(str,null) last_name(str,null) phone(str,null) email_address(str) #datetime_created(int) datetime_modified(int) confirmation(str,null) flag(str,null) sendnotification(str,null) greeting(str,null) ha1(str) ha1b(str) allow_find(str) timezone(str,null) rpid(str,null) domn(int,null) uuid(str,null) line="$HA1:$SERUSER:$SERDOMAIN:$2::::$3:$date_now:$date_now::o:::$HA1:$HA1B:0::::" echo $line >> $SUB_FILE #Add to URI file #username(str) domain(str) uri_user(str) last_modified(int) line="$SERUSER:$SERDOMAIN:$SERUSER:$date_now" echo $line >> $URI_FILE echo -e "\nNew user ($SERUSER@$SERDOMAIN) added to DBTEXT files\n" ;; mail) if [ $# -ne 2 ] ; then usage exit 1 fi shift set_user $1 EA=`cat $SUB_FILE | $EGREP :$SERUSER:$SERDOMAIN: | cut -s -d : -f 8 | $LAST_LINE` echo -e "\nWrite email to $1: $EA now ...\n" mail -s "Message from $SERDOMAIN SIP admin" $EA if [ $? -eq 0 ] ; then echo -e "\nmessage sent\n" else echo -e "\nsending message failed\n" fi ;; rpid) rpid "$@" ;; showdb|userdb) shift if [ $# -eq 1 ] ; then set_user $1 is_user if [ $? -ne 0 ] ; then echo -e "\nnon-existent user\n" exit 1; fi #The email field is number 8 ... echo -e "\n** In Subscriber Table: ** " cat $SUB_FILE | $EGREP :$SERUSER:$SERDOMAIN: | cut -s -d : -f 8 echo -e "\n** In Location Table: ** " cat $UL_FILE | head -n 1 | tr -d "(,)" | sed s/"str\|int\|null"/""/g | tr " " ":" cat $UL_FILE | $EGREP "^$SERUSER:($SERDOMAIN)?\B?:" else usr_loc=`cat $UL_FILE | cut -s -d : -f 1 | tr '\n' '|' | sed s/'|\$'/''/g` if [ -n $usr_loc ]; then echo -e "\n** Subscribers (username and email) currently registered: ** " cat $SUB_FILE | $EGREP $usr_loc | cut -s -d : -f 2,8 echo -e "\n** Deatailed location data available on disk (username, domain, contact, callid): ** " cat $UL_FILE | $EGREP $usr_loc | cut -s -d : -f 1,2,3,8 fi fi echo -e "\nNote: Due to usage of cache, server's list " \ "may differ from DB list.\n" ;; rm) if [ $# -ne 2 ] ; then usage exit 1 fi shift set_user $1 is_user if [ $? -ne 0 ] ; then echo -e "\nnon-existent user\n" exit 1 fi # begin with remove all user's privileges echo -e "\nACL revoke not implemented for DBTEXT ... rights not removed\n" cat $URI_FILE | $EGREP -v "^$SERUSER:" > $URI_FILE.tmp mv -f $URI_FILE.tmp $URI_FILE # destroy the user now cat $SUB_FILE | $EGREP -v ":$SERUSER:$SERDOMAIN:" >> $SUB_FILE.tmp mv -f $SUB_FILE.tmp $SUB_FILE # and also all his contacts $0 ul rm $1 > /dev/null 2>&1 echo -e "\nUSER $SERUSER removed\n" ;; acl) shift acl "$@" ;; domain) shift domain "$@" ;; lcr) shift lcr "$@" ;; dbtext) if [ $# -eq 1 ] ; then if [ -z "$DBTEXT_PATH" ] ; then DBTEXT_PATH="/usr/local/etc/openser/dbtext" fi elif [ $# -eq 2 ]; then DBTEXT_PATH=$2 else usage exit fi UL_FILE=$DBTEXT_PATH/$UL_TABLE DOMAIN_FILE=$DBTEXT_PATH/$DOMAIN_TABLE ALS_FILE=$DBTEXT_PATH/$ALS_TABLE SUB_FILE=$DBTEXT_PATH/$SUB_TABLE URI_FILE=$DBTEXT_PATH/$URI_TABLE ACL_FILE=$DBTEXT_PATH/$ACL_TABLE LCR_FILE=$DBTEXT_PATH/$LCR_TABLE GW_FILE=$DBTEXT_PATH/$GW_TABLE GW_GRP_FILE=$DBTEXT_PATH/$GW_GRP_TABLE VER_FILE=$DBTEXT_PATH/version mkdir -p $DBTEXT_PATH echo -e "Creating DBText files in $DBTEXT_PATH\n" #Subscriber file echo "phplib_id(str) username(str) domain(str) password(str) first_name(str,null) last_name(str,null) phone(str,null) email_address(str) datetime_created(int,null) datetime_modified(int,null) confirmation(str,null) flag(str,null) sendnotification(str,null) greeting(str,null) ha1(str) ha1b(str) allow_find(str) timezone(str,null) rpid(str,null) domn(int,null) uuid(str,null)" > $SUB_FILE #Location file echo "username(str) domain(str,null) contact(str,null) received(str,null) path(str,null) expires(int,null) q(double,null) callid(str,null) cseq(int,null) last_modified(int,null) flags(int) cflags(int) user_agent(str) socket(str) methods(int,null)" > $UL_FILE #Aliases file echo "username(str) domain(str,null) contact(str,null) received(str,null) path(str,null) expires(int,null) q(double,null) callid(str,null) cseq(int,null) last_modified(int,null) flags(int) cflags(int) user_agent(str) socket(str) methods(int,null)" > $ALS_FILE #Uri file echo "username(str) domain(str) uri_user(str) last_modified(int)" > $URI_FILE #Group/ACL file echo "username(str) domain(str) grp(str) last_modified(int)" > $ACL_FILE #gw file echo "gw_name(str) grp_id(int) ip_addr(str) port(int,null) uri_scheme(int,null) transport(int,null) strip(int) prefix(str,null)" > $GW_FILE #lcr file echo "prefix(str,null) from_uri(str,null) grp_id(int) priority(int,null)" > $LCR_FILE #gw_grp file echo "grp_id(int) grp_name(str)" > $GW_GRP_FILE #Version file echo "table_name(str) table_version(int)" > $VER_FILE echo "subscriber:5" >> $VER_FILE echo "reserved:1" >> $VER_FILE echo "phonebook:1" >> $VER_FILE echo "pending:4" >> $VER_FILE echo "missed_calls:2" >> $VER_FILE echo "location:1004" >> $VER_FILE echo "aliases:1004" >> $VER_FILE echo "grp:2" >> $VER_FILE echo "event:1" >> $VER_FILE echo "active_sessions:1" >> $VER_FILE echo "acc:2" >> $VER_FILE echo "config:1" >> $VER_FILE echo "silo:4" >> $VER_FILE echo "realm:1" >> $VER_FILE echo "domain:1" >> $VER_FILE echo "uri:1" >> $VER_FILE echo "server_monitoring:1" >> $VER_FILE echo "server_monitoring_agg:1" >> $VER_FILE echo "trusted:2" >> $VER_FILE echo "usr_preferences:2" >> $VER_FILE echo "usr_preferences_types:1" >> $VER_FILE echo "admin_privileges:1" >> $VER_FILE echo "calls_forwarding:1" >> $VER_FILE echo "speed_dial:2" >> $VER_FILE echo "dbaliases:1" >> $VER_FILE echo "gw:4" >> $VER_FILE echo "gw_grp:1" >> $VER_FILE echo "lcr:2" >> $VER_FILE echo -e "DBText files created.\n\nRemeber to set the DBTEXT_PATH variable (read usage)\n" ;; version) echo -e "\n$0 $VERSION\n" ;; *) usage exit 1 ;; esac