useradd.sh added, and temporarily adding abc_users.txt to put on ABC servers

This commit is contained in:
2025-01-29 10:34:47 -05:00
parent f4b9d3e1b9
commit 9713c09f9f
2 changed files with 117 additions and 0 deletions
Executable
+48
View File
@@ -0,0 +1,48 @@
#!/bin/bash
key="9RTG9Aq2NTfefE3XeAiDUbacmNvOJPWfRV3Vbs5DS8ZCCAr6XrIUDLqZeBCceQUo"
host="http://192.168.1.15"
declare -A myOpts
user=""
pass=""
name=""
email=""
go=""
opts=""
while [ -n "$1" ]; do
case "$1" in
--user) user="$2"; shift 2;;
--pass) pass="$2"; shift 2;;
--name) name="$2"; shift 2;;
--email) email="$2"; shift 2;;
--go) go="true"; shift 1;;
*) shift 1;;
esac
done
if [ -z "$user" -o -z "$pass" -o -z "$name" -o -z "$email" ]; then
echo "Must specify all of --user --pass --email and --name"
exit
fi
opts+="&force_pw_change=0"
opts+="&email_info=0"
opts+="&monitoring_contact=1"
opts+="&enable_notifications=1"
opts+="&auth_level=user"
opts+="&can_see_all_hs=1" # Default is 0
opts+="&can_control_all_hs=0"
opts+="&can_reconfigure_hs=0"
opts+="&can_control_engine=0"
opts+="&can_use_advanced=0"
opts+="&read_only=1" # Default is 0
opts+="&auth_type=local"
name=$(echo "$name" | sed -e "s/ /%20/g")
echo curl -XPOST "\"${host}/nagiosxi/api/v1/system/user?apikey=${key}&pretty=1\"" \
-d "\"username=${user}&password=${pass}&name=${name}&email=${email}${opts}\""
[ -n "$go" ] && curl -XPOST "${host}/nagiosxi/api/v1/system/user?apikey=${key}&pretty=1" \
-d "username=${user}&password=${pass}&name=${name}&email=${email}${opts}"