Skip to content

Commit f7a948f

Browse files
committed
Add kcw script to Keycloak repository
Signed-off-by: stianst <[email protected]>
1 parent 6f4af1f commit f7a948f

File tree

2 files changed

+180
-0
lines changed

2 files changed

+180
-0
lines changed

misc/scripts/README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
## dependency-report.sh
2+
3+
Search for a dependency in the Keycloak project to identify where it is used, and if there are multiple versions in use.
4+
5+
For example:
6+
7+
```
8+
misc/scripts/dependency-report.sh org.twitter4j:twitter4j-core
9+
```
10+
11+
Will output a report like:
12+
13+
```
14+
===================================================================================================
15+
Dependency tree for org.twitter4j:twitter4j-core
16+
---------------------------------------------------------------------------------------------------
17+
org.keycloak:keycloak-services:jar:999.0.0-SNAPSHOT
18+
\- org.twitter4j:twitter4j-core:jar:4.1.2:compile
19+
org.keycloak:keycloak-crypto-fips1402:jar:999.0.0-SNAPSHOT
20+
\- org.keycloak:keycloak-services:jar:999.0.0-SNAPSHOT:compile
21+
\- org.twitter4j:twitter4j-core:jar:4.1.2:compile
22+
...
23+
```
24+
25+
# kcw
26+
27+
Provides a quick and convenient way of starting a Keycloak server, supporting a specific version, a locally built version,
28+
or the nightly release.
29+
30+
Examples:
31+
32+
```
33+
kcw dev start-dev
34+
kcw nightly start --hostname=mykeycloak
35+
```
36+
37+
For more details run `kcw help`.

