Browse code

- adding/removing/showing of rpid

Jan Janak authored on 05/11/2003 05:05:33
Showing 1 changed files
... ...
@@ -87,6 +87,7 @@ REALM_COLUMN=domain
87 87
 HA1_COLUMN=HA1
88 88
 HA1B_COLUMN=HA1B
89 89
 PASSWORD_COLUMN=password
90
+RPID_COLUMN=rpid
90 91
 SUBSCRIBER_COLUMN='username'
91 92
 EMAIL_COLUMN=email_address
92 93
 SUB_CREATED_COLUMN=datetime_created
... ...
@@ -140,6 +141,9 @@ parameter usage:
140 141
  alias show [<alias>] ............... show aliases
141 142
  alias rm <alias> ................... remove an alias
142 143
  alias add <alias> <uri> ............ add an aliases 
144
+ rpid add <username> <rpid> ......... add rpid for a user (*)
145
+ rpid rm <username> ................. set rpid to NULL for a user (*)
146
+ rpid show <username> ............... show rpid of a user
143 147
 
144 148
            * access control lists *
145 149
  acl show [<username>] .............. show user membership
... ...
@@ -432,6 +436,80 @@ usrloc() {
432 436
 	esac
433 437
 }
434 438
 
439
+rpid() {
440
+	if [ "$#" -lt 2 ] ; then
441
+		echo "rpid: too few parameters"
442
+		exit 1
443
+	fi
444
+        shift;
445
+
446
+	case $1 in
447
+		show)
448
+			if [ $# -eq 2 ] ; then
449
+				set_user $2
450
+				is_user 
451
+				if [ $? -ne 0 ] ; then
452
+					echo non-existent user
453
+					exit 1;
454
+				fi
455
+				CLAUSE=" WHERE $SUBSCRIBER_COLUMN='$SERUSER' AND $REALM_COLUMN='$SERDOMAIN' "
456
+			elif [ $# -ne 1 ] ; then
457
+				usage
458
+				exit 1
459
+			fi
460
+			QUERY="select $SUBSCRIBER_COLUMN, $RPID_COLUMN FROM $SUB_TABLE $CLAUSE ; "
461
+			sql_ro_query "$QUERY"
462
+			;;
463
+
464
+		add|rm)
465
+		        MODE=$1;
466
+
467
+			if [ "$MODE" == "add" ] ; then
468
+			    ARG_NUM=3;
469
+			else
470
+			    ARG_NUM=2;
471
+			fi
472
+			
473
+			if [ $# -lt $ARG_NUM ] ; then
474
+				usage
475
+				exit 1
476
+			fi
477
+
478
+			prompt_pw
479
+			set_user $2
480
+			is_user 
481
+			if [ $? -ne 0 ] ; then
482
+				echo non-existent user
483
+				exit 1
484
+			fi
485
+			shift 2
486
+
487
+			if [ "$MODE" = "add" ] ; then
488
+			        RPID_VAL="'$1'";
489
+			else
490
+			        RPID_VAL=NULL;
491
+			fi
492
+
493
+			QUERY="UPDATE $SUB_TABLE \
494
+                	SET $RPID_COLUMN=$RPID_VAL \
495
+                	WHERE $SUBSCRIBER_COLUMN='$SERUSER' AND $REALM_COLUMN='$SERDOMAIN';"
496
+				sql_query "$QUERY"
497
+				if [ $? -ne 0 ] ; then
498
+					echo "SQL Error"
499
+					exit 1
500
+				fi
501
+
502
+			$0 rpid show $SERUSER@$SERDOMAIN
503
+
504
+			;;
505
+
506
+		*)
507
+			usage
508
+			exit 1
509
+			;;
510
+	esac
511
+}
512
+
435 513
 domain() {
436 514
 	case $1 in
437 515
 		show)
... ...
@@ -765,6 +843,10 @@ case $1 in
765 843
 		usrloc "$@"
766 844
 		;;
767 845
 
846
+        rpid)
847
+	        rpid "$@"
848
+		;;
849
+
768 850
 	online)
769 851
 		fifo_cmd ul_dump |grep aor| awk '{print $3}' | sort | sort -mu
770 852
 		exit $?