forked from ot4i/ace-docker
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathace_config_webusers.sh
127 lines (106 loc) · 3.92 KB
/
ace_config_webusers.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/bin/bash
# © Copyright IBM Corporation 2018.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v2.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v20.html
if [ -z "$MQSI_VERSION" ]; then
source /opt/ibm/ace-11/server/bin/mqsiprofile
fi
SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
source ${SCRIPT_DIR}/ace_config_logging.sh
log "Handling webusers configuration"
ADMINUSERSFILE=/home/aceuser/initial-config/webusers/admin-users.txt
OPERATORUSERSFILE=/home/aceuser/initial-config/webusers/operator-users.txt
VIEWERUSERSFILE=/home/aceuser/initial-config/webusers/viewer-users.txt
EDITORUSERSFILE=/home/aceuser/initial-config/webusers/editor-users.txt
AUDITUSERSFILE=/home/aceuser/initial-config/webusers/audit-users.txt
DASHBOARDUSERSFILE=/home/aceuser/initial-config/webusers/dashboard-users.txt
if [ -s $ADMINUSERSFILE ] || [ -s $OPERATORUSERSFILE ] || [ -s $VIEWERUSERSFILE ] || [ -s $EDITORUSERSFILE ] || [ -s $AUDITUSERSFILE ] || [ -s $DASHBOARDUSERSFILE ]; then
OUTPUT=$(mqsichangeauthmode -w /home/aceuser/ace-server -s active -m file 2>&1)
logAndExitIfError $? "${OUTPUT}"
OUTPUT=$(mqsichangefileauth -w /home/aceuser/ace-server -r admin -p all+ 2>&1)
logAndExitIfError $? "${OUTPUT}"
OUTPUT=$(mqsichangefileauth -w /home/aceuser/ace-server -r viewer -p read+ 2>&1)
logAndExitIfError $? "${OUTPUT}"
OLDIFS=${IFS}
if [ -s $ADMINUSERSFILE ]; then
IFS=$'\n'
for line in $(cat $ADMINUSERSFILE | tr -d '\r'); do
if [[ $line =~ ^\# ]]; then
continue
fi
IFS=${OLDIFS}
fields=($line)
log "Creating admin user ${fields[0]}"
OUTPUT=$(mqsiwebuseradmin -w /home/aceuser/ace-server -c -u ${fields[0]} -a ${fields[1]} -r admin 2>&1)
logAndExitIfError $? "${OUTPUT}"
done
fi
if [ -s $OPERATORUSERSFILE ]; then
IFS=$'\n'
for line in $(cat $OPERATORUSERSFILE | tr -d '\r'); do
if [[ $line =~ ^\# ]]; then
continue
fi
IFS=${OLDIFS}
fields=($line)
log "Creating admin user ${fields[0]}"
OUTPUT=$(mqsiwebuseradmin -w /home/aceuser/ace-server -c -u ${fields[0]} -a ${fields[1]} -r admin 2>&1)
logAndExitIfError $? "${OUTPUT}"
done
fi
if [ -s $VIEWERUSERSFILE ]; then
IFS=$'\n'
for line in $(cat $VIEWERUSERSFILE | tr -d '\r'); do
if [[ $line =~ ^\# ]]; then
continue
fi
IFS=${OLDIFS}
fields=($line)
log "Creating viewer user ${fields[0]}"
OUTPUT=$(mqsiwebuseradmin -w /home/aceuser/ace-server -c -u ${fields[0]} -a ${fields[1]} -r viewer 2>&1)
logAndExitIfError $? "${OUTPUT}"
done
fi
if [ -s $EDITORUSERSFILE ]; then
IFS=$'\n'
for line in $(cat $EDITORUSERSFILE | tr -d '\r'); do
if [[ $line =~ ^\# ]]; then
continue
fi
IFS=${OLDIFS}
fields=($line)
log "Creating viewer user ${fields[0]}"
OUTPUT=$(mqsiwebuseradmin -w /home/aceuser/ace-server -c -u ${fields[0]} -a ${fields[1]} -r viewer 2>&1)
logAndExitIfError $? "${OUTPUT}"
done
fi
if [ -s $AUDITUSERSFILE ]; then
IFS=$'\n'
for line in $(cat $AUDITUSERSFILE | tr -d '\r'); do
if [[ $line =~ ^\# ]]; then
continue
fi
IFS=${OLDIFS}
fields=($line)
log "Creating viewer user ${fields[0]}"
OUTPUT=$(mqsiwebuseradmin -w /home/aceuser/ace-server -c -u ${fields[0]} -a ${fields[1]} -r viewer 2>&1)
logAndExitIfError $? "${OUTPUT}"
done
fi
if [ -s $DASHBOARDUSERSFILE ]; then
IFS=$'\n'
for line in $(cat $DASHBOARDUSERSFILE | tr -d '\r'); do
if [[ $line =~ ^\# ]]; then
continue
fi
IFS=${OLDIFS}
fields=($line)
log "Creating viewer user ${fields[0]}"
OUTPUT=$(mqsiwebuseradmin -w /home/aceuser/ace-server -c -u ${fields[0]} -a ${fields[1]} -r viewer 2>&1)
logAndExitIfError $? "${OUTPUT}"
done
fi
fi