forked from gitpod-io/workspace-images
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-common.sh
executable file
·42 lines (35 loc) · 943 Bytes
/
build-common.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
#! /bin/bash
YELLOW=$(tput setaf 3)
readonly YELLOW
NC=$(tput sgr0)
readonly NC
readonly BACKUP_FILE=".dazzle.yaml.orig"
readonly ORIGINAL_FILE="dazzle.yaml"
function save_original() {
if [ ! -f ${BACKUP_FILE} ]; then
echo "${YELLOW}Creating a backup of ${ORIGINAL_FILE} as it does not exist yet...${NC}" && cp ${ORIGINAL_FILE} ${BACKUP_FILE}
fi
}
function restore_original() {
echo "${YELLOW}Restoring backup file ${BACKUP_FILE} to original file ${ORIGINAL_FILE}${NC}"
cp ${BACKUP_FILE} ${ORIGINAL_FILE}
}
function ctrl_c() {
echo "${YELLOW}** Trapped CTRL-C${NC}"
restore_original
}
function get_available_chunks() {
local chunk_defs
chunk_defs=$(ls chunks)
for chunk in $chunk_defs; do
local chunkYaml="chunks/${chunk}/chunk.yaml"
if [[ -f "$chunkYaml" ]]; then
variants=$(yq e '.variants[].name' "$chunkYaml")
for variant in $variants; do
echo "$chunk:$variant"
done
else
echo "$chunk"
fi
done
}