Compare commits

..

3 Commits

Author SHA1 Message Date
7bc97edce6 Update systemd service in jotty update script
- Recreate systemd service file with correct ExecStart command
- Change from 'yarn start' to '/usr/bin/node server.js'
- Ensures old installations get updated service configuration
- Run daemon-reload after service file update
2025-12-21 22:59:32 +01:00
9fe00ae3c6 Apply standalone mode optimization to Jotty update script
- Use standalone mode in update_script function
- Ensures updates maintain the optimized deployment structure
- Consistent with install script changes
2025-12-21 22:58:18 +01:00
f139c6960f Optimize Jotty installation with standalone mode
- Use Next.js standalone mode to reduce folder size from ~2.4GB to ~80MB
- Copy public, howto, and static folders to standalone output
- Remove node_modules and build artifacts after creating standalone version
- Update systemd service to use node directly instead of yarn start
- Improves build efficiency and reduces disk usage

Implements #10178
Co-authored-by: fccview <fccview@users.noreply.github.com>
2025-12-21 22:57:33 +01:00
4 changed files with 52 additions and 17 deletions

View File

@ -48,6 +48,17 @@ function update_script() {
$STD yarn --frozen-lockfile $STD yarn --frozen-lockfile
$STD yarn next telemetry disable $STD yarn next telemetry disable
$STD yarn build $STD yarn build
[ -d "public" ] && cp -r public .next/standalone/
[ -d "howto" ] && cp -r howto .next/standalone/
mkdir -p .next/standalone/.next
cp -r .next/static .next/standalone/.next/
mv .next/standalone /tmp/jotty_standalone
rm -rf * .next .git .gitignore .yarn
mv /tmp/jotty_standalone/* .
mv /tmp/jotty_standalone/.[!.]* . 2>/dev/null || true
rm -rf /tmp/jotty_standalone
msg_ok "Updated jotty" msg_ok "Updated jotty"
msg_info "Restoring configuration & data" msg_info "Restoring configuration & data"
@ -55,6 +66,24 @@ function update_script() {
$STD tar -xf /opt/data_config.tar $STD tar -xf /opt/data_config.tar
msg_ok "Restored configuration & data" msg_ok "Restored configuration & data"
msg_info "Updating Service"
cat <<EOF >/etc/systemd/system/jotty.service
[Unit]
Description=jotty server
After=network.target
[Service]
WorkingDirectory=/opt/jotty
EnvironmentFile=/opt/jotty/.env
ExecStart=/usr/bin/node server.js
Restart=on-abnormal
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
msg_ok "Updated Service"
msg_info "Starting Service" msg_info "Starting Service"
systemctl start jotty systemctl start jotty
msg_ok "Started Service" msg_ok "Started Service"

View File

@ -28,8 +28,6 @@ function update_script() {
exit exit
fi fi
JAVA_VERSION="21" setup_java
msg_info "Updating ${APP}" msg_info "Updating ${APP}"
$STD apt update --allow-releaseinfo-change $STD apt update --allow-releaseinfo-change
$STD apt install -y unifi $STD apt install -y unifi

View File

@ -21,6 +21,18 @@ cd /opt/jotty
$STD yarn --frozen-lockfile $STD yarn --frozen-lockfile
$STD yarn next telemetry disable $STD yarn next telemetry disable
$STD yarn build $STD yarn build
[ -d "public" ] && cp -r public .next/standalone/
[ -d "howto" ] && cp -r howto .next/standalone/
mkdir -p .next/standalone/.next
cp -r .next/static .next/standalone/.next/
mv .next/standalone /tmp/jotty_standalone
rm -rf * .next .git .gitignore .yarn
mv /tmp/jotty_standalone/* .
mv /tmp/jotty_standalone/.[!.]* . 2>/dev/null || true
rm -rf /tmp/jotty_standalone
mkdir -p data/{users,checklists,notes} mkdir -p data/{users,checklists,notes}
cat <<EOF >/opt/jotty/.env cat <<EOF >/opt/jotty/.env
@ -55,7 +67,7 @@ After=network.target
[Service] [Service]
WorkingDirectory=/opt/jotty WorkingDirectory=/opt/jotty
EnvironmentFile=/opt/jotty/.env EnvironmentFile=/opt/jotty/.env
ExecStart=yarn start ExecStart=/usr/bin/node server.js
Restart=on-abnormal Restart=on-abnormal
[Install] [Install]

View File

@ -17,6 +17,7 @@ msg_info "Installing Dependencies"
$STD apt install -y apt-transport-https $STD apt install -y apt-transport-https
msg_ok "Installed Dependencies" msg_ok "Installed Dependencies"
JAVA_VERION="17" setup_java
setup_deb822_repo \ setup_deb822_repo \
"unifi" \ "unifi" \
"https://dl.ui.com/unifi/unifi-repo.gpg" \ "https://dl.ui.com/unifi/unifi-repo.gpg" \
@ -25,22 +26,17 @@ setup_deb822_repo \
"ubiquiti" \ "ubiquiti" \
"amd64" "amd64"
JAVA_VERSION="21" setup_java if ! grep -q -m1 'avx[^ ]*' /proc/cpuinfo; then
msg_warn "No AVX Support Detected. MongoDB v4.4 will be installed"
if lscpu | grep -q 'avx'; then if ! dpkg -l | grep -q "libssl1.1"; then
MONGO_VERSION="8.0" setup_mongodb curl -fsSL "https://security.debian.org/debian-security/pool/updates/main/o/openssl/libssl1.1_1.1.1w-0+deb11u4_amd64.deb" -o "libssl1.1_1.1.1w-0+deb11u4_amd64.deb"
$STD dpkg -i libssl1.1_1.1.1w-0+deb11u4_amd64.deb
fi
MONGO_VERSION="4.4" setup_mongodb
else else
msg_error "No AVX detected (CPU-Flag)! We have discontinued support for this. You are welcome to try it manually with a Debian LXC, but due to the many issues with Unifi, we currently only support AVX CPUs." MONGO_VERSION="7.0" setup_mongodb
exit 10
fi
if ! dpkg -l | grep -q 'libssl1.1'; then
msg_info "Installing libssl (if needed)"
curl -fsSL "https://security.debian.org/debian-security/pool/updates/main/o/openssl/libssl1.1_1.1.1w-0+deb11u4_amd64.deb" -o "/tmp/libssl.deb"
$STD dpkg -i /tmp/libssl.deb
rm -f /tmp/libssl.deb
msg_ok "Installed libssl1.1"
fi fi
msg_ok "Installed MongoDB"
msg_info "Installing UniFi Network Server" msg_info "Installing UniFi Network Server"
$STD apt install -y unifi $STD apt install -y unifi