1
0
mirror of https://github.com/community-scripts/ProxmoxVE.git synced 2025-02-01 14:51:50 +00:00

Breaking Change: Homarr (#1825)

This commit is contained in:
CanbiZ 2025-01-28 16:32:44 +01:00 committed by GitHub
parent b973ca9d8d
commit dae705056c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 48 additions and 39 deletions

View File

@ -32,46 +32,46 @@ function update_script() {
msg_error "No ${APP} Installation Found!"
exit
fi
RELEASE=$(curl -s https://api.github.com/repos/ajnart/homarr/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
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
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) }')
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
msg_info "Stopping Services"
systemctl stop homarr
msg_ok "Services Stopped"
msg_info "Backing up Data"
msg_info "Backup Data"
mkdir -p /opt/homarr-data-backup
cp /opt/homarr/.env /opt/homarr-data-backup/.env
cp /opt/homarr/database/db.sqlite /opt/homarr-data-backup/db.sqlite
cp -r /opt/homarr/data/configs /opt/homarr-data-backup/configs
msg_ok "Backed up Data"
msg_ok "Backup Data"
msg_info "Updating ${APP} to ${RELEASE}"
wget -q "https://github.com/ajnart/homarr/archive/refs/tags/v${RELEASE}.zip"
msg_info "Updating ${APP} to v${RELEASE}"
wget -q "https://github.com/homarr-labs/homarr/archive/refs/tags/v${RELEASE}.zip"
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
yarn install &>/dev/null
yarn build &>/dev/null
pnpm run db:migration:sqlite:run &>/dev/null
pnpm build &>/dev/null
mkdir build
cp ./node_modules/better-sqlite3/build/Release/better_sqlite3.node ./build/better_sqlite3.node
echo "${RELEASE}" >/opt/${APP}_version.txt
msg_ok "Updated ${APP}"
msg_info "Restoring Data"
rm -rf /opt/homarr/data/configs
mv /opt/homarr-data-backup/configs /opt/homarr/data/configs
mv /opt/homarr-data-backup/db.sqlite /opt/homarr/database/db.sqlite
yarn db:migrate &>/dev/null
rm -rf /opt/homarr-data-backup
msg_ok "Restored Data"
msg_info "Starting Services"
systemctl start homarr
msg_ok "Started Services"
msg_ok "Updated Successfully"
else
msg_ok "No update required. ${APP} is already at ${RELEASE}"
msg_ok "No update required. ${APP} is already at v${RELEASE}"
fi
exit
}
@ -83,4 +83,4 @@ description
msg_ok "Completed Successfully!\n"
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:3000${CL}"
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:3000${CL}"

View File

@ -1,8 +1,7 @@
#!/usr/bin/env bash
# Copyright (c) 2021-2025 tteck
# Author: tteck (tteckster)
# Co-Author: MickLesk (Canbiz)
# Copyright (c) 2021-2025 community-scripts ORG
# Author: MickLesk (Canbiz)
# License: MIT
# https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://github.com/ajnart/homarr
@ -20,6 +19,7 @@ $STD apt-get install -y \
sudo \
mc \
curl \
redis-server \
ca-certificates \
gnupg \
make \
@ -30,32 +30,40 @@ msg_ok "Installed Dependencies"
msg_info "Setting up Node.js Repository"
mkdir -p /etc/apt/keyrings
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
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
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
msg_ok "Set up Node.js Repository"
msg_info "Installing Node.js/Yarn"
msg_info "Installing Node.js/pnpm"
$STD apt-get update
$STD apt-get install -y nodejs
$STD npm install -g yarn
msg_ok "Installed Node.js/Yarn"
$STD npm install -g pnpm
msg_ok "Installed Node.js/pnpm"
msg_info "Installing Homarr (Patience)"
RELEASE=$(curl -s https://api.github.com/repos/ajnart/homarr/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
wget -q "https://github.com/ajnart/homarr/archive/refs/tags/v${RELEASE}.zip"
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
rm -rf v${RELEASE}.zip
mv homarr-${RELEASE} /opt/homarr
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)"
SECRET_ENCRYPTION_KEY="$(openssl rand -base64 32 | tr -dc 'a-zA-Z0-9' | cut -c1-32)"
cat <<EOF >/opt/homarr/.env
DATABASE_URL="file:./database/db.sqlite"
NEXTAUTH_URL="http://localhost:3000"
NEXTAUTH_SECRET="$(openssl rand -base64 32)"
NEXT_PUBLIC_DISABLE_ANALYTICS="true"
DEFAULT_COLOR_SCHEME="dark"
AUTH_SECRET="${AUTH_SECRET}"
DB_DRIVER='better-sqlite3'
SECRET_ENCRYPTION_KEY="${SECRET_ENCRYPTION_KEY}"
DB_URL='/opt/homarr_db/db.sqlite'
TURBO_TELEMETRY_DISABLED=1
NODE_OPTIONS='-r @homarr/log/override'
EOF
cd /opt/homarr
$STD yarn install
$STD yarn build
$STD yarn db:migrate
$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"
msg_ok "Installed Homarr"
@ -69,18 +77,19 @@ After=network.target
Type=exec
WorkingDirectory=/opt/homarr
EnvironmentFile=-/opt/homarr/.env
ExecStart=/usr/bin/yarn start
ExecStart=/usr/bin/pnpm start
[Install]
WantedBy=multi-user.target
EOF
systemctl enable -q --now homarr.service
systemctl enable -q --now homarr
msg_ok "Created Service"
motd_ssh
customize
msg_info "Cleaning up"
rm -rf /opt/v${RELEASE}.zip
$STD apt-get -y autoremove
$STD apt-get -y autoclean
msg_ok "Cleaned"