-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup-from-scratch.sh
54 lines (41 loc) · 1.67 KB
/
setup-from-scratch.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
#!/bin/bash
# Function to print an error message and exit
exit_with_message() {
echo "$1"
exit 1
}
# Get the current working directory
current_dir=$(pwd)
# Extract the name of the current directory
current_dir_name=$(basename "$current_dir")
# Check if the current directory is 'dev-env' and the parent directory is 'salmagundi'
if [[ "$current_dir_name" == "salmagundi-kubernetes-dev-env" ]] && [[ $(basename "$(dirname "$current_dir")") == "salmagundi" ]]; then
echo "In the wrong directory. Going back..."
cd ../..
fi
if [[ "$current_dir_name" == "salmagundi" ]]; then
echo "In the wrong directory. Going back..."
cd ..
fi
# Define the root directory where 'salmagundi' should be
root_dir=$(pwd)
# Define the directory path for 'salmagundi' and 'salmagundi-kubernetes-dev-env'
salmagundi_dir="$root_dir/salmagundi"
dev_env_dir="$salmagundi_dir/salmagundi-kubernetes-dev-env"
# Create the 'salmagundi' directory if it doesn't exist
mkdir -p "$salmagundi_dir"
# Clone or pull the dev-env repo if necessary
if [ -d "$dev_env_dir/.git" ]; then
echo "'salmagundi-kubernetes-dev-env' already exists. Pulling the latest changes..."
git -C "$dev_env_dir" pull
else
echo "Cloning 'salmagundi-kubernetes-dev-env'..."
git clone "[email protected]:Amsterdam/salmagundi-kubernetes-dev-env.git" "$dev_env_dir"
fi
# Navigate to the 'salmagundi-kubernetes-dev-env' directory
cd "$dev_env_dir" || exit_with_message "Failed to navigate to the 'salmagundi-kubernetes-dev-env' directory."
# Execute the make clone command
if ! make clone; then
exit_with_message "Failed to run 'make clone'. Please check the Makefile and try again."
fi
echo "Setup completed successfully."