39 lines
1.0 KiB
Bash
Executable File
39 lines
1.0 KiB
Bash
Executable File
#!/bin/bash
|
|
COMMAND="$@"
|
|
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
|
|
|
|
denv_info_msg "[dev-env]: Execute $COMMAND for all systems"
|
|
|
|
# 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 "[$IDENTIFIER]: $COMMAND"
|
|
SYSTEM_SCRIPT_DIRECTORY=$(realpath "$ENV_DIR/systems/$DIRECTORY/bin/script")
|
|
COMMAND_PATH="$SYSTEM_SCRIPT_DIRECTORY/$COMMAND";
|
|
|
|
# Check if system directory already exists
|
|
if [ ! -f "$COMMAND_PATH" ]; then
|
|
denv_error_msg "$COMMAND_PATH not found."
|
|
exit 1
|
|
else
|
|
denv_echo_msg "Executing $COMMAND..."
|
|
$COMMAND_PATH
|
|
fi
|
|
denv_info_msg "System $IDENTIFIER done"
|
|
echo ""
|
|
|
|
done < "$CONFIG_FILE"
|