Ability to --create --delete --usesrdel <userid>
This commit is contained in:
@@ -285,6 +285,7 @@ while [ -n "$1" ]; do
|
|||||||
--users) myOptions[Users]="0"; shift 1;;
|
--users) myOptions[Users]="0"; shift 1;;
|
||||||
--usersa) myOptions[Users]="1"; shift 1;;
|
--usersa) myOptions[Users]="1"; shift 1;;
|
||||||
--useradd) myOptions[UserAdd]="$2"; shift 2;;
|
--useradd) myOptions[UserAdd]="$2"; shift 2;;
|
||||||
|
--userdel) myOptions[UserDel]="$2"; shift 2;;
|
||||||
-f|--fields) myOptions[Fields]="$2"; shift 2;;
|
-f|--fields) myOptions[Fields]="$2"; shift 2;;
|
||||||
--file) myOptions[File]="$2"; shift 2;;
|
--file) myOptions[File]="$2"; shift 2;;
|
||||||
-j|--jq) myOptions[MoreJQ]="$2"; shift 2;;
|
-j|--jq) myOptions[MoreJQ]="$2"; shift 2;;
|
||||||
@@ -464,15 +465,25 @@ do_disable() {
|
|||||||
|
|
||||||
# Delete a service, given hostname and service_description
|
# Delete a service, given hostname and service_description
|
||||||
do_delete() {
|
do_delete() {
|
||||||
do_debug 1 "Trying to delete host and service, so let's verify first"
|
do_debug 1 "Trying to delete something..."
|
||||||
host="${myDir[host_name]}"
|
host="${myDir[host_name]}"
|
||||||
svc="${myDir[service_description]}"
|
svc="${myDir[service_description]}"
|
||||||
[ -z "$host" -o -z "$svc" ] && echo "Cannot delete without a host and a service." && exit 1
|
if [ -n "$host" -a -n "$svc" ]; then
|
||||||
|
do_debug 1 "Trying to delete host and service, so let's verify first"
|
||||||
host=`echo "$host" | tr " " "+"`
|
host=`echo "$host" | tr " " "+"`
|
||||||
svc=`echo "$svc" | tr " " "+"`
|
svc=`echo "$svc" | tr " " "+"`
|
||||||
do_debug 1 "DELETE: about to delete $host: $svc"
|
do_debug 1 "DELETE: about to delete $host: $svc"
|
||||||
api_data="host_name=$host&service_description=$svc"
|
api_data="host_name=$host&service_description=$svc"
|
||||||
do_api_delete config service "$api_data" XDELETE
|
do_api_delete config service "$api_data" XDELETE
|
||||||
|
else
|
||||||
|
user="${myOptions[UserDel]}"
|
||||||
|
if [ -n "$user" ]; then
|
||||||
|
do_debug 1 "Trying to delete user, so let's verify first"
|
||||||
|
userId=`echo "$user" | egrep "^[0-9]+$"`
|
||||||
|
[ -z "$userId" ] && echo "You need to specify a numeric UserID to delete" && exit 1
|
||||||
|
do_api_delete system "user/$userId" "" XDELETE
|
||||||
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
do_create() {
|
do_create() {
|
||||||
|
|||||||
Reference in New Issue
Block a user