Skip to content

Commit

Permalink
Merge pull request #34 from adorsys/issue-24
Browse files Browse the repository at this point in the history
Add platform-specific check for keycloak_pid in test deployment
  • Loading branch information
IngridPuppet authored Jul 25, 2024
2 parents 0d8885d + d001dd5 commit a11b461
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
19 changes: 14 additions & 5 deletions 0.start-kc-oid4vci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,20 @@ else
fi

# Shutdown keycloak if any
keycloak_pid=$(ps aux | grep -i '[k]eycloak' | awk '{print $2}')
if [ -n "$keycloak_pid" ]; then
echo "A Keycloak instance is already running (PID: $keycloak_pid). Shutting it down..."
kill $keycloak_pid
fi
# Determine OS platform and shutdown Keycloak if running
OS=$(uname -s)
case "$OS" in
Linux*|Darwin*)
keycloak_pid=$(pgrep -f keycloak)
if [ -n "$keycloak_pid" ]; then
echo "Keycloak instance found (PID: $keycloak_pid) on $OS. Shutting it down..."
kill $keycloak_pid
fi
;;
*)
echo "This script supports only Linux or macOS."
;;
esac

# Change to the tools directory and unpack keycloak
if [ -d "$KC_INSTALL_DIR" ]; then
Expand Down
23 changes: 20 additions & 3 deletions 1.oid4vci_test_deployment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,29 @@
. .env

# Ensure keycloak with oid4vc-vci profile is running
keycloak_pid=$(ps aux | grep -i '[k]eycloak' | awk '{print $2}')
if [ ! -n "$keycloak_pid" ]; then
echo "Keycloak not running. Start keycloak using 0.start-kc-oid4vci first..."
# Function to get the Keycloak PID based on the OS
get_keycloak_pid() {
if [[ "$OSTYPE" == "darwin"* ]]; then
# macOS
echo $(ps aux | grep -i '[q]uarkus' | awk '{print $2}')
else
# Linux
echo $(ps aux | grep -i '[k]eycloak' | awk '{print $2}')
fi
}

# Get the Keycloak PID
keycloak_pid=$(get_keycloak_pid)

# Check if Keycloak is running
if [ -z "$keycloak_pid" ]; then
echo "Keycloak not running. Start Keycloak using 0.start-kc-oid4vci first..."
exit 1
fi

echo "Keycloak is running with PID: $keycloak_pid"


# Get admin token using environment variables for credentials
echo "Obtaining admin token..."
$KC_INSTALL_DIR/bin/kcadm.sh config truststore --trustpass $KC_TRUST_STORE_PASS $KC_TRUST_STORE
Expand Down

0 comments on commit a11b461

Please sign in to comment.