-
Notifications
You must be signed in to change notification settings - Fork 4
/
init.sh
executable file
·52 lines (40 loc) · 1.33 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
#!/usr/bin/env bash
echo "INIT"
set -x
VALID_CLOUD_IN_A_BOX_TYPES=("edge" "kubernetes" "sandbox")
CLOUD_IN_A_BOX_TYPE=$1
shift
if [[ -z $CLOUD_IN_A_BOX_TYPE ]]; then
# No type was specified, use sandbox as default
CLOUD_IN_A_BOX_TYPE=sandbox
else
# Check if it is a valid type
if [[ " ${VALID_CLOUD_IN_A_BOX_TYPES[*]} " != *" $CLOUD_IN_A_BOX_TYPE "* ]]; then
echo "ERROR: Invalid type $CLOUD_IN_A_BOX_TYPE specified."
exit 1
fi
# Write parameters
for extra in "$@"; do
echo "$extra" | tee -a /etc/cloud-in-a-box.env
done
fi
echo "CLOUD_IN_A_BOX_TYPE=$CLOUD_IN_A_BOX_TYPE" | tee -a /etc/cloud-in-a-box.env
param_file="/etc/.initial-kernel-commandline"
if ! [ -e "${param_file}" ];then
param_file="/proc/cmdline"
fi
vars="$(tr ' ' '\n' < $param_file | grep -P '^ciab_.+=.+')"
if [ -n "$vars" ]; then
eval "$vars"
fi
set -x
set -e
# Get initial configuration repository
git clone "${ciab_repo_url:-https://github.com/osism/cloud-in-a-box}" /opt/cloud-in-a-box
git -C /opt/cloud-in-a-box checkout "${ciab_branch:-main}"
sed -i "~s,configuration_git_version:.*,configuration_git_version: ${ciab_branch:-main}," \
/opt/cloud-in-a-box/environments/manager/configuration.yml
# Run bootstrap script
/opt/cloud-in-a-box/bootstrap.sh $CLOUD_IN_A_BOX_TYPE
# Run deploy script
/opt/cloud-in-a-box/deploy.sh $CLOUD_IN_A_BOX_TYPE