kamctl: use VERIFY_USER variable to control if user check is done
authorDaniel-Constantin Mierla <miconda@gmail.com>
Thu, 14 Dec 2017 13:55:27 +0000 (14:55 +0100)
committerDaniel-Constantin Mierla <miconda@gmail.com>
Thu, 14 Dec 2017 13:55:27 +0000 (14:55 +0100)
- help automating some commands such as acl grant

utils/kamctl/kamctl
utils/kamctl/kamctl.base
utils/kamctl/kamctlrc

index 569ddd8..f82f6f5 100755 (executable)
@@ -311,14 +311,16 @@ acl() {
        case $1 in
                show)
                        if [ $# -eq 2 ] ; then
-                               is_user $2
-                               if [ $? -ne 0 ] ; then
-                                       mecho "Non-existent user '$2'. Still proceeding? [Y|N] "
-                                       read answer
-                                       if [ "$answer" = "y" -o "$answer" = "Y" ] ; then
-                                               minfo "Proceeding with non-local user"
-                                       else
-                                               exit 1
+                               if [ $VERIFY_USER -eq 1 ] ; then
+                                       is_user $2
+                                       if [ $? -ne 0 ] ; then
+                                               mecho "Non-existent user '$2'. Still proceeding? [Y|N] "
+                                               read answer
+                                               if [ "$answer" = "y" -o "$answer" = "Y" ] ; then
+                                                       minfo "Proceeding with non-local user"
+                                               else
+                                                       exit 1
+                                               fi
                                        fi
                                fi
                                set_user $2
@@ -338,14 +340,16 @@ acl() {
                                usage
                                exit 1
                        fi
-                       is_user $2
-                       if [ $? -ne 0 ] ; then
-                               mecho "Non-existent user '$2'. Still proceeding? [Y|N] "
-                               read answer
-                               if [ "$answer" = "y" -o "$answer" = "Y" ] ; then
-                                       minfo "Proceeding with non-local user"
-                               else
-                                       exit 1
+                       if [ $VERIFY_USER -eq 1 ] ; then
+                               is_user $2
+                               if [ $? -ne 0 ] ; then
+                                       mecho "Non-existent user '$2'. Still proceeding? [Y|N] "
+                                       read answer
+                                       if [ "$answer" = "y" -o "$answer" = "Y" ] ; then
+                                               minfo "Proceeding with non-local user"
+                                       else
+                                               exit 1
+                                       fi
                                fi
                        fi
                        set_user $2
index 29ee217..eb8ab55 100644 (file)
@@ -136,6 +136,9 @@ fi
 if [ -z "$ACL_GROUPS" ] ; then
        ACL_GROUPS="local ld int voicemail free-pstn"
 fi
+if [ -z "$VERIFY_USER" ] ; then
+       VERIFY_USER=1
+fi
 
 ##### ----------------------------------------------- #####
 #### Defined values
index 46fcdf5..836290a 100644 (file)
 ## are accepted
 # ACL_GROUPS="local ld int voicemail free-pstn"
 
+## check if user exists (used by some commands such as acl);
+## - default on (1); off (0)
+# VERIFY_USER=1
+
 ## verbose - debug purposes - default '0'
 # VERBOSE=1