-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·142 lines (128 loc) · 3.35 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·142 lines (128 loc) · 3.35 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
#!/bin/bash
# install.sh - Check dependencies and setup
set -euo pipefail
echo "=== VPC Control Tool - Setup ==="
echo ""
# Check if running as root
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root (use sudo)"
exit 1
fi
# Check required commands
REQUIRED_COMMANDS=("ip" "iptables" "bridge" "sysctl")
MISSING=()
for cmd in "${REQUIRED_COMMANDS[@]}"; do
if ! command -v "$cmd" >/dev/null 2>&1; then
MISSING+=("$cmd")
fi
done
if [[ ${#MISSING[@]} -gt 0 ]]; then
echo "Missing required commands: ${MISSING[*]}"
echo ""
echo "Install with:"
echo " Ubuntu/Debian: sudo apt install iproute2 iptables bridge-utils"
echo " Fedora/RHEL: sudo dnf install iproute iptables bridge-utils"
exit 1
fi
echo "✓ All required commands found"
echo ""
# Enable IP forwarding permanently
if ! grep -q "^net.ipv4.ip_forward=1" /etc/sysctl.conf 2>/dev/null; then
echo "Enabling IP forwarding permanently..."
echo "net.ipv4.ip_forward=1" >> /etc/sysctl.conf
sysctl -p >/dev/null
echo "✓ IP forwarding enabled"
else
echo "✓ IP forwarding already enabled"
fi
# Create directories
mkdir -p config logs demo/screenshots
# Make vpcctl executable
chmod +x vpcctl
chmod +x lib/*.sh 2>/dev/null || true
echo "✓ vpcctl made executable"
# Create empty state file
touch config/vpc.conf
echo "✓ State file created"
# Create default security groups JSON
if [[ ! -f config/security-groups.json ]]; then
cat > config/security-groups.json << 'EOF'
{
"policies": [
{
"subnet": "10.0.1.0/24",
"description": "Example public subnet policy",
"ingress": [
{
"port": 80,
"protocol": "tcp",
"source": "0.0.0.0/0",
"action": "allow",
"description": "Allow HTTP"
},
{
"port": 443,
"protocol": "tcp",
"source": "0.0.0.0/0",
"action": "allow",
"description": "Allow HTTPS"
},
{
"port": 22,
"protocol": "tcp",
"source": "10.0.0.0/16",
"action": "allow",
"description": "Allow SSH from VPC only"
}
],
"egress": [
{
"destination": "0.0.0.0/0",
"action": "allow",
"description": "Allow all outbound"
}
]
},
{
"subnet": "10.0.2.0/24",
"description": "Example private subnet policy",
"ingress": [
{
"port": 3306,
"protocol": "tcp",
"source": "10.0.1.0/24",
"action": "allow",
"description": "Allow MySQL from public subnet"
},
{
"port": 22,
"protocol": "tcp",
"source": "10.0.1.0/24",
"action": "allow",
"description": "Allow SSH from public subnet"
}
],
"egress": [
{
"destination": "10.0.0.0/16",
"action": "allow",
"description": "Allow traffic within VPC"
}
]
}
]
}
EOF
echo "✓ Default security groups config created"
fi
echo ""
echo "=== Setup Complete ==="
echo ""
echo "You can now use vpcctl:"
echo " sudo ./vpcctl create-vpc --name myvpc --cidr 10.0.0.0/16"
echo " sudo ./vpcctl add-subnet --vpc myvpc --name public --cidr 10.0.1.0/24 --type public"
echo " sudo ./vpcctl list-vpcs"
echo ""
echo "For help, run:"
echo " ./vpcctl --help"
echo ""