-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbulkImport.sh
70 lines (51 loc) · 1.59 KB
/
bulkImport.sh
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
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
file=/root/scripts/users.txt
index2=index
role=_role
passwd=splunk@
cat $file | while read line
do
if [ $(id -u) -eq 0 ]; then
echo $line
egrep "$line" /srv/splunk/etc/master-apps/_cluster/local/indexes.conf >/dev/null
if [ $? -eq 0 ]; then
echo "$line exists!"
exit 1
else
echo "
[$line$index2]
homePath = $SPLUNK_HOME/var/lib/splunk/$line/db
coldPath = $SPLUNK_HOME/var/lib/splunk/$line/colddb
thawedPath = $SPLUNK_HOME/var/lib/splunk/$line/thaweddb
repFactor = auto
frozenTimePeriodInSecs = 2592000" >> /srv/splunk/etc/master-apps/_cluster/local/indexes.conf
[ $? -eq 0 ] && echo "Index has been added to SPLUNK!" || echo "Failed to add new index!"
fi
else
echo "Only root may add index to the system"
exit 2
fi
#Use REST api to add users
curl -k -u admin:changeme https://10.26.204.145:8089/services/authorization/roles \
-d name=$line$role \
-d imported_roles=power \
-d srchIndexesDefault=$line$index2 \
-d srchIndexesAllowed=$line$index2
curl -k -u admin:changeme https://10.26.204.146:8089/services/authorization/roles \
-d name=$line$role \
-d imported_roles=power \
-d srchIndexesDefault=$line$index2 \
-d srchIndexesAllowed=$line$index2
curl -k -u admin:changeme https://10.26.204.145:8089/services/authentification/users \
-d name=$line \
-d realname=$line \
-d password=$passwd$line \
-d defaultApp=search \
-d roles=$line$role
curl -k -u admin:changeme https://10.26.204.146:8089/services/authentification/users \
-d name=$line \
-d realname=$line \
-d password=$passwd$line \
-d defaultApp=search \
-d roles=$line$role
done