-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.sh
More file actions
executable file
·62 lines (51 loc) · 1.66 KB
/
bootstrap.sh
File metadata and controls
executable file
·62 lines (51 loc) · 1.66 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
#!/bin/bash
function create_ssm_user {
# check if user already exists
getent passwd ssm-user > /dev/null
if [[ $? = 0 ]]; then
echo "ssm-user user already exists. Don't need to do anything more."
else
# ssm-user creation
useradd --comment "mirror AWS System Manager ssm-user" --create-home --shell /bin/bash ssm-user
if [[ $? != 0 ]]; then
>&2 echo "Error while creating user."
exit 1
fi
usermod -a -G wheel ssm-user
if [[ $? != 0 ]]; then
>&2 echo "Error while updating user permissions."
exit 1
fi
echo "ssm-user ALL=(ALL:ALL) NOPASSWD: ALL" > /etc/sudoers.d/dont-prompt-ssm-user-for-sudo-password
if [[ $? != 0 ]]; then
>&2 echo "Error while updating user sudo password policy."
exit 1
fi
fi
}
#/usr/bin/env bash
echo "Bootstrapping Geppetto"
# ensure git is installed
echo "- Installing bootstrapping tools"
yum install -y git-core sudo shadow-utils
# create the ssm user
create_ssm_user
OZONE_HOME="/usr/o3"
GEPPETTO_HOME=${OZONE_HOME}/geppetto
if [[ -d ${GEPPETTO_HOME} ]]; then
echo "- Cleaning old ${GEPPETTO_HOME}"
sudo rm -rf ${GEPPETTO_HOME}
fi
echo "- Creating ${GEPPETTO_HOME}"
sudo mkdir -p ${GEPPETTO_HOME}
# assign right permissions
echo "- Assign user permissions to ${OZONE_HOME}"
sudo chown -R ssm-user:ssm-user ${OZONE_HOME}
CWD=$(dirname $0)
REAL_DIR=$(realpath ${CWD})
echo "- run the ssm-user bootstrap script in ${REAL_DIR}"
sudo -iu ssm-user GITHUB_HTTPS_CREDS=${GITHUB_HTTPS_CREDS} GEPPETTO_BRANCH=${GEPPETTO_BRANCH:-${BRANCH}} AUTODEPLOY=${AUTODEPLOY:-"false"} ${REAL_DIR}/ssm-bootstrap.sh
if [[ $? != 0 ]]; then
>&2 echo "Bootstrap initialization failed."
exit 1
fi