Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
add configuration via /etc/default/polkadot
Browse files Browse the repository at this point in the history
  • Loading branch information
s3krit committed Sep 4, 2020
1 parent 30b83f0 commit 969b3ce
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 20 deletions.
9 changes: 5 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 0 additions & 8 deletions scripts/deb/postinst

This file was deleted.

17 changes: 17 additions & 0 deletions scripts/packaging/deb-maintainer-scripts/postinst
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 969b3ce

Please sign in to comment.