Add Debian packaging support with configurable binding

- Add complete debian/ packaging structure for .deb creation
- Support BIND_ADDR environment variable (defaults to 0.0.0.0)
- Create /etc/default/naas config file (defaults to localhost binding)
- Systemd service reads from /etc/default/naas
- Package installs but does not auto-enable service
- Upgrades restart service only if already enabled
- Proper user creation and cleanup on install/remove

Key files:
- debian/control: Package metadata with rustup build dependency support
- debian/naas.default: Configuration template for /etc/default/naas
- debian/naas.service: Updated systemd service with EnvironmentFile
- debian/postinst: Creates naas user, restarts on upgrade if enabled
- debian/prerm: Stops service on removal
- debian/postrm: Cleans up user on purge
- src/main.rs: Added BIND_ADDR support for configurable binding

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Ole-Morten Duesund 2025-09-29 13:35:38 +02:00
commit 57628d940d
11 changed files with 182 additions and 1 deletions

31
debian/postinst vendored Executable file
View file

@ -0,0 +1,31 @@
#!/bin/bash
set -e
case "$1" in
configure)
# Create naas user if it doesn't exist
if ! getent passwd naas >/dev/null; then
adduser --system --group --no-create-home \
--disabled-password --disabled-login \
--shell /bin/false naas
fi
# Reload systemd daemon to pick up new service file
if [ -d /run/systemd/system ]; then
systemctl daemon-reload || true
fi
# On upgrade, restart the service if it's already enabled
if [ -n "$2" ] && [ -d /run/systemd/system ]; then
if systemctl is-enabled naas >/dev/null 2>&1; then
echo "Restarting naas service..."
systemctl restart naas || true
fi
fi
;;
esac
#DEBHELPER#
exit 0