-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoat_create_user
57 lines (53 loc) · 2.23 KB
/
oat_create_user
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
#create user
USERNAME_PARM="-uname"
USERNAME=""
PASSWORD_PARM="-upwd"
PASSWORD=""
ShowCreateUserExample()
{
echo -e "Create User example:\n\033[31;49;5;1m bash oat_create_user -uname USERNAME -upwd PASSWORD\033[0m"
}
# Check that the number of params is correct
if [ $# -lt 4 ] || [ $1 != $USERNAME_PARM ] || [ $3 != $PASSWORD_PARM ];then
echo "parm error!"
ShowCreateUserExample
exit 0
fi
USERNAME="$2"
PASSWORD="$4"
# create the user
bash oat_user -a -h node-110 '{"Username":"'$USERNAME'","Password":"'$PASSWORD'"}'
if [ $? == 0 ]; then
# add the Attest permission to the user for all the existing values
bash oat_user_permission -a -h node-110 '{"Username":"'$USERNAME'","Class":"Host","Operation":"Attest","ParName":"HostName","Value":".*"}'
if [ $? == 0 ]; then
# add the Read_Attest permission to the user only for himself
bash oat_user_permission -a -h node-110 '{"Username":"'$USERNAME'","Class":"Host","Operation":"Read_Attest","ParName":"Username","Value":"'$USERNAME'"}'
if [ $? == 0 ]; then
# add the Read_Report permission to the user for all the existing values
bash oat_user_permission -a -h node-110 '{"Username":"'$USERNAME'","Class":"Host","Operation":"Read_Report","ParName":"HostName","Value":".*"}'
if [ $? == 0 ]; then
# add the User-Edit-Username permission to the user only for himself
bash oat_user_permission -a -h node-110 '{"Username":"'$USERNAME'","Class":"User","Operation":"Edit","ParName":"Username","Value":"'$USERNAME'"}'
if [ $? == 0 ]; then
# add the User-Edit-Username permission to the user only for alphanumeric values
bash oat_user_permission -a -h node-110 '{"Username":"'$USERNAME'","Class":"User","Operation":"Edit","ParName":"Password","Value":"[a-zA-z0-9]+"}'
if [ $? != 0 ]; then
echo -e "oat_user_permission -a User-Edit-Password failed!"
fi
else
echo -e "oat_user_permission -a User-Edit-Username failed!"
fi
else
echo -e "oat_user_permission -a Read_Report failed!"
fi
else
echo -e "oat_user_permission -a Read_Attest failed!"
fi
else
echo -e "oat_user_permission -a Attest failed!"
fi
else
echo -e "oat_user -a failed!"
fi