-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathinit.sh
executable file
·70 lines (60 loc) · 2.3 KB
/
init.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
project="init"
dir_seed="$(pwd)/seed"
IMPORT_LIST="$(ls ${dir_seed} 2>/dev/null)"
dir_bundle="$(pwd)/bundle"
EXTRACT_LIST="$(ls ${dir_bundle}/*.tar.xz 2>/dev/null)"
# For now, konductor operator collector must be run as root for cross os/release support
if (( $EUID != 0 )); then
echo ">> Please run as root"
exit 1
else
# konductor builds the cloudctl pod on the localhost over ansible ssh connection
ready=$(ssh -o "BatchMode yes" -o "StrictHostKeyChecking no" root@localhost whoami 1>/dev/null ; echo $?)
if [[ ${ready} == '0' ]] && \
[[ -f "/root/.ssh/id_rsa" ]]; then
echo ">> Host ssh connection discovered successfully"
else
echo ">> Host ssh connection not found"
echo ">> Configuring host for cni ssh connection"
[[ -f ${HOME}/.ssh/id_rsa ]] \
|| ssh-keygen -f ${HOME}/.ssh/id_rsa -t rsa -N ''
cat ${HOME}/.ssh/id_rsa.pub >> ${HOME}/.ssh/authorized_keys
chmod 0644 ${HOME}/.ssh/authorized_keys
sed -i 's/PermitRootLogin no/PermitRootLogin prohibit-password/g' /etc/ssh/sshd_config
systemctl restart sshd
sleep 2
ready=$(ssh -o "BatchMode yes" -o "StrictHostKeyChecking no" root@localhost whoami 1>/dev/null ; echo $?)
if [[ ${ready} == 0 ]]; then
echo ">> Host ssh connection configured successfully"
else
echo ">> Failed to configure localhost ssh connection."
exit 1
fi
fi
fi
mkdir -p /tmp/konductor
cp -rf ~/.ssh /tmp/konductor/.ssh
if [[ ! -z "${IMPORT_LIST}" ]]; then
for i in ${EXTRACT_LIST}; do
tar xvf ${i} -C /root
done
fi
if [[ ! -z "${IMPORT_LIST}" ]]; then
podman pod rm --force cloudctl 2>/dev/null
podman image prune --all --force
for IMG in ${IMPORT_LIST}; do
echo ">> Loading Konductor Image from ${IMG}"
podman load --input ${dir_seed}/${IMG}
done
else
echo ">> Pulling Konductor Image from DockerHub Repo"
podman pull quay.io/cloudctl/konductor:latest
fi
sudo podman run -it --rm --pull never \
-h ${project} --name ${project} \
--entrypoint ./site.yml --privileged \
--volume /tmp/konductor/.ssh:/root/.ssh:z \
--workdir /root/platform/iac/cloudctl \
--volume $(pwd):/root/platform/iac/cloudctl:z \
quay.io/cloudctl/konductor:latest $@