1
0
mirror of https://github.com/community-scripts/ProxmoxVE.git synced 2025-02-01 18:31:51 +00:00
ProxmoxVE/install/homarr-install.sh

95 lines
2.5 KiB
Bash
Raw Permalink Normal View History

2023-08-16 08:56:17 -04:00
#!/usr/bin/env bash
2025-01-28 16:32:44 +01:00
# Copyright (c) 2021-2025 community-scripts ORG
# Author: MickLesk (Canbiz)
2025-01-28 16:50:30 +01:00
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://github.com/ajnart/homarr
2023-08-16 08:56:17 -04:00
source /dev/stdin <<< "$FUNCTIONS_FILE_PATH"
color
verb_ip6
catch_errors
setting_up_container
network_check
update_os
msg_info "Installing Dependencies"
$STD apt-get install -y \
sudo \
mc \
curl \
2025-01-28 16:32:44 +01:00
redis-server \
ca-certificates \
gnupg \
make \
g++ \
2025-01-04 00:09:47 +01:00
build-essential
2023-08-16 08:56:17 -04:00
msg_ok "Installed Dependencies"
msg_info "Setting up Node.js Repository"
2023-09-02 08:36:54 -04:00
mkdir -p /etc/apt/keyrings
2023-09-01 07:19:05 -04:00
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
2025-01-28 16:32:44 +01:00
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_22.x nodistro main" >/etc/apt/sources.list.d/nodesource.list
2023-08-16 08:56:17 -04:00
msg_ok "Set up Node.js Repository"
2025-01-28 16:32:44 +01:00
msg_info "Installing Node.js/pnpm"
2023-09-01 07:19:05 -04:00
$STD apt-get update
2023-08-16 08:56:17 -04:00
$STD apt-get install -y nodejs
2025-01-28 18:24:06 +01:00
$STD npm install -g pnpm@latest
2025-01-28 16:32:44 +01:00
msg_ok "Installed Node.js/pnpm"
2023-08-16 08:56:17 -04:00
msg_info "Installing Homarr (Patience)"
2025-01-28 16:32:44 +01:00
cd /opt
RELEASE=$(curl -s https://api.github.com/repos/homarr-labs/homarr/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
wget -q "https://github.com/homarr-labs/homarr/archive/refs/tags/v${RELEASE}.zip"
unzip -q v${RELEASE}.zip
mv homarr-${RELEASE} /opt/homarr
2025-01-28 16:32:44 +01:00
mkdir -p /opt/homarr_db
touch /opt/homarr_db/db.sqlite
AUTH_SECRET="$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | cut -c1-13)"
2025-01-28 16:59:27 +01:00
SECRET_ENCRYPTION_KEY="$(openssl rand -hex 32)"
2025-01-28 16:32:44 +01:00
2024-04-14 23:53:22 -04:00
cat <<EOF >/opt/homarr/.env
2025-01-28 16:59:27 +01:00
AUTH_SECRET='${AUTH_SECRET}'
2025-01-28 16:32:44 +01:00
DB_DRIVER='better-sqlite3'
2025-01-28 16:59:27 +01:00
SECRET_ENCRYPTION_KEY='${SECRET_ENCRYPTION_KEY}'
2025-01-28 16:32:44 +01:00
DB_URL='/opt/homarr_db/db.sqlite'
TURBO_TELEMETRY_DISABLED=1
2024-04-14 23:53:22 -04:00
EOF
2025-01-28 16:32:44 +01:00
2023-08-16 08:56:17 -04:00
cd /opt/homarr
2025-01-28 16:50:30 +01:00
$STD pnpm install
2025-01-28 16:32:44 +01:00
$STD pnpm run db:migration:sqlite:run
$STD pnpm build
mkdir build
cp ./node_modules/better-sqlite3/build/Release/better_sqlite3.node ./build/better_sqlite3.node
echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt"
2023-08-16 08:56:17 -04:00
msg_ok "Installed Homarr"
msg_info "Creating Service"
cat <<EOF >/etc/systemd/system/homarr.service
[Unit]
Description=Homarr Service
After=network.target
[Service]
Type=exec
WorkingDirectory=/opt/homarr
EnvironmentFile=-/opt/homarr/.env
2025-01-28 16:32:44 +01:00
ExecStart=/usr/bin/pnpm start
2023-08-16 08:56:17 -04:00
[Install]
WantedBy=multi-user.target
EOF
2025-01-28 16:32:44 +01:00
systemctl enable -q --now homarr
2023-08-16 08:56:17 -04:00
msg_ok "Created Service"
motd_ssh
customize
msg_info "Cleaning up"
2025-01-28 16:32:44 +01:00
rm -rf /opt/v${RELEASE}.zip
2024-05-02 13:26:16 -04:00
$STD apt-get -y autoremove
$STD apt-get -y autoclean
2023-08-16 08:56:17 -04:00
msg_ok "Cleaned"