homarr-install.sh 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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"
  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 git
  18. $STD apt-get install -y ca-certificates
  19. $STD apt-get install -y gnupg
  20. msg_ok "Installed Dependencies"
  21. msg_info "Setting up Node.js Repository"
  22. mkdir -p /etc/apt/keyrings
  23. curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
  24. echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" >/etc/apt/sources.list.d/nodesource.list
  25. msg_ok "Set up Node.js Repository"
  26. msg_info "Installing Node.js/Yarn"
  27. $STD apt-get update
  28. $STD apt-get install -y nodejs
  29. $STD npm install -g npm@latest
  30. $STD npm install -g yarn
  31. msg_ok "Installed Node.js/Yarn"
  32. msg_info "Installing Homarr (Patience)"
  33. mkdir -p /opt/homarr
  34. RELEASE=$(curl -s https://api.github.com/repos/ajnart/homarr/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
  35. wget -q -O- https://github.com/ajnart/homarr/archive/refs/tags/v${RELEASE}.tar.gz | $STD tar -xz -C /opt && mv /opt/homarr-${RELEASE}/* /opt/homarr
  36. rm -rf /opt/homarr-${RELEASE}
  37. cd /opt/homarr
  38. wget -q -O /opt/homarr/.env https://raw.githubusercontent.com/ajnart/homarr/dev/.env.example
  39. sed -i 's|NEXTAUTH_SECRET="[^"]*"|NEXTAUTH_SECRET="'"$(openssl rand -base64 32)"'"|' /opt/homarr/.env
  40. $STD yarn install
  41. $STD yarn build
  42. $STD yarn db:migrate
  43. msg_ok "Installed Homarr"
  44. msg_info "Creating Service"
  45. cat <<EOF >/etc/systemd/system/homarr.service
  46. [Unit]
  47. Description=Homarr Service
  48. After=network.target
  49. [Service]
  50. Type=exec
  51. WorkingDirectory=/opt/homarr
  52. EnvironmentFile=-/opt/homarr/.env
  53. ExecStart=/usr/bin/yarn start
  54. [Install]
  55. WantedBy=multi-user.target
  56. EOF
  57. systemctl enable -q --now homarr.service
  58. msg_ok "Created Service"
  59. motd_ssh
  60. customize
  61. msg_info "Cleaning up"
  62. $STD apt-get autoremove
  63. $STD apt-get autoclean
  64. msg_ok "Cleaned"