forked from VerKnowSys/Shable
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup-base-system
executable file
·49 lines (34 loc) · 1.34 KB
/
setup-base-system
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
#!/bin/sh
. lib/shable
include "base"
_host="${1}"
_ssh_port="22"
inventory_read "${DEFAULT_INVENTORY}" "${_host}"
not_empty "${_host}" "Specify $(diste "host") to invoke $(diste "base-system-setup") on"
not_empty "${ip}" "Expected defined value of $(diste "ip") in inventory: $(diste "${DEFAULT_INVENTORY}")"
# not_empty "${ip_internal}" "Expected defined value of $(diste "ip_internal") in inventory: $(diste "${DEFAULT_INVENTORY}")"
add_ssh_conf_entry "${_host}" "${ip}"
add_ssh_known_host "${ip}"
# handle interrupts - to avoid mess under ~/.ssh/config
trap "remove_last_ssh_conf_entry" INT TERM
note "Setting up new base system on host: $(distn "${_host}"), ip: $(distn "${ip}")" #, internal ip: $(distn "${ip_internal}")"
# call setup-new-server reign, run as superuser, skip validation of unavailable binaries in pre-base-system:
RUN_AS=root \
SKIP_ENV_VALIDATION=YES \
bin/reign \
"${DEFAULT_INVENTORY}" \
setup-new-server \
"${_host}" \
"${_ssh_port}"
note "Waiting for remote host to reboot"
sleep 45
printf "port ${DEFAULT_SSH_PORT}" >> "${HOME}/.ssh/config"
RUN_AS=root \
SKIP_ENV_VALIDATION=YES \
bin/reign \
"${DEFAULT_INVENTORY}" \
setup-new-server-install-base-software \
"${_host}"
# after setup, generate new host config
remove_last_ssh_conf_entry
add_ssh_conf_entry "${_host}" "${ip}" "${DEFAULT_SSH_PORT}"