|
1 | 1 | #!/usr/bin/env bash
|
2 | 2 |
|
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 |
7 | 7 |
|
8 |
| -source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" |
| 8 | +source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" |
9 | 9 | color
|
10 | 10 | verb_ip6
|
11 | 11 | catch_errors
|
12 | 12 | setting_up_container
|
13 | 13 | network_check
|
14 | 14 | update_os
|
15 | 15 |
|
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 |
22 | 22 | msg_ok "Installed Dependencies"
|
23 | 23 |
|
| 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) |
24 | 33 | 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 |
30 | 37 | msg_ok "Installed Keycloak"
|
31 | 38 |
|
32 | 39 | 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 | +
|
37 | 45 | [Service]
|
38 | 46 | User=root
|
39 | 47 | WorkingDirectory=/opt/keycloak
|
40 | 48 | ExecStart=/opt/keycloak/bin/kc.sh start-dev
|
| 49 | +
|
41 | 50 | [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 |
44 | 54 | msg_ok "Created Service"
|
45 | 55 |
|
46 | 56 | motd_ssh
|
47 | 57 | customize
|
48 | 58 |
|
49 | 59 | msg_info "Cleaning up"
|
| 60 | +rm -f $temp_file |
50 | 61 | $STD apt-get -y autoremove
|
51 | 62 | $STD apt-get -y autoclean
|
52 | 63 | msg_ok "Cleaned"
|
0 commit comments