Browse code

added tables for user preferences, multidomain serweb ACL control, speed-dial and caller screening

Karel Kozlik authored on 10/03/2004 11:58:37
Showing 1 changed files
... ...
@@ -1,9 +1,9 @@
1
-#!/bin/sh 
1
+#!/bin/sh
2 2
 #
3 3
 # $Id$
4 4
 #
5 5
 # Script for adding and dropping ser MySql tables
6
-# 
6
+#
7 7
 # TO-DO: update_structures command for migriting to new
8 8
 #        table definitons
9 9
 # USAGE: call the command without any parameters for info
... ...
@@ -71,8 +71,8 @@ EOF
71 71
 } #usage
72 72
 
73 73
 
74
-# read password 
75
-prompt_pw() 
74
+# read password
75
+prompt_pw()
76 76
 {
77 77
 	savetty=`stty -g`
78 78
 	printf "MySql password for $SQL_USER: "
... ...
@@ -89,7 +89,7 @@ sql_query()
89 89
 }
90 90
 
91 91
 # dump all rows
92
-ser_dump()  # pars: <database name> 
92
+ser_dump()  # pars: <database name>
93 93
 {
94 94
 	if [ $# -ne 1 ] ; then
95 95
 		echo "ser_dump function takes one param"
... ...
@@ -100,7 +100,7 @@ ser_dump()  # pars: <database name>
100 100
 
101 101
 
102 102
 # copy a database to database_bak
103
-ser_backup() # par: <database name> 
103
+ser_backup() # par: <database name>
104 104
 {
105 105
 	if [ $# -ne 1 ] ; then
106 106
 		echo  "ser_backup function takes one param"
... ...
@@ -133,7 +133,7 @@ fi
133 133
 sql_query $1 < $2
134 134
 }
135 135
 
136
-ser_drop()  # pars: <database name> 
136
+ser_drop()  # pars: <database name>
137 137
 {
138 138
 if [ $# -ne 1 ] ; then
139 139
 	echo "ser_drop function takes two params"
... ...
@@ -146,7 +146,7 @@ EOF
146 146
 } #ser_drop
147 147
 
148 148
 # read realm
149
-prompt_realm() 
149
+prompt_realm()
150 150
 {
151 151
 	printf "Domain (realm) for the default user 'admin': "
152 152
 	read SIP_DOMAIN
... ...
@@ -176,13 +176,13 @@ if [ $# -eq 1 ] ; then
176 176
 	fi
177 177
 	credentials
178 178
 	# by default we create initial user
179
-	INITIAL_USER="INSERT INTO subscriber 
180
-		($USERCOL, password, first_name, last_name, phone, 
181
-		email_address, datetime_created, datetime_modified, confirmation, 
182
-		flag, sendnotification, greeting, ha1, domain, ha1b, phplib_id, perms ) 
183
-		VALUES ( 'admin', 'heslo', 'Initial', 'Admin', '123', 
184
-		'root@localhost', '2002-09-04 19:37:45', '0000-00-00 00:00:00', 
185
-		'57DaSIPuCm52UNe54LF545750cfdL48OMZfroM53', 'o', '', '', 
179
+	INITIAL_USER="INSERT INTO subscriber
180
+		($USERCOL, password, first_name, last_name, phone,
181
+		email_address, datetime_created, datetime_modified, confirmation,
182
+		flag, sendnotification, greeting, ha1, domain, ha1b, phplib_id, perms )
183
+		VALUES ( 'admin', 'heslo', 'Initial', 'Admin', '123',
184
+		'root@localhost', '2002-09-04 19:37:45', '0000-00-00 00:00:00',
185
+		'57DaSIPuCm52UNe54LF545750cfdL48OMZfroM53', 'o', '', '',
186 186
 		'$HA1', '$SIP_DOMAIN', '$HA1B',
187 187
 		'65e397cda0aa8e3202ea22cbd350e4e9', 'admin' );"
188 188
 elif [ $# -eq 2 ] ; then
... ...
@@ -238,6 +238,11 @@ INSERT INTO version VALUES ( 'uri', '1');
238 238
 INSERT INTO version VALUES ( 'server_monitoring', '1');
239 239
 INSERT INTO version VALUES ( 'server_monitoring_agg', '1');
240 240
 INSERT INTO version VALUES ( 'trusted', '1');
241
+INSERT INTO version VALUES ( 'preferences', '1');
242
+INSERT INTO version VALUES ( 'preferences_types', '1');
243
+INSERT INTO version VALUES ( 'admin_privileges', '1');
244
+INSERT INTO version VALUES ( 'calls_forwarding', '1');
245
+INSERT INTO version VALUES ( 'speed_dial', '1');
241 246
 
242 247
 #
243 248
 # Table structure for table 'acc' -- accounted calls
... ...
@@ -556,7 +561,19 @@ CREATE TABLE preferences (
556 561
   value varchar(100) NOT NULL default '',
557 562
   PRIMARY KEY ($USERCOL, domain, attribute)
558 563
 ) $TABLE_TYPE;
559
-	  
564
+
565
+#
566
+# Table structure for table 'preferences_types' -- types of atributes in preferences
567
+#
568
+
569
+CREATE TABLE preferences_types (
570
+  att_name varchar(50) NOT NULL default '',
571
+  att_rich_type varchar(32) NOT NULL default 'string',
572
+  att_raw_type int(11) unsigned NOT NULL default '2',
573
+  att_type_spec text,
574
+  default_value varchar(100) NOT NULL default '',
575
+  PRIMARY KEY  (att_name)
576
+) $TABLE_TYPE;
560 577
 
561 578
 #
562 579
 # Table structure for table trusted
... ...
@@ -589,7 +606,49 @@ CREATE TABLE server_monitoring_agg (
589 606
   PRIMARY KEY  (param)
590 607
 ) $TABLE_TYPE;
591 608
 
592
-# add an admin user "admin" with password==heslo, 
609
+#
610
+# Table structure for table 'admin_privileges' -- multidomain serweb ACL control
611
+#
612
+
613
+CREATE TABLE admin_privileges (
614
+  $USERCOL varchar(64) NOT NULL default '',
615
+  domain varchar(128) NOT NULL default '',
616
+  priv_name varchar(64) NOT NULL default '',
617
+  priv_value varchar(64) NOT NULL default '',
618
+  PRIMARY KEY  ($USERCOL,priv_name,priv_value,domain)
619
+) $TABLE_TYPE;
620
+
621
+#
622
+# Table structure for table 'calls_forwarding'  -- curently used only for caller screening
623
+#
624
+
625
+CREATE TABLE calls_forwarding (
626
+  $USERCOL varchar(64) NOT NULL default '',
627
+  domain varchar(128) NOT NULL default '',
628
+  uri_re varchar(128) NOT NULL default '',
629
+  purpose varchar(32) NOT NULL default '',
630
+  action varchar(32) NOT NULL default '',
631
+  param1 varchar(128) default NULL,
632
+  param2 varchar(128) default NULL,
633
+  PRIMARY KEY  ($USERCOL,domain,uri_re,purpose)
634
+) $TABLE_TYPE;
635
+
636
+#
637
+# Table structure for table 'speed_dial'
638
+#
639
+
640
+CREATE TABLE speed_dial (
641
+  $USERCOL varchar(64) NOT NULL default '',
642
+  domain varchar(128) NOT NULL default '',
643
+  username_from_req_uri varchar(128) NOT NULL default '',
644
+  domain_from_req_uri varchar(128) NOT NULL default '',
645
+  new_request_uri varchar(128) NOT NULL default '',
646
+  PRIMARY KEY  ($USERCOL,domain,domain_from_req_uri,username_from_req_uri)
647
+) $TABLE_TYPE;
648
+
649
+
650
+
651
+# add an admin user "admin" with password==heslo,
593 652
 # so that one can try it out on quick start
594 653
 
595 654
 $INITIAL_USER
... ...
@@ -602,7 +661,7 @@ EOF
602 661
 
603 662
 
604 663
 export PW
605
-if [ "$#" -ne 0 ]; then 
664
+if [ "$#" -ne 0 ]; then
606 665
   prompt_pw
607 666
 fi
608 667
 
... ...
@@ -611,7 +670,7 @@ case $1 in
611 670
 
612 671
 		#1 create a backup database (named *_bak)
613 672
 		echo "creating backup database"
614
-		ser_backup $DBNAME 
673
+		ser_backup $DBNAME
615 674
 		if [ "$?" -ne 0 ] ; then
616 675
 			echo "reinstall: ser_backup failed"
617 676
 			exit 1
... ...
@@ -629,7 +688,7 @@ case $1 in
629 688
 			sed "s/[rR][eE][aA][lL][mM]/domain/g"> ${tmp_file}.2
630 689
 		#3 drop original database
631 690
 		echo "dropping table ($DBNAME)"
632
-		ser_drop $DBNAME 
691
+		ser_drop $DBNAME
633 692
 		if [ "$?" -ne 0 ] ; then
634 693
 			echo "reinstall: dropping table failed"
635 694
 			rm $tmp_file*
... ...
@@ -644,7 +703,7 @@ case $1 in
644 703
 			exit 1
645 704
 		fi
646 705
 		#5 restoring table content
647
-		echo "restoring table content" 
706
+		echo "restoring table content"
648 707
 		ser_restore $DBNAME ${tmp_file}.2
649 708
 		if [ "$?" -ne 0 ] ; then
650 709
 			echo "reinstall: restoring table failed"
... ...
@@ -682,7 +741,7 @@ case $1 in
682 741
 		;;
683 742
 	backup)
684 743
 		# backup current database
685
-		ser_dump $DBNAME 
744
+		ser_dump $DBNAME
686 745
 		exit $?
687 746
 		;;
688 747
 	restore)
... ...
@@ -701,22 +760,22 @@ case $1 in
701 760
 		if [ $# -eq 1 ] ; then
702 761
 			DBNAME="$1"
703 762
 		fi
704
-		ser_create $DBNAME 
763
+		ser_create $DBNAME
705 764
 		exit $?
706 765
 		;;
707 766
 	drop)
708 767
 		# delete ser database
709
-		ser_drop $DBNAME 
768
+		ser_drop $DBNAME
710 769
 		exit $?
711 770
 		;;
712 771
 	reinit)
713 772
 		# delete database and create a new one
714
-		ser_drop $DBNAME 
773
+		ser_drop $DBNAME
715 774
 		ret=$?
716 775
 		if [ "$ret" -ne 0 ]; then
717 776
 			exit $ret
718 777
 		fi
719
-		ser_create $DBNAME 
778
+		ser_create $DBNAME
720 779
 		exit $?
721 780
 		;;
722 781
 	*)