Browse code

adding permanent contacts introduced

Jiri Kuthan authored on 26/08/2002 20:31:06
Showing 1 changed files
... ...
@@ -1,4 +1,4 @@
1
-#!/bin/sh 
1
+#!/bin/sh  
2 2
 #
3 3
 # $Id$
4 4
 #
... ...
@@ -74,29 +74,38 @@ A_LAST_MODIFIED_COLUMN=last_modified
74 74
 
75 75
 
76 76
 usage() {
77
-	echo "usage: "
78
-	echo -n " `basename $0` add <name> <password> <email> "
79
-	echo "... add a new subscriber (*)"
80
-	echo " `basename $0` dul <name> - delete user's UsrLoc entries (*)"
81
-	echo " `basename $0` show [<name>] - show online users"
82
-	echo " `basename $0` mail <name> - send an email to a user"
83
-	echo " `basename $0` rm <name> - delete a user (*)"
84
-	echo " `basename $0` passwd <user> <passwd> - change user's password (*)"
85
-	echo " `basename $0` stat - show runnig processes + $0 show"
86
-	echo " `basename $0` acl show [<user>] - show user membership"
87
-	echo " `basename $0` acl grant <user> <group>... - grant user membership (*)"
88
-	echo " `basename $0` acl revoke <user> [<group>] - grant user membership(s) (*)"
89
-	echo " `basename $0` alias show [<alias>] - show aliases"
90
-	echo " `basename $0` alias rm <alias> - remove an alias"
91
-	echo " `basename $0` alias add <alias> <uri> - show aliases"
92
-	echo 
93
-	echo "   commands labeled with (*) will prompt for a MySQL password"
94
-	echo "   if the variable PW is set, the password will not be prompted"
95
-
96
-	if [ "0$VERIFY_ACL" -eq 1 ] ; then
97
-		echo "   ACL privileges are: $ACL_GROUPS"
98
-	fi
99
-	echo
77
+CMD=`basename $0`
78
+if [ "0$VERIFY_ACL" -eq 1 ] ; then
79
+	EXTRA_TEXT="ACL privileges are: $ACL_GROUPS"
80
+fi
81
+cat <<EOF
82
+usage: 
83
+           < subscribers >
84
+ $CMD add <name> <password> <email> ... add a new subscriber (*)
85
+ $CMD mail <name> ..................... send an email to a user
86
+ $CMD rm <name> ....................... delete a user (*)
87
+ $CMD alias show [<alias>] ............ show aliases
88
+ $CMD alias rm <alias> ................ remove an alias
89
+ $CMD alias add <alias> <uri> ......... show aliases
90
+           < access control lists >
91
+ $CMD acl show [<user>] ............... show user membership
92
+ $CMD acl grant <user> <group> ........ grant user membership (*)
93
+ $CMD acl revoke <user> [<group>] ..... grant user membership(s) (*)
94
+           < usrloc >
95
+ $CMD dul <name> ...................... delete user's UsrLoc entries (*)
96
+ $CMD show [<name>] ................... show online users
97
+ $CMD passwd <user> <passwd> .......... change user's password (*)
98
+ $CMD perm <user> <uri> ............... introduce a permanent UrLoc entry
99
+           < server health >
100
+ $CMD stat ............................ show runnig processes + $0 show
101
+ $CMD monitor ......................... show internal status
102
+
103
+   commands labeled with (*) will prompt for a MySQL password
104
+   if the variable PW is set, the password will not be prompted"
105
+
106
+     $EXTRA_TEXT
107
+
108
+EOF
100 109
 }
101 110
 
102 111
 #params: none
... ...
@@ -170,11 +179,6 @@ ser_alias() {
170 179
 	case $1 in 
171 180
 		show)
172 181
 			if [ $# -eq 2 ] ; then
173
-				is_user $2
174
-				if [ $? -ne 0 ] ; then
175
-					echo non-existent user
176
-					exit 1;
177
-				fi
178 182
 				CLAUSE=" WHERE $A_USER_COLUMN='$2' "
179 183
 			elif [ $# -ne 1 ] ; then
180 184
 				usage
... ...
@@ -397,6 +401,29 @@ case $1 in
397 401
 
398 402
 		;;
399 403
 
404
+	# add a permanent UsrLoc entry
405
+	perm)
406
+		if [ $# -ne 3 ] ; then
407
+			usage
408
+			exit 1
409
+		fi
410
+		prompt_pw
411
+		is_user $2
412
+		if [ $? -ne 0 ] ; then
413
+			echo non-existent user
414
+			exit 1;
415
+		fi
416
+		QUERY="insert into $USRLOC \
417
+			($A_USER_COLUMN, $A_CONTACT_COLUMN, $A_EXPIRES_COLUMN, \
418
+			$A_Q_COLUMN, $A_CALLID_COLUMN, $A_CSEQ_COLUMN, \
419
+			$A_LAST_MODIFIED_COLUMN) \
420
+			values ( '$2', '$3', '$FOREVER', \
421
+			'1.00', 'call-id-for-ever', '1',
422
+			now() );"
423
+			sql_query "$QUERY"
424
+		;;
425
+
426
+
400 427
 	dul)
401 428
 		if [ $# -ne 2 ] ; then
402 429
 			usage