-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathxml2dot.sh
executable file
·34 lines (27 loc) · 1.05 KB
/
xml2dot.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
#!/bin/bash
############################
# Usage:
# File Name: xml2dot.sh
# Author: annhe
# Mail: [email protected]
# Created Time: 2016-05-16 00:17:21
############################
itop_config_mgmt="../env-production/itop-config-mgmt/datamodel.itop-config-mgmt.xml"
le_config_mgmt="le-config-mgmt/datamodel.le-config-mgmt.xml"
grep "class id=" $itop_config_mgmt |cut -f2 -d'"' >class.txt
grep "<parent>" $itop_config_mgmt |cut -f2 -d'>' |cut -f1 -d'<' >parent.txt
paste class.txt parent.txt |sed '/^\t/d' >itop.txt
grep "class id=" $le_config_mgmt |grep define |cut -f2 -d'"' >class.txt
grep "<parent>" $le_config_mgmt |cut -f2 -d'>' |cut -f1 -d'<' >parent.txt
paste class.txt parent.txt |sed '/^\t/d' >>itop.txt
cp itop.txt{,.bak}
for id in `grep "class id=" $le_config_mgmt |grep delete |cut -f2 -d'"'`;do
sed -i "/\t$id$/d" itop.txt
sed -i "/^$id\t/d" itop.txt
done
sed -i 's/\t/->/g' itop.txt
echo -e "digraph G{\nrankdir=RL" > itop.dot
cat itop.txt >>itop.dot
echo "}" >>itop.dot
dot -Tpng itop.dot -o le-itop.png
rm -f class.txt parent.txt itop.txt itop.txt.bak