Skip to content

Commit 0ac0cc2

Browse files
authored
Keycloak: Update installation script (#2714)
* Update installation script * fixed tar command * fix tar again * fixes * Update keycloak-install.sh
1 parent c730b5c commit 0ac0cc2

File tree

1 file changed

+33
-22
lines changed

1 file changed

+33
-22
lines changed

install/keycloak-install.sh

+33-22
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,63 @@
11
#!/usr/bin/env bash
22

3-
# Copyright (c) 2021-2025 tteck
4-
# Author: tteck (tteckster)
5-
# License: MIT
6-
# https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
3+
# Copyright (c) 2021-2025 community-scripts ORG
4+
# Author: tteck (tteckster) | Co-Author: Slaviša Arežina (tremor021)
5+
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
6+
# Source: https://github.com/keycloak/keycloak
77

8-
source /dev/stdin <<< "$FUNCTIONS_FILE_PATH"
8+
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
99
color
1010
verb_ip6
1111
catch_errors
1212
setting_up_container
1313
network_check
1414
update_os
1515

16-
msg_info "Installing Dependencies (Patience)"
17-
$STD apt-get install -y curl
18-
$STD apt-get install -y sudo
19-
$STD apt-get install -y mc
20-
$STD apt-get install -y ca-certificates-java
21-
$STD apt-get install -y openjdk-17-jre-headless
16+
msg_info "Installing Dependencies"
17+
$STD apt-get install -y \
18+
curl \
19+
sudo \
20+
mc \
21+
gnupg
2222
msg_ok "Installed Dependencies"
2323

24+
msg_info "Installing OpenJDK"
25+
wget -qO- https://packages.adoptium.net/artifactory/api/gpg/key/public | gpg --dearmor >/etc/apt/trusted.gpg.d/adoptium.gpg
26+
echo 'deb [arch=amd64 signed-by=/etc/apt/trusted.gpg.d/adoptium.gpg] https://packages.adoptium.net/artifactory/deb bookworm main' >/etc/apt/sources.list.d/adoptium.list
27+
$STD apt-get update
28+
$STD apt-get install -y temurin-21-jre
29+
msg_ok "Installed OpenJDK"
30+
31+
msg_info "Installing Keycloak"
32+
temp_file=$(mktemp)
2433
RELEASE=$(curl -s https://api.github.com/repos/keycloak/keycloak/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
25-
msg_info "Installing Keycloak v$RELEASE"
26-
cd /opt
27-
wget -q https://github.com/keycloak/keycloak/releases/download/$RELEASE/keycloak-$RELEASE.tar.gz
28-
$STD tar -xvf keycloak-$RELEASE.tar.gz
29-
mv keycloak-$RELEASE keycloak
34+
wget -q https://github.com/keycloak/keycloak/releases/download/$RELEASE/keycloak-$RELEASE.tar.gz -O $temp_file
35+
tar xzf $temp_file
36+
mv keycloak-$RELEASE /opt/keycloak
3037
msg_ok "Installed Keycloak"
3138

3239
msg_info "Creating Service"
33-
service_path="/etc/systemd/system/keycloak.service"
34-
echo "[Unit]
35-
Description=Keycloak
36-
After=network-online.target
40+
cat <<EOF >/etc/systemd/system/keycloak.service
41+
[Unit]
42+
Description=Keycloak Service
43+
After=network.target
44+
3745
[Service]
3846
User=root
3947
WorkingDirectory=/opt/keycloak
4048
ExecStart=/opt/keycloak/bin/kc.sh start-dev
49+
4150
[Install]
42-
WantedBy=multi-user.target" >$service_path
43-
$STD systemctl enable --now keycloak.service
51+
WantedBy=multi-user.target
52+
EOF
53+
systemctl enable -q --now keycloak
4454
msg_ok "Created Service"
4555

4656
motd_ssh
4757
customize
4858

4959
msg_info "Cleaning up"
60+
rm -f $temp_file
5061
$STD apt-get -y autoremove
5162
$STD apt-get -y autoclean
5263
msg_ok "Cleaned"

0 commit comments

Comments
 (0)