-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·146 lines (136 loc) · 4.67 KB
/
setup.sh
File metadata and controls
executable file
·146 lines (136 loc) · 4.67 KB
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/bin/bash
# CCA CloudShell - Setup Script
# Run this script first to install dependencies
#
# Quick Start:
# curl -sL https://github.com/LFigg/cca-cloudshell/archive/refs/heads/main.tar.gz | tar xz
# cd cca-cloudshell-main
# ./setup.sh
set -e
echo "========================================"
echo "CCA CloudShell - Setup"
echo "========================================"
# Detect environment
if [ -n "$AWS_EXECUTION_ENV" ]; then
echo "Detected: AWS CloudShell"
SHELL_TYPE="aws"
elif [ -n "$ACC_TERM_ID" ] || [ -d "/home/$USER/clouddrive" ]; then
echo "Detected: Azure Cloud Shell"
SHELL_TYPE="azure"
elif [ "$CLOUD_SHELL" = "true" ] || [ -n "$DEVSHELL_GCLOUD_CONFIG" ]; then
echo "Detected: Google Cloud Shell"
SHELL_TYPE="gcp"
else
echo "Detected: Local/Other environment"
SHELL_TYPE="local"
fi
# Check Python version
PYTHON_VERSION=$(python3 --version 2>&1 | cut -d' ' -f2)
echo "Python version: $PYTHON_VERSION"
# Set pip flags based on environment (Azure Cloud Shell requires --user)
PIP_FLAGS="--quiet"
if [ "$SHELL_TYPE" = "azure" ]; then
PIP_FLAGS="--quiet --user"
echo "Note: Using --user flag for pip (required in Azure Cloud Shell)"
fi
# Install dependencies based on collector type
echo ""
echo "Which collector(s) do you want to set up?"
echo " 1) AWS only (minimal dependencies)"
echo " 2) Azure only"
echo " 3) GCP only"
echo " 4) M365 only"
echo " 5) All collectors"
echo ""
read -p "Enter choice [1-5, default=5]: " choice
choice=${choice:-5}
case $choice in
1)
echo "Installing AWS dependencies..."
pip3 install $PIP_FLAGS boto3 rich tenacity
;;
2)
echo "Installing Azure dependencies..."
pip3 install $PIP_FLAGS azure-identity azure-mgmt-compute azure-mgmt-storage \
azure-mgmt-sql azure-mgmt-cosmosdb azure-mgmt-containerservice \
azure-mgmt-web azure-mgmt-resource azure-mgmt-subscription \
azure-mgmt-recoveryservices azure-mgmt-recoveryservicesbackup \
azure-mgmt-redis azure-mgmt-costmanagement azure-mgmt-rdbms \
azure-mgmt-synapse azure-mgmt-netapp azure-mgmt-monitor azure-storage-blob \
rich tenacity
;;
3)
echo "Installing GCP dependencies..."
pip3 install $PIP_FLAGS google-cloud-compute google-cloud-storage \
google-api-python-client google-cloud-container google-cloud-functions \
google-cloud-resource-manager rich tenacity
;;
4)
echo "Installing M365 dependencies..."
pip3 install $PIP_FLAGS msgraph-sdk azure-identity rich tenacity
;;
5)
echo "Installing all dependencies..."
pip3 install $PIP_FLAGS -r requirements.txt
;;
*)
echo "Invalid choice. Installing all dependencies..."
pip3 install $PIP_FLAGS -r requirements.txt
;;
esac
echo ""
echo "========================================"
echo "Setup complete!"
echo "========================================"
echo ""
echo "Start collection:"
echo " python3 collect.py # Auto-detect cloud and collect"
echo " python3 collect.py --setup # Interactive setup wizard"
echo ""
echo "Direct collector access (advanced):"
echo " python3 collect.py --cloud aws"
echo " python3 collect.py --cloud azure"
echo " python3 collect.py --cloud gcp"
echo " python3 collect.py --cloud m365"
echo ""
# Environment-specific guidance and offer to run
if [ "$SHELL_TYPE" = "aws" ]; then
echo "AWS CloudShell detected - credentials are pre-configured."
echo ""
read -p "Run collection now? [Y/n]: " run_now
run_now=${run_now:-Y}
if [[ "$run_now" =~ ^[Yy]$ ]]; then
echo ""
exec python3 collect.py --cloud aws
fi
elif [ "$SHELL_TYPE" = "azure" ]; then
echo "Azure Cloud Shell detected - credentials are pre-configured."
echo ""
read -p "Run collection now? [Y/n]: " run_now
run_now=${run_now:-Y}
if [[ "$run_now" =~ ^[Yy]$ ]]; then
echo ""
exec python3 collect.py --cloud azure
fi
elif [ "$SHELL_TYPE" = "gcp" ]; then
echo "Google Cloud Shell detected - credentials are pre-configured."
echo ""
read -p "Run collection now? [Y/n]: " run_now
run_now=${run_now:-Y}
if [[ "$run_now" =~ ^[Yy]$ ]]; then
echo ""
exec python3 collect.py --cloud gcp
fi
else
echo "Local environment detected."
echo "Configure credentials for your target cloud before running."
echo ""
read -p "Run interactive setup wizard? [Y/n]: " run_wizard
run_wizard=${run_wizard:-Y}
if [[ "$run_wizard" =~ ^[Yy]$ ]]; then
echo ""
exec python3 collect.py --setup
fi
fi
echo ""
echo "Run compatibility check: python3 tests/test_cloudshell_compat.py"