forked from mjpitz/rpi-cloud-init
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconnect.sh
More file actions
executable file
·51 lines (42 loc) · 1.14 KB
/
Copy pathconnect.sh
File metadata and controls
executable file
·51 lines (42 loc) · 1.14 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
#!/usr/bin/env bash
export NETWORK_IP=${NETWORK_IP:-192.168.4.1}
readonly ip_prefix=${NETWORK_IP%.1}
export ADMIN_USER=${ADMIN_USER:-mjpitz}
readonly default_ssh_key_path="${HOME}/.ssh/id_rsa"
readonly ssh_key_path="${SSH_KEY_PATH:-"$default_ssh_key_path"}"
function connect_host() {
static_ip="${1}"
host="ip-${static_ip//./-}"
if [[ ! -z "${DEBUG}" ]]; then
cat <<EOF
docker-machine create \
--driver generic \
--generic-ip-address "${static_ip}" \
--generic-ssh-key "${ssh_key_path}" \
--generic-ssh-port 22 \
--generic-ssh-user "${ADMIN_USER}" \
"${host}"
EOF
fi
docker-machine create \
--driver generic \
--generic-ip-address "${static_ip}" \
--generic-ssh-key "${ssh_key_path}" \
--generic-ssh-port 22 \
--generic-ssh-user "${ADMIN_USER}" \
"${host}"
}
function connect_zone() {
prefix=${1}
start=${2}
end=${3}
for i in $(seq ${start} ${end}); do
static_ip="${prefix}.${i}"
echo "connecting ${static_ip}"
connect_host "${static_ip}"
done
}
connect_zone ${ip_prefix} 30 30
connect_zone ${ip_prefix} 50 54
connect_zone ${ip_prefix} 60 64
connect_zone ${ip_prefix} 70 74