-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathupdate-host-configuration.sh
63 lines (54 loc) · 1.74 KB
/
update-host-configuration.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
#!/bin/sh
# Stop script on NZEC
set -e
# Stop script if unbound variable found (use ${var:-} if intentional)
set -u
# Lines added to get the script running in the script path shell context
# reference: http://www.ostricher.com/2014/10/the-right-way-to-get-the-directory-of-a-bash-script/
cd "$(dirname "$0")"
# To avoid issues with MINGW and Git Bash, see:
# https://github.com/docker/toolbox/issues/673
# https://gist.github.com/borekb/cb1536a3685ca6fc0ad9a028e6a959e3
export MSYS_NO_PATHCONV=1
export MSYS2_ARG_CONV_EXCL="*"
print_help () {
echo ""
echo "Usage: sh update-host-configuration.sh [OPTIONS]"
echo ""
echo "Prepare host for the Doppler Jenkins Swarm."
echo ""
echo "It requires SOPS installed with our private keys."
echo ""
echo "Options:"
echo " -h, --help"
echo
echo "Examples:"
echo " sh update-host-configuration.sh"
}
for i in "$@" ; do
case $i in
-h|--help)
print_help
exit 0
;;
esac
done
sh ./host-setup/decrypt-host-setup-files.sh
# Install ssh keys to allow to upload to our CDN
sshPath="/var/lib/jenkins/.ssh"
chmod 600 ./host-setup/ssh/id_rsa.secret.shared
mkdir -p "${sshPath}"
cp -n ./host-setup/ssh/id_rsa.pub "${sshPath}"
cp -n ./host-setup/ssh/known_hosts "${sshPath}"
mv -n ./host-setup/ssh/id_rsa.secret.shared "${sshPath}/id_rsa"
# Docker login
dockerPath="/root/.docker"
chmod 600 ./host-setup/docker/config.secret.shared.json
mkdir -p "${dockerPath}"
mv -n ./host-setup/docker/config.secret.shared.json "${dockerPath}"/config.json
# AWS login
awsPath="/var/lib/jenkins/.aws"
chmod 600 ./host-setup/aws/credentials.secret.shared
mkdir -p "${awsPath}"
cp -n ./host-setup/aws/config "${awsPath}"
mv -n ./host-setup/aws/credentials.secret.shared "${awsPath}/credentials"