diff --git a/Cargo.toml b/Cargo.toml index 156247a1aaed..17ba6ff3009c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -88,13 +88,14 @@ extended-description = "Implementation of a https://polkadot.network node in Rus section = "misc" maintainer = "martin@parity.io" license-file = ["LICENSE", "0"] -maintainer-scripts = "scripts/deb/" +# https://www.debian.org/doc/debian-policy/ch-maintainerscripts.html +maintainer-scripts = "scripts/packaging/deb-maintainer-scripts" assets = [ - ["target/release/polkadot", "usr/bin/", "755"], - ["scripts/polkadot.service", "etc/systemd/system/", "644"] + ["target/release/polkadot", "/usr/bin/", "755"], + ["scripts/packaging/polkadot.service", "/lib/systemd/system/", "644"] ] conf-files = [ - "/etc/systemd/system/polkadot.service" + "/etc/default/polkadot" ] # Configuration for building an .rpm package - for use with `cargo-rpm` diff --git a/README.md b/README.md index 09382b9c657d..fb85c3299f8c 100644 --- a/README.md +++ b/README.md @@ -25,11 +25,11 @@ Currently supports Debian 10 (Buster) and Ubuntu 20.04 (Focal), and derivatives. Installation from the repository will create a `systemd` service that can be -used to run a Polkadot node. By default, it will run as the `polkadot` user, -with no additional flags. The service file located at -`/etc/systemd/system/polkadot.service` can be edited to customise this as -necessary. This file will not be overwritten on updating polkadot. Conversely, -you may also just run the node directly from the command-line. +used to run a Polkadot node. This is disabled by default, and can be started by +running `systemctl start polkadot`. By default, it will run as the `polkadot` +user. Command-line flags passed to the binary can be customised by editing +`/etc/default/polkadot`. This file will not be overwritten on updating +polkadot. You may also just run the node directly from the command-line. ``` # Import the security@parity.io GPG key diff --git a/scripts/deb/postinst b/scripts/deb/postinst deleted file mode 100644 index e16fce374fb4..000000000000 --- a/scripts/deb/postinst +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -set -e - -getent group polkadot >/dev/null 2>&1 || addgroup --system polkadot -getent passwd polkadot >/dev/null 2>&1 || - adduser --system --home /home/polkadot --disabled-password \ - --ingroup polkadot polkadot diff --git a/scripts/packaging/deb-maintainer-scripts/postinst b/scripts/packaging/deb-maintainer-scripts/postinst new file mode 100644 index 000000000000..3ac5cd04c376 --- /dev/null +++ b/scripts/packaging/deb-maintainer-scripts/postinst @@ -0,0 +1,17 @@ +#!/bin/sh + +set -e + +action="$1" +config_file="/etc/default/polkadot" + +if [ "$action" = "configure" ]; then + # Make user and group + getent group polkadot >/dev/null 2>&1 || addgroup --system polkadot + getent passwd polkadot >/dev/null 2>&1 || + adduser --system --home /home/polkadot --disabled-password \ + --ingroup polkadot polkadot + if [ ! -e "$config_file" ]; then + echo 'POLKADOT_CLI_ARGS=""' > /etc/default/polkadot + fi +fi diff --git a/scripts/polkadot.service b/scripts/packaging/polkadot.service similarity index 74% rename from scripts/polkadot.service rename to scripts/packaging/polkadot.service index 0fbb108524b9..28a6193d2858 100644 --- a/scripts/polkadot.service +++ b/scripts/packaging/polkadot.service @@ -4,11 +4,12 @@ After=network.target Documentation=https://github.com/paritytech/polkadot [Service] -ExecStart=/usr/bin/polkadot -Restart=always -RestartSec=120 +EnvironmentFile=-/etc/default/polkadot +ExecStart=/usr/bin/polkadot $POLKADOT_CLI_ARGS User=polkadot Group=polkadot +Restart=always +RestartSec=120 MemoryHigh=5400M MemoryMax=5500M