Repository navigation
Expand file tree
/
Copy pathkcw
More file actions
executable file
·162 lines (136 loc) · 5.26 KB
/
Copy pathkcw
File metadata and controls
executable file
·162 lines (136 loc) · 5.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#!/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 "Environment variables:"
echo " KCW_PROVIDERS comma separated list of providers to install"
echo " KCW_CONFIGS comma separated list of config files to install"
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 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 "-------------------------------------------------------------------------------------------"
mkdir -p "$DL_DIR"
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 [ "$KCW_PROVIDERS" != "" ]; then
for PROVIDER in $(echo "$KCW_PROVIDERS" | tr "," "\n"); do
cp "$PROVIDER" $KC_DIR/providers/
echo "Installed provider: $PROVIDER"
done
fi
if [ "$KCW_CONFIGS" != "" ]; then
for CONFIG in $(echo "$KCW_CONFIGS" | tr "," "\n"); do
cp "$CONFIG" $KC_DIR/conf/
echo "Installed config file: $CONFIG"
done
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