-
Notifications
You must be signed in to change notification settings - Fork 0
/
mk-servers.sh
72 lines (64 loc) · 1.88 KB
/
mk-servers.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
#!/bin/bash
BASE=/opt/APG
BIN=${HOME}/bin
ETC=${HOME}/etc
SERVERS=servers.xml
mkdir ${BIN} 2>/dev/null
mkdir ${ETC} 2>/dev/null
##
## Link per-achitecture scripts to servers.sh
##
for TAG in frontend primary additional collector
do
[[ -x ${BIN}/${TAG}.sh ]] || ln ${BIN}/servers.sh ${BIN}/${TAG}.sh
done
##
## Go looking for the ${SERVERS} file.
##
cd ${BASE}/Custom/WebApps-Resources/Default
cd Default.1 2>/dev/null # only exists in 3.5sp1
cd centralized-management
[[ -f ${SERVERS} ]] || ( echo missing ${SERVERS} file ; exit 1 )
##
## Create a list of all servers, and per-architecture.
##
/bin/grep name= ${SERVERS} | \
/bin/sed -e 's/^.* name=//' -e 's/ .*//' -e 's/"//g' \
> ${ETC}/servers_all
/bin/grep name= ${SERVERS} | /bin/grep windows-x64 | \
/bin/sed -e 's/^.* name=//' -e 's/ .*//' -e 's/"//g' \
> ${ETC}/servers_win
/bin/grep name= ${SERVERS} | /bin/grep -v windows-x64 | \
/bin/sed -e 's/^.* name=//' -e 's/ .*//' -e 's/"//g' \
> ${ETC}/servers_ux
##
## Clean out any old versions.
##
cd ${ETC}
/bin/rm ./{frontend,primary,additional,collector}_{all,win,ux} 2>/dev/null
##
## Let the user tag each server.
##
echo "For each server, enter its tag, one or more of Frontend, Primary,"
echo "Additional and/or Collector. You may enter just the initial."
for s in $(< ./servers_all )
do
read -r -p "$s: " -a TAGS
for TAG in ${TAGS[*]}
do
case $TAG in
[Ff]*) echo $s>>./frontend_all ;;
[Pp]*) echo $s>>./primary_all ;;
[Aa]*) echo $s>>./additional_all ;;
[Cc]*) echo $s>>./collector_all ;;
esac
done
done
##
## Create tagged per-architecture files.
##
for TAG in frontend primary additional collector
do
grep -f ./servers_win ./${TAG}_all >./${TAG}_win
grep -f ./servers_ux ./${TAG}_all >./${TAG}_ux
done