misc/scripts/kcw

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
#!/bin/bash -e
2+
3+
KC_DIR=~/kc
4+
5+
if [ "$KC_SRC_HOME" != "" ]; then
6+
SRC_DIR="$KC_SRC_HOME"
7+
else
8+
SRC_DIR=$(readlink -f "$0" | sed 's|/misc/scripts/kcw||')
9+
fi
10+
DL_DIR=~/Downloads
11+
12+
ARGS=""
13+
14+
while [ "$1" != "" ]; do
15+
if [ "$1" == "dev" ]; then
16+
INSTALL="dev"
17+
elif [ "$1" == "dev-build" ]; then
18+
INSTALL="dev"
19+
BUILD=1
20+
elif [ "$1" == "rel" ]; then
21+
INSTALL=$(curl --silent https://api.github.com/repos/keycloak/keycloak/releases/latest | jq -r .tag_name)
22+
elif [[ "$1" =~ "rel=" ]]; then
23+
INSTALL=`echo $1 | cut -d '=' -f 2`
24+
elif [ "$1" == "nightly" ]; then
25+
INSTALL="nightly"
26+
elif [ "$1" = "help" ]; then
27+
echo "Usage: kcw [command] [kc commands]"
28+
echo " dev install from local fork"
29+
echo " dev-build build and install from local fork"
30+
echo " nightly install nightly release"
31+
echo " rel install latest release"
32+
echo " rel[=version] install specific version"
33+
echo ""
34+
echo "Examples:"
35+
echo " Start existing install: kcw start-dev"
36+
echo " Install nightly and start: kcw nightly start-dev --cluster=none"
37+
exit
38+
else
39+
ARGS="$ARGS $1"
40+
fi
41+
42+
shift
43+
done
44+
45+
echo "###########################################################################################"
46+
echo "Installing: $INSTALL"
47+
echo "Executing: bin/kc.sh$ARGS"
48+
echo "###########################################################################################"
49+
50+
if [ "$INSTALL" != "" ]; then
51+
# Clean current install
52+
PID=$(ps -e -wwf | grep java | grep "$KC_DIR" | awk '{ print $2 }')
53+
if [ "$PID" != "" ]; then
54+
echo ""
55+
echo "-------------------------------------------------------------------------------------------"
56+
echo "Killing existing install"
57+
echo "-------------------------------------------------------------------------------------------"
58+
kill -9 $PID
59+
echo "Killed: $PID"
60+
fi
61+
if [ -d $KC_DIR ]; then
62+
echo ""
63+
echo "-------------------------------------------------------------------------------------------"
64+
echo "Deleting existing install"
65+
echo "-------------------------------------------------------------------------------------------"
66+
rm -rf $KC_DIR
67+
echo "Deleted $KC_DIR"
68+
fi
69+
70+
if [ "$INSTALL" == "dev" ]; then
71+
VERSION=$(cat $SRC_DIR/pom.xml | grep '<version>' | head -n 2 | tail -n 1 | cut -d '>' -f 2 | cut -d '<' -f 1)
72+
73+
if [ "$BUILD" ]; then
74+
echo ""
75+
echo "-------------------------------------------------------------------------------------------"
76+
echo "Building"
77+
echo "-------------------------------------------------------------------------------------------"
78+
79+
#mvn -pl quarkus/dist -am -DskipTests -f $SRC_DIR/pom.xml -T 1C --offline clean install
80+
cd $SRC_DIR
81+
./mvnw -T 1C -Dmaven.build.cache.enabled=true -DskipTests -DskipTestsuite -DskipExamples -DskipAdapters -DskipDocs install
82+
fi
83+
84+
echo ""
85+
echo "-------------------------------------------------------------------------------------------"
86+
echo "Installing"
87+
echo "-------------------------------------------------------------------------------------------"
88+
89+
cd /tmp/
90+
unzip -q $SRC_DIR/quarkus/dist/target/keycloak-$VERSION.zip
91+
mv keycloak-$VERSION $KC_DIR
92+
93+
echo "Built and installed $VERSION from $SRC_DIR"
94+
else
95+
VERSION=$INSTALL
96+
if [ "$INSTALL" == "nightly" ]; then
97+
VERSION=999.0.0-SNAPSHOT
98+
fi
99+
100+
echo ""
101+
echo "-------------------------------------------------------------------------------------------"
102+
echo "Installing"
103+
echo "-------------------------------------------------------------------------------------------"
104+
105+
cd $DL_DIR
106+
107+
if [ -f keycloak-$VERSION.zip ]; then
108+
if ( ! md5sum keycloak-$VERSION.zip | grep $(wget -q -O - https://github.com/keycloak/keycloak/releases/download/$INSTALL/keycloak-$VERSION.zip.md5) &>/dev/null ); then
109+
echo "Checksum doesn't match deleting keycloak-$VERSION.zip"
110+
rm keycloak-$VERSION.zip
111+
fi
112+
fi
113+
114+
if [ ! -f keycloak-$VERSION.zip ]; then
115+
cd $DL_DIR
116+
echo "Downloading keycloak-$VERSION.zip"
117+
wget -q https://github.com/keycloak/keycloak/releases/download/$INSTALL/keycloak-$VERSION.zip
118+
fi
119+
120+
cd /tmp/
121+
unzip -q $DL_DIR/keycloak-$VERSION.zip
122+
mv keycloak-$VERSION $KC_DIR
123+
124+
echo "Installed $VERSION"
125+
fi
126+
fi
127+
128+
if [ "$ARGS" != "" ]; then
129+
echo ""
130+
echo "-------------------------------------------------------------------------------------------"
131+
echo "Running: bin/kc.sh$ARGS"
132+
echo "-------------------------------------------------------------------------------------------"
133+
134+
export KC_BOOTSTRAP_ADMIN_USERNAME=admin
135+
export KC_BOOTSTRAP_ADMIN_PASSWORD=admin
136+
export KC_BOOTSTRAP_ADMIN_CLIENT_ID=admin
137+
export KC_BOOTSTRAP_ADMIN_CLIENT_SECRET=admin
138+
139+
cd $KC_DIR/bin
140+
141+
142+
./kc.sh $ARGS
143+
fi

0 commit comments

Comments
 (0)