feat: add bsnotify

This commit is contained in:
s3lph 2025-01-18 19:53:02 +01:00
parent 0ee3650142
commit e7b286fd1e
Signed by: s3lph
GPG key ID: 0AA29A52FB33CFB5
10 changed files with 116 additions and 0 deletions

View file

@ -34,6 +34,7 @@ jobs:
--upload-file "${file}" \ --upload-file "${file}" \
"${API_REPOSITORY_DEB}" "${API_REPOSITORY_DEB}"
done done
bsnotify: *job
daliserver: *job daliserver: *job
forgejo: *job forgejo: *job
forgejo-runner: *job forgejo-runner: *job

View file

@ -10,6 +10,7 @@ information, please see [https://repo.s3lph.me/](https://repo.s3lph.me/).
## Packages ## Packages
- [ansible-semaphore](https://github.com/ansible-semaphore/semaphore) - [ansible-semaphore](https://github.com/ansible-semaphore/semaphore)
- [bsnotify](https://github.com/jonans/bsnotify)
- [daliserver](https://github.com/onitake/daliserver) - [daliserver](https://github.com/onitake/daliserver)
- [forgejo](https://codeberg.org/forgejo/forgejo) - [forgejo](https://codeberg.org/forgejo/forgejo)
- [forgejo-runner](https://code.forgejo.org/forgejo/runner) - [forgejo-runner](https://code.forgejo.org/forgejo/runner)

View file

@ -0,0 +1,6 @@
#
# This MUST be populated for bsnotify to run:
# BSNOTIFY_ARGS="<printer ip> <printer serial number> [<local bind ip 1>[,...]]"
#
BSNOTIFY_ARGS=

14
bsnotify/bsnotify.service Normal file
View file

@ -0,0 +1,14 @@
[Unit]
Description=Use Bambu Studio or Orca Slicer with printers outside your LAN
After=network-online.target
Wants=network-online.target
[Service]
EnvironmentFile=-/etc/default/bsnotify
ExecStart=/usr/bin/python3 /usr/bin/bsnotify $BSNOTIFY_ARGS
DynamicUser=true
CapabilityBoundingSet=
Restart=on-failure
[Install]
WantedBy=multi-user.target

49
bsnotify/build.sh Executable file
View file

@ -0,0 +1,49 @@
#!/bin/bash
set -exo pipefail
ROOT=$(pwd)
function fetch() {
cd "${SRCDIR}"
git clone https://github.com/jonans/bsnotify
cd bsnotify
export VERSION=0.$(git rev-list --count HEAD)
}
function prepare() {
chmod +x "${SRCDIR}/bsnotify/bsnotify"
mkdir -p \
"${PKGDIR}/DEBIAN" \
"${PKGDIR}/usr/bin" \
"${PKGDIR}/etc/default" \
"${PKGDIR}/lib/systemd/system"
cp "${SRCDIR}/bsnotify" "${PKGDIR}/usr/bin/bsnotify"
cp "${ROOT}/bsnotify.defaults" "${PKGDIR}/etc/default/bsnotify"
cp "${ROOT}/bsnotify.service" "${PKGDIR}/lib/systemd/system/bsnotify.service"
cp "${ROOT}/debian.control" "${PKGDIR}/DEBIAN/control"
cp "${ROOT}/debian.conffiles" "${PKGDIR}/DEBIAN/conffiles"
cp "${ROOT}/debian.postinst" "${PKGDIR}/DEBIAN/postinst"
cp "${ROOT}/debian.prerm" "${PKGDIR}/DEBIAN/prerm"
cp "${ROOT}/debian.postrm" "${PKGDIR}/DEBIAN/postrm"
sed -re "s/__VERSION__/${VERSION}/g" -i "${PKGDIR}/DEBIAN/control"
sed -re "s/__MAINTAINER__/${MAINTAINER}/g" -i "${PKGDIR}/DEBIAN/control"
find "${PKGDIR}" -exec touch -m -d "${ISODATE}" {} \;
}
function package() {
cd "${BUILDDIR}"
dpkg-deb --build "${PKGDIR}" "${BUILDDIR}"
}
function build() {
export BUILDDIR=${ROOT}/build
export SRCDIR=${ROOT}/build/srcdir
export PKGDIR=${ROOT}/build/pkgdir
mkdir -p ${SRCDIR} ${PKGDIR}
fetch
prepare
package
}
build

View file

@ -0,0 +1 @@
/etc/default/bsnotify

15
bsnotify/debian.control Normal file
View file

@ -0,0 +1,15 @@
Package: bsnotify
Version: __VERSION__
Maintainer: __MAINTAINER__
Section: web
Priority: optional
Architecture: amd64
Depends: python3
Description: Use Bambu Studio or Orca Slicer with printers outside your LAN
Bambu Lab printers have a LAN only mode to avoid relying on cloud
services for general tasks. One limitation is that Bambu Studio can
only find your printer when both are on the same LAN. Discovery
happens using SSDP but due non-standard/broken implementation it does
not work when they are on different LANs. Since BS lacks the simple
ability to add printer via IP, SSDP is the only way. Thats where
bsnotify comes in, it will notify BS of printers outside your LAN.

11
bsnotify/debian.postinst Executable file
View file

@ -0,0 +1,11 @@
#!/bin/bash
set -e
if [[ "$1" == "configure" ]]; then
deb-systemd-helper enable bsnotify.service
deb-systemd-invoke restart bsnotify.service
fi

9
bsnotify/debian.postrm Executable file
View file

@ -0,0 +1,9 @@
#!/bin/bash
set -e
if [[ "$1" == "remove" ]]; then
systemctl daemon-reload || true
fi

9
bsnotify/debian.prerm Executable file
View file

@ -0,0 +1,9 @@
#!/bin/bash
set -e
if [[ "$1" == "remove" ]]; then
deb-systemd-invoke stop bsnotify.service
fi