ProxmoxVED/ct/homarr.sh
2025-12-11 20:38:34 +01:00

98 lines
3.2 KiB
Bash

#!/usr/bin/env bash
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/build.func)
# Copyright (c) 2021-2025 community-scripts ORG
# Author: CrazyWolf13
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://homarr.dev/
APP="homarr"
var_tags="${var_tags:-arr;dashboard}"
var_cpu="${var_cpu:-2}"
var_ram="${var_ram:-1024}"
var_disk="${var_disk:-8}"
var_os="${var_os:-debian}"
var_version="${var_version:-13}"
var_unprivileged="${var_unprivileged:-1}"
header_info "$APP"
variables
color
catch_errors
function update_script() {
header_info
check_container_storage
check_container_resources
if [[ ! -d /opt/homarr ]]; then
msg_error "No ${APP} Installation Found!"
exit
fi
if check_for_gh_release "homarr" "Meierschlumpf/homarr"; then
msg_info "Stopping Services (Patience)"
systemctl stop homarr
systemctl stop redis-server
msg_ok "Services Stopped"
if ! grep -q '^REDIS_IS_EXTERNAL=' /opt/homarr/.env; then
msg_info "Fixing old structure"
$STD apt install -y musl-dev
ln -s /usr/lib/x86_64-linux-musl/libc.so /lib/libc.musl-x86_64.so.1
echo "REDIS_IS_EXTERNAL='true'" >> /opt/homarr/.env
sed -i 's|^ExecStart=.*|ExecStart=/opt/homarr/run.sh|' /etc/systemd/system/homarr.service
sed -i 's|^EnvironmentFile=.*|EnvironmentFile=-/opt/homarr.env|' /etc/systemd/system/homarr.service
chown -R redis:redis /appdata/redis
chmod 755 /appdata/redis
mkdir -p /etc/systemd/system/redis-server.service.d/
cat > /etc/systemd/system/redis-server.service.d/override.conf << 'EOF'
[Service]
ReadWritePaths=-/appdata/redis -/var/lib/redis -/var/log/redis -/var/run/redis -/etc/redis
EOF
# TODO: change in json
systemctl daemon-reload
cp /opt/homarr/.env /opt/homarr.env
rm /opt/run_homarr.sh
msg_ok "Fixed old structure"
fi
msg_info "Updating Nodejs"
$STD apt update
$STD apt upgrade nodejs -y
msg_ok "Updated Nodejs"
NODE_VERSION=$(curl -s https://raw.githubusercontent.com/homarr-labs/homarr/dev/package.json | jq -r '.engines.node | split(">=")[1] | split(".")[0]')
setup_nodejs
rm -rf /opt/homarr
fetch_and_deploy_gh_release "homarr" "Meierschlumpf/homarr" "prebuild" "latest" "/opt/homarr" "source-amd64.tar"
msg_info "Updating Homarr to v${RELEASE}"
cp /opt/homarr/redis.conf /etc/redis/redis.conf
rm /etc/nginx/nginx.conf
mkdir -p /etc/nginx/templates
cp /opt/homarr/nginx.conf /etc/nginx/templates/nginx.conf
echo $'#!/bin/bash\ncd /opt/homarr/apps/cli && node ./cli.cjs "$@"' >/usr/bin/homarr
chmod +x /usr/bin/homarr
msg_ok "Updated ${APP}"
msg_info "Starting Services"
chmod +x /opt/homarr/run.sh
systemctl start homarr
systemctl start redis-server
msg_ok "Started Services"
msg_ok "Updated successfully!"
fi
exit
}
start
build_container
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}:7575${CL}"