add config for cargo-deb

This commit is contained in:
Jacob Lifshay 2024-04-10 00:25:52 -07:00
parent 14f1c5addc
commit cf8af5d173
Signed by: programmerjake
SSH key fingerprint: SHA256:B1iRVvUJkvd7upMIiMqn6OyxvD2SgJkAH3ZnUOj6z+c
4 changed files with 60 additions and 3 deletions

View file

@ -2,6 +2,8 @@
name = "subscribe-list"
version = "0.1.0"
edition = "2021"
authors = ["Jacob Lifshay <programmerjake@gmail.com>"]
description = "web server for managing subscriptions"
license = "GPL-3.0-or-later"
publish = false
@ -30,3 +32,16 @@ serde_with = { version = "3.7.0", features = ["base64"] }
tinytemplate = "1.2.1"
tokio = { version = "1.37.0", features = ["macros", "rt-multi-thread"] }
toml = { version = "0.8.12", features = ["preserve_order"] }
[package.metadata.deb]
depends = ["$auto", "adduser (>= 3.11)"]
assets = [
["target/release/subscribe-list", "usr/bin/", "755"],
["config.toml.sample", "usr/share/subscribe-list/config.toml.sample", "644"],
]
maintainer-scripts = "debian"
[package.metadata.deb.systemd-units]
unit-name = "subscribe-list"
unit-scripts = "."
enable = false

View file

@ -1,4 +1,4 @@
sqlite_db = "/var/local/lib/subscribe-list.db"
sqlite_db = "/var/lib/subscribe-list/list.db"
server_base_url = "https://my-site/"
[oidc.google]

42
debian/postinst vendored Executable file
View file

@ -0,0 +1,42 @@
#!/bin/sh
set -e
case "$1" in
configure)
if ! getent group | grep -q "^www-data:"; then
echo -n "Adding group www-data.."
addgroup --quiet --system www-data 2>/dev/null || true
echo ".done"
fi
test -d /var/www || mkdir /var/www
if ! getent passwd | grep -q "^www-data:"; then
echo -n "Adding system user www-data.."
adduser --quiet --system --ingroup www-data --no-create-home --disabled-password www-data 2>/dev/null || true
echo ".done"
fi
usermod -c www-data -d /var/www -g www-data www-data
if ! test -d /var/lib/subscribe-list/; then
mkdir -m 750 /var/lib/subscribe-list/
touch /var/lib/subscribe-list/list.db
chmod 640 /var/lib/subscribe-list/list.db
chown -R www-data:www-data /var/lib/subscribe-list/
fi
if ! test -d /etc/subscribe-list/; then
mkdir -m 750 /etc/subscribe-list/
install -m 640 /usr/share/subscribe-list/config.toml.sample /etc/subscribe-list/config.toml
chown -R root:www-data /etc/subscribe-list/
fi
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
#DEBHELPER#
exit 0

View file

@ -5,8 +5,8 @@ Requires=subscribe-list.socket
[Service]
Environment=RUST_LOG=info
Type=exec
ExecStart=!sh -c 'mkdir -p /var/local/lib; umask 007; touch /var/local/lib/subscribe-list.db; chown www-data:www-data /var/local/lib/subscribe-list.db'
ExecStart=/usr/local/bin/subscribe-list --config /etc/subscribe-list/config.toml serve --listen-fd
ExecStart=test -f /var/lib/subscribe-list/list.db
ExecStart=/usr/bin/subscribe-list --config /etc/subscribe-list/config.toml serve --listen-fd
User=www-data
Group=www-data