keycloak-install.sh 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/usr/bin/env bash
  2. # Copyright (c) 2021-2023 tteck
  3. # Author: tteck (tteckster)
  4. # License: MIT
  5. # https://github.com/tteck/Proxmox/raw/main/LICENSE
  6. source /dev/stdin <<< "$FUNCTIONS_FILE_PATH"
  7. color
  8. verb_ip6
  9. catch_errors
  10. setting_up_container
  11. network_check
  12. update_os
  13. msg_info "Installing Dependencies (Patience)"
  14. $STD apt-get install -y curl
  15. $STD apt-get install -y sudo
  16. $STD apt-get install -y mc
  17. $STD apt-get install -y ca-certificates-java
  18. $STD apt-get install -y openjdk-17-jre-headless
  19. msg_ok "Installed Dependencies"
  20. RELEASE=$(curl -s https://api.github.com/repos/keycloak/keycloak/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
  21. msg_info "Installing Keycloak v$RELEASE"
  22. cd /opt
  23. wget -q https://github.com/keycloak/keycloak/releases/download/$RELEASE/keycloak-$RELEASE.tar.gz
  24. $STD tar -xvf keycloak-$RELEASE.tar.gz
  25. mv keycloak-$RELEASE keycloak
  26. msg_ok "Installed Keycloak"
  27. msg_info "Creating Service"
  28. service_path="/etc/systemd/system/keycloak.service"
  29. echo "[Unit]
  30. Description=Keycloak
  31. After=network-online.target
  32. [Service]
  33. User=root
  34. WorkingDirectory=/opt/keycloak
  35. ExecStart=/opt/keycloak/bin/kc.sh start-dev
  36. [Install]
  37. WantedBy=multi-user.target" >$service_path
  38. $STD systemctl enable --now keycloak.service
  39. msg_ok "Created Service"
  40. motd_ssh
  41. customize
  42. msg_info "Cleaning up"
  43. $STD apt-get autoremove
  44. $STD apt-get autoclean
  45. msg_ok "Cleaned"