-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6a8c7f3
commit 0b173cb
Showing
3 changed files
with
88 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#!/bin/sh | ||
# Collect.sh - A script to run Infrahub's support data collection in Docker mode. | ||
# | ||
# This script runs the following docker command: | ||
# | ||
# docker run --rm \ | ||
# -v /var/run/docker.sock:/var/run/docker.sock \ | ||
# -v "$(pwd)/exports":/source/exports \ | ||
# -e INFRAHUB_BUILD_NAME=infrahub \ | ||
# registry.opsmill.io/opsmill/infrahub invoke dev.collect [additional options] | ||
# | ||
# Usage: | ||
# curl https://infrahub.opsmill.io/collect.sh | sh [--include-queries] | ||
# | ||
# Options: | ||
# --include-queries Pass an extra flag to collect database queries logs | ||
# | ||
# Note: If INFRAHUB_BUILD_NAME is already defined in the environment, its value will be used. | ||
|
||
set -e | ||
|
||
# Check if docker is available | ||
if ! command -v docker >/dev/null 2>&1; then | ||
echo "Error: Docker is not installed or not in PATH." | ||
exit 1 | ||
fi | ||
|
||
# Use INFRAHUB_BUILD_NAME from the environment or default to "infrahub" | ||
if [ -z "$INFRAHUB_BUILD_NAME" ]; then | ||
export INFRAHUB_BUILD_NAME="infrahub" | ||
fi | ||
|
||
# Default: no extra options | ||
EXTRA_OPTS="" | ||
|
||
# Process command-line options | ||
while [ "$#" -gt 0 ]; do | ||
case "$1" in | ||
--include-queries) | ||
EXTRA_OPTS="$EXTRA_OPTS --include-queries" | ||
;; | ||
--help|-h) | ||
echo "Usage: sh collect.sh [--include-queries]" | ||
exit 0 | ||
;; | ||
*) | ||
echo "Unknown option: $1" | ||
echo "Usage: sh collect.sh [--include-queries]" | ||
exit 1 | ||
;; | ||
esac | ||
shift | ||
done | ||
|
||
# Create the exports directory if it doesn't exist | ||
if [ ! -d "$(pwd)/exports" ]; then | ||
mkdir -p "$(pwd)/exports" | ||
fi | ||
|
||
# Build the docker run command | ||
DOCKER_CMD="docker run --rm \ | ||
-v /var/run/docker.sock:/var/run/docker.sock \ | ||
-v $(pwd)/exports:/source/exports \ | ||
-e INFRAHUB_BUILD_NAME=${INFRAHUB_BUILD_NAME} \ | ||
registry.opsmill.io/opsmill/infrahub invoke dev.collect $EXTRA_OPTS" | ||
|
||
echo "Running command:" | ||
echo "$DOCKER_CMD" | ||
|
||
# Execute the command | ||
eval $DOCKER_CMD | ||
echo "Support archive created in the ./exports directory." |