diff --git a/Cargo.toml b/Cargo.toml index 568c602..e1990f3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,6 +2,8 @@ name = "subscribe-list" version = "0.1.0" edition = "2021" +authors = ["Jacob Lifshay "] +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 \ No newline at end of file diff --git a/config.toml.sample b/config.toml.sample index 37a5d0b..42c7e5d 100644 --- a/config.toml.sample +++ b/config.toml.sample @@ -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] diff --git a/debian/postinst b/debian/postinst new file mode 100755 index 0000000..422d058 --- /dev/null +++ b/debian/postinst @@ -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 \ No newline at end of file diff --git a/subscribe-list.service b/subscribe-list.service index 47253fd..a916eba 100644 --- a/subscribe-list.service +++ b/subscribe-list.service @@ -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