dev-env/script/clone
2024-12-21 03:50:02 +01:00

33 lines
916 B
Bash
Executable File

#!/bin/bash
ENV_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )/.." &> /dev/null && pwd )
CONFIG_FILE="$ENV_DIR/.systems"
source $ENV_DIR/bin/denv_msg
# Check if .systems configuration exists
if [ ! -f "$CONFIG_FILE" ]; then
denv_error_msg "$CONFIG_FILE not found."
exit 1
fi
# Iterate through all lines in .systems configuration
while IFS=' ' read -r IDENTIFIER DIRECTORY GIT; do
# Skip comments and emtpy lines
if [[ "$IDENTIFIER" =~ ^#.* ]] || [ -z "$IDENTIFIER" ]; then
continue
fi
denv_info_msg "System $IDENTIFIER"
DIRECTORY="systems/$DIRECTORY"
# Check if system directory already exists
if [ ! -d "$DIRECTORY" ]; then
denv_info_msg "Clone into directory '$DIRECTORY'..."
git clone "$GIT" "$DIRECTORY"
denv_success_msg "Successfully cloned $IDENTIFIER"
else
denv_echo_msg "Directory '$DIRECTORY' already exists. Skipping..."
fi
echo ""
done < "$CONFIG_FILE"