forked from mvanholsteijn/aws-visualizer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.sh
executable file
·55 lines (48 loc) · 1.32 KB
/
run.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
#!/bin/bash
function check_pip_installed() {
PIP=$(which pip)
if [ -z "$PIP" ] ; then
echo ERROR: Python not installed
exit 1
fi
for module in $@ ; do
INSTALLED=$(pip show $module 2>/dev/null)
if [ -z "$INSTALLED" ] ; then
echo ERROR: module $module not installed.
echo ERROR: please run pip install $@
exit 1
fi
done
}
check_pip_installed boto netaddr
if [ ! -f ~/.aws/credentials ] ; then
echo ERROR: ~/.aws/credentials are missing.
echo ' [default]'
echo ' aws_access_key_id = <ACCESS_KEY>'
echo ' aws_secret_access_key = <SECRET_KEY>'
exit 1
fi
rm -rf target
mkdir -p target/default
mkdir -p target/securitygroups
mkdir -p target/subnets
echo INFO: graphing default dependencies
python graph_region.py --directory target/default $@
echo INFO: graphing with subnets
python graph_region.py --directory target/subnets --use-subnets $@
echo INFO: graphing with security groups
python graph_region.py --directory target/securitygroups --use-security-group-subgraphs $@
DOT=$(which dot)
if [ -n "$DOT" ] ; then
for file in target/*/*.dot; do
echo INFO: generating png for $file
dot -Tpng -o $(dirname $file)/$(basename $file .dot).png $file
done
if [ "$(uname)" == "Darwin" ] ; then
open target/*/*.png
else
echo INFO: Done. checkout target/ subdirectories
fi
else
echo WARN: dot not installed.
fi