+
Skip to content

Add kcw script to Keycloak repository #40223

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions misc/scripts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
## dependency-report.sh

Search for a dependency in the Keycloak project to identify where it is used, and if there are multiple versions in use.

For example:

```
misc/scripts/dependency-report.sh org.twitter4j:twitter4j-core
```

Will output a report like:

```
===================================================================================================
Dependency tree for org.twitter4j:twitter4j-core
---------------------------------------------------------------------------------------------------
org.keycloak:keycloak-services:jar:999.0.0-SNAPSHOT
\- org.twitter4j:twitter4j-core:jar:4.1.2:compile
org.keycloak:keycloak-crypto-fips1402:jar:999.0.0-SNAPSHOT
\- org.keycloak:keycloak-services:jar:999.0.0-SNAPSHOT:compile
\- org.twitter4j:twitter4j-core:jar:4.1.2:compile
...
```

# kcw

Provides a quick and convenient way of starting a Keycloak server, supporting a specific version, a locally built version,
or the nightly release.

Examples:

```
kcw dev start-dev
kcw nightly start --hostname=mykeycloak
```

For more details run `kcw help`.
143 changes: 143 additions & 0 deletions misc/scripts/kcw
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
#!/bin/bash -e

KC_DIR=~/kc

if [ "$KC_SRC_HOME" != "" ]; then
SRC_DIR="$KC_SRC_HOME"
else
SRC_DIR=$(readlink -f "$0" | sed 's|/misc/scripts/kcw||')
fi
DL_DIR=~/Downloads

ARGS=""

while [ "$1" != "" ]; do
if [ "$1" == "dev" ]; then
INSTALL="dev"
elif [ "$1" == "dev-build" ]; then
INSTALL="dev"
BUILD=1
elif [ "$1" == "rel" ]; then
INSTALL=$(curl --silent https://api.github.com/repos/keycloak/keycloak/releases/latest | jq -r .tag_name)
elif [[ "$1" =~ "rel=" ]]; then
INSTALL=`echo $1 | cut -d '=' -f 2`
elif [ "$1" == "nightly" ]; then
INSTALL="nightly"
elif [ "$1" = "help" ]; then
echo "Usage: kcw [command] [kc commands]"
echo " dev install from local fork"
echo " dev-build build and install from local fork"
echo " nightly install nightly release"
echo " rel install latest release"
echo " rel[=version] install specific version"
echo ""
echo "Examples:"
echo " Start existing install: kcw start-dev"
echo " Install nightly and start: kcw nightly start-dev --cluster=none"
exit
else
ARGS="$ARGS $1"
fi

shift
done

echo "###########################################################################################"
echo "Installing: $INSTALL"
echo "Executing: bin/kc.sh$ARGS"
echo "###########################################################################################"

if [ "$INSTALL" != "" ]; then
# Clean current install
PID=$(ps -e -wwf | grep java | grep "$KC_DIR" | awk '{ print $2 }')
if [ "$PID" != "" ]; then
echo ""
echo "-------------------------------------------------------------------------------------------"
echo "Killing existing install"
echo "-------------------------------------------------------------------------------------------"
kill -9 $PID
echo "Killed: $PID"
fi
if [ -d $KC_DIR ]; then
echo ""
echo "-------------------------------------------------------------------------------------------"
echo "Deleting existing install"
echo "-------------------------------------------------------------------------------------------"
rm -rf $KC_DIR
echo "Deleted $KC_DIR"
fi

if [ "$INSTALL" == "dev" ]; then
VERSION=$(cat $SRC_DIR/pom.xml | grep '<version>' | head -n 2 | tail -n 1 | cut -d '>' -f 2 | cut -d '<' -f 1)

if [ "$BUILD" ]; then
echo ""
echo "-------------------------------------------------------------------------------------------"
echo "Building"
echo "-------------------------------------------------------------------------------------------"

#mvn -pl quarkus/dist -am -DskipTests -f $SRC_DIR/pom.xml -T 1C --offline clean install
cd $SRC_DIR
./mvnw -T 1C -Dmaven.build.cache.enabled=true -DskipTests -DskipTestsuite -DskipExamples -DskipAdapters -DskipDocs install
fi

echo ""
echo "-------------------------------------------------------------------------------------------"
echo "Installing"
echo "-------------------------------------------------------------------------------------------"

cd /tmp/
unzip -q $SRC_DIR/quarkus/dist/target/keycloak-$VERSION.zip
mv keycloak-$VERSION $KC_DIR

echo "Built and installed $VERSION from $SRC_DIR"
else
VERSION=$INSTALL
if [ "$INSTALL" == "nightly" ]; then
VERSION=999.0.0-SNAPSHOT
fi

echo ""
echo "-------------------------------------------------------------------------------------------"
echo "Installing"
echo "-------------------------------------------------------------------------------------------"

cd $DL_DIR

if [ -f keycloak-$VERSION.zip ]; then
if ( ! md5sum keycloak-$VERSION.zip | grep $(wget -q -O - https://github.com/keycloak/keycloak/releases/download/$INSTALL/keycloak-$VERSION.zip.md5) &>/dev/null ); then
echo "Checksum doesn't match deleting keycloak-$VERSION.zip"
rm keycloak-$VERSION.zip
fi
fi

if [ ! -f keycloak-$VERSION.zip ]; then
cd $DL_DIR
echo "Downloading keycloak-$VERSION.zip"
wget -q https://github.com/keycloak/keycloak/releases/download/$INSTALL/keycloak-$VERSION.zip
fi

cd /tmp/
unzip -q $DL_DIR/keycloak-$VERSION.zip
mv keycloak-$VERSION $KC_DIR

echo "Installed $VERSION"
fi
fi

if [ "$ARGS" != "" ]; then
echo ""
echo "-------------------------------------------------------------------------------------------"
echo "Running: bin/kc.sh$ARGS"
echo "-------------------------------------------------------------------------------------------"

export KC_BOOTSTRAP_ADMIN_USERNAME=admin
export KC_BOOTSTRAP_ADMIN_PASSWORD=admin
export KC_BOOTSTRAP_ADMIN_CLIENT_ID=admin
export KC_BOOTSTRAP_ADMIN_CLIENT_SECRET=admin

cd $KC_DIR/bin


./kc.sh $ARGS
fi
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载