diff --git a/ct/homarr.sh b/ct/homarr.sh index 0fc3ce9fe..ced4e467a 100644 --- a/ct/homarr.sh +++ b/ct/homarr.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) # Copyright (c) 2021-2025 tteck -# Author: tteck (tteckster) | Co-Author: MickLesk (Canbiz) +# Author: tteck (tteckster) | Co-Author: MickLesk (Canbiz) | Co-Author: CrazyWolf13 # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE # Source: https://homarr.dev/ @@ -15,6 +15,7 @@ var_version="12" var_unprivileged="1" header_info "$APP" + variables color catch_errors @@ -37,7 +38,7 @@ 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" + msg_info "Stopping Services (Patience)" systemctl stop homarr msg_ok "Services Stopped" @@ -55,9 +56,23 @@ fi mv /opt/homarr-data-backup/.env /opt/homarr/.env cd /opt/homarr pnpm install &>/dev/null - pnpm run db:migration:sqlite:run &>/dev/null pnpm build &>/dev/null - mkdir build + 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 cp ./node_modules/better-sqlite3/build/Release/better_sqlite3.node ./build/better_sqlite3.node echo "${RELEASE}" >/opt/${APP}_version.txt msg_ok "Updated ${APP}" @@ -79,4 +94,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}:7575${CL}" diff --git a/install/homarr-install.sh b/install/homarr-install.sh index 6a0ba36b6..bb2aaae73 100644 --- a/install/homarr-install.sh +++ b/install/homarr-install.sh @@ -3,7 +3,7 @@ # 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 +# Source: https://github.com/homarr-labs/homarr source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" color @@ -20,10 +20,13 @@ $STD apt-get install -y \ curl \ redis-server \ ca-certificates \ - gnupg \ + gpg \ make \ g++ \ - build-essential + build-essential \ + nginx \ + gettext \ + openssl msg_ok "Installed Dependencies" msg_info "Setting up Node.js Repository" @@ -46,27 +49,56 @@ unzip -q 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 -hex 32)" - +cd /opt/homarr cat </opt/homarr/.env -AUTH_SECRET='${AUTH_SECRET}' DB_DRIVER='better-sqlite3' +DB_DIALECT='sqlite' SECRET_ENCRYPTION_KEY='${SECRET_ENCRYPTION_KEY}' DB_URL='/opt/homarr_db/db.sqlite' TURBO_TELEMETRY_DISABLED=1 +AUTH_PROVIDERS='credentials' +NODE_ENV='production' EOF - -cd /opt/homarr $STD pnpm install -$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" -msg_info "Creating Service" +msg_info "Copying build and config files" +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 +mkdir -p /etc/nginx/templates +rm /etc/nginx/nginx.conf +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 +cp ./node_modules/better-sqlite3/build/Release/better_sqlite3.node ./build/better_sqlite3.node +echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt" +msg_ok "Finished copying" + +msg_info "Creating Services" +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 cat </etc/systemd/system/homarr.service [Unit] Description=Homarr Service @@ -76,7 +108,7 @@ After=network.target Type=exec WorkingDirectory=/opt/homarr EnvironmentFile=-/opt/homarr/.env -ExecStart=/usr/bin/pnpm start +ExecStart=/opt/run_homarr.sh [Install] WantedBy=multi-user.target diff --git a/json/homarr.json b/json/homarr.json index ad0b72498..abbfda375 100644 --- a/json/homarr.json +++ b/json/homarr.json @@ -8,7 +8,7 @@ "type": "ct", "updateable": true, "privileged": false, - "interface_port": 3000, + "interface_port": 7575, "documentation": null, "website": "https://homarr.dev/", "logo": "https://raw.githubusercontent.com/loganmarchione/homelab-svg-assets/main/assets/homarr.svg",