2023-08-16 14:57:18 +02:00
|
|
|
#!/usr/bin/env bash
|
2024-11-02 08:48:05 +01:00
|
|
|
source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
|
2025-01-01 13:37:29 +01:00
|
|
|
# Copyright (c) 2021-2025 tteck
|
2025-02-14 12:09:35 +01:00
|
|
|
# Author: tteck (tteckster) | Co-Author: MickLesk (Canbiz) | Co-Author: CrazyWolf13
|
2024-12-16 12:42:51 +01:00
|
|
|
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
|
|
|
# Source: https://homarr.dev/
|
2023-08-16 14:57:18 +02:00
|
|
|
|
|
|
|
APP="Homarr"
|
2024-12-16 13:31:48 +01:00
|
|
|
var_tags="arr;dashboard"
|
2023-08-16 14:57:18 +02:00
|
|
|
var_cpu="2"
|
2025-01-28 21:13:21 +01:00
|
|
|
var_ram="4096"
|
2024-12-16 12:42:51 +01:00
|
|
|
var_disk="8"
|
2023-08-16 14:57:18 +02:00
|
|
|
var_os="debian"
|
|
|
|
var_version="12"
|
2024-12-16 12:42:51 +01:00
|
|
|
var_unprivileged="1"
|
|
|
|
|
|
|
|
header_info "$APP"
|
2025-02-14 12:09:35 +01:00
|
|
|
|
2023-08-16 14:57:18 +02:00
|
|
|
variables
|
|
|
|
color
|
|
|
|
catch_errors
|
|
|
|
|
|
|
|
function update_script() {
|
2024-12-16 12:42:51 +01:00
|
|
|
header_info
|
|
|
|
check_container_storage
|
|
|
|
check_container_resources
|
|
|
|
if [[ ! -d /opt/homarr ]]; then
|
|
|
|
msg_error "No ${APP} Installation Found!"
|
|
|
|
exit
|
|
|
|
fi
|
2025-01-28 16:32:44 +01:00
|
|
|
if [[ -f /opt/homarr/database/db.sqlite ]]; then
|
|
|
|
msg_error "Old Homarr detected due to existing database file (/opt/homarr/database/db.sqlite)."
|
|
|
|
msg_error "Update not supported. Refer to:"
|
|
|
|
msg_error " - https://github.com/community-scripts/ProxmoxVE/discussions/1551"
|
|
|
|
msg_error " - https://homarr.dev/docs/getting-started/after-the-installation/#importing-a-zip-from-version-before-100"
|
|
|
|
exit 1
|
2025-02-15 16:13:48 +01:00
|
|
|
fi
|
|
|
|
if [[ ! -f /opt/run_homarr.sh ]]; then
|
|
|
|
msg_info "Detected outdated and missing service files"
|
|
|
|
msg_error "Warning - The port of homarr changed from 3000 to 7575"
|
|
|
|
apt-get install -y nginx gettext openssl gpg &>/dev/null
|
|
|
|
sed -i '/^NODE_ENV=/d' /opt/homarr/.env && echo "NODE_ENV='production'" >> /opt/homarr/.env
|
|
|
|
sed -i '/^DB_DIALECT=/d' /opt/homarr/.env && echo "DB_DIALECT='sqlite'" >> /opt/homarr/.env
|
|
|
|
cat <<'EOF' >/opt/run_homarr.sh
|
|
|
|
#!/bin/bash
|
|
|
|
export DB_DIALECT='sqlite'
|
|
|
|
export AUTH_SECRET=$(openssl rand -base64 32)
|
|
|
|
node /opt/homarr_db/migrations/$DB_DIALECT/migrate.cjs /opt/homarr_db/migrations/$DB_DIALECT
|
|
|
|
export HOSTNAME=$(ip route get 1.1.1.1 | grep -oP 'src \K[^ ]+')
|
|
|
|
envsubst '${HOSTNAME}' < /etc/nginx/templates/nginx.conf > /etc/nginx/nginx.conf
|
|
|
|
nginx -g 'daemon off;' &
|
|
|
|
redis-server /opt/homarr/packages/redis/redis.conf &
|
|
|
|
node apps/tasks/tasks.cjs &
|
|
|
|
node apps/websocket/wssServer.cjs &
|
|
|
|
node apps/nextjs/server.js & PID=$!
|
|
|
|
wait $PID
|
|
|
|
EOF
|
|
|
|
chmod +x /opt/run_homarr.sh
|
|
|
|
rm /etc/systemd/system/homarr.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
|
|
|
|
ExecStart=/opt/run_homarr.sh
|
|
|
|
[Install]
|
|
|
|
WantedBy=multi-user.target
|
|
|
|
EOF
|
|
|
|
msg_ok "Updated Services"
|
|
|
|
systemctl daemon-reload
|
2025-01-28 16:32:44 +01:00
|
|
|
fi
|
|
|
|
RELEASE=$(curl -s https://api.github.com/repos/homarr-labs/homarr/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
|
2024-12-16 12:42:51 +01:00
|
|
|
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
|
2025-01-28 16:32:44 +01:00
|
|
|
|
2025-02-14 12:09:35 +01:00
|
|
|
msg_info "Stopping Services (Patience)"
|
2024-12-16 12:42:51 +01:00
|
|
|
systemctl stop homarr
|
|
|
|
msg_ok "Services Stopped"
|
2024-11-08 11:34:07 +01:00
|
|
|
|
2025-01-28 16:32:44 +01:00
|
|
|
msg_info "Backup Data"
|
2024-12-16 12:42:51 +01:00
|
|
|
mkdir -p /opt/homarr-data-backup
|
|
|
|
cp /opt/homarr/.env /opt/homarr-data-backup/.env
|
2025-01-28 16:32:44 +01:00
|
|
|
msg_ok "Backup Data"
|
2024-11-10 17:20:37 +01:00
|
|
|
|
2025-02-15 16:13:48 +01:00
|
|
|
msg_info "Updating and rebuilding ${APP} to v${RELEASE} (Patience)"
|
2025-01-28 16:32:44 +01:00
|
|
|
wget -q "https://github.com/homarr-labs/homarr/archive/refs/tags/v${RELEASE}.zip"
|
2024-12-16 12:42:51 +01:00
|
|
|
unzip -q v${RELEASE}.zip
|
|
|
|
rm -rf v${RELEASE}.zip
|
|
|
|
rm -rf /opt/homarr
|
|
|
|
mv homarr-${RELEASE} /opt/homarr
|
|
|
|
mv /opt/homarr-data-backup/.env /opt/homarr/.env
|
|
|
|
cd /opt/homarr
|
2025-01-28 16:53:33 +01:00
|
|
|
pnpm install &>/dev/null
|
2025-01-28 16:32:44 +01:00
|
|
|
pnpm build &>/dev/null
|
2025-02-14 12:09:35 +01:00
|
|
|
cp /opt/homarr/apps/nextjs/next.config.ts .
|
|
|
|
cp /opt/homarr/apps/nextjs/package.json .
|
|
|
|
cp -r /opt/homarr/packages/db/migrations /opt/homarr_db/migrations
|
|
|
|
cp -r /opt/homarr/apps/nextjs/.next/standalone/* /opt/homarr
|
|
|
|
mkdir -p /appdata/redis
|
|
|
|
cp /opt/homarr/packages/redis/redis.conf /opt/homarr/redis.conf
|
|
|
|
rm /etc/nginx/nginx.conf
|
|
|
|
mkdir -p /etc/nginx/templates
|
|
|
|
cp /opt/homarr/nginx.conf /etc/nginx/templates/nginx.conf
|
|
|
|
|
|
|
|
mkdir -p /opt/homarr/apps/cli
|
|
|
|
cp /opt/homarr/packages/cli/cli.cjs /opt/homarr/apps/cli/cli.cjs
|
|
|
|
echo $'#!/bin/bash\ncd /opt/homarr/apps/cli && node ./cli.cjs "$@"' > /usr/bin/homarr
|
|
|
|
chmod +x /usr/bin/homarr
|
|
|
|
|
|
|
|
mkdir /opt/homarr/build
|
2025-01-28 16:32:44 +01:00
|
|
|
cp ./node_modules/better-sqlite3/build/Release/better_sqlite3.node ./build/better_sqlite3.node
|
2024-12-16 12:42:51 +01:00
|
|
|
echo "${RELEASE}" >/opt/${APP}_version.txt
|
|
|
|
msg_ok "Updated ${APP}"
|
2024-11-08 11:34:07 +01:00
|
|
|
|
2024-12-16 12:42:51 +01:00
|
|
|
msg_info "Starting Services"
|
|
|
|
systemctl start homarr
|
|
|
|
msg_ok "Started Services"
|
|
|
|
msg_ok "Updated Successfully"
|
|
|
|
else
|
2025-01-28 16:32:44 +01:00
|
|
|
msg_ok "No update required. ${APP} is already at v${RELEASE}"
|
2024-12-16 12:42:51 +01:00
|
|
|
fi
|
|
|
|
exit
|
2023-08-16 14:57:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
start
|
|
|
|
build_container
|
|
|
|
description
|
|
|
|
|
|
|
|
msg_ok "Completed Successfully!\n"
|
2024-12-16 12:42:51 +01:00
|
|
|
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
|
|
|
|
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
|
2025-02-14 12:09:35 +01:00
|
|
|
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:7575${CL}"
|