Commit 1ab8b050 authored by Ivan Vandot's avatar Ivan Vandot Committed by GitHub

deb and rpm support (#962)

parent 6463de45
......@@ -47,7 +47,7 @@ archives:
format: binary
nfpms:
- file_name_template: "{{ tolower .ProjectName }}-{{ tolower .Os }}-{{ tolower .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
- file_name_template: "{{ tolower .ProjectName }}_{{ tolower .Version }}_{{ tolower .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
vendor: Ethereum Swarm
homepage: https://swarm.ethereum.org/
......@@ -58,8 +58,40 @@ nfpms:
license: GPL-3
dependencies:
- ca-certificates
- adduser
formats:
- deb
- rpm
config_files:
"packaging/bee.yaml": "/etc/bee/bee.yaml"
"packaging/default": "/etc/default/bee"
"packaging/bee.service": "/lib/systemd/system/bee.service"
overrides:
deb:
dependencies:
- passwd
- ca-certificates
scripts:
preinstall: ./packaging/deb/preinst
postinstall: ./packaging/deb/postinst
preremove: ./packaging/deb/prerm
postremove: ./packaging/deb/postrm
rpm:
dependencies:
- ca-certificates
- shadow-utils
scripts:
preinstall: ./packaging/rpm/pre
postinstall: ./packaging/rpm/post
preremove: ./packaging/rpm/preun
postremove: ./packaging/rpm/postun
deb:
scripts:
templates: ./packaging/deb/templates
bindir: /usr/bin
[Unit]
Description=Bee - Ethereum Swarm node
Documentation=https://swarm-gateways.net/bzz:/docs.swarm.eth/
After=network.target
[Service]
EnvironmentFile=/etc/default/bee
NoNewPrivileges=true
User=bee
Group=bee
ExecStart=/usr/bin/bee start --config=/etc/bee/bee.yaml
Restart=on-failure
RestartSec=5s
[Install]
WantedBy=multi-user.target
## Bee configuration - https://swarm-gateways.net/bzz:/docs.swarm.eth/docs/installation/configuration
## HTTP API listen address (default ":1633")
# api-addr: :1633
## initial nodes to connect to (default [/dnsaddr/bootnode.ethswarm.org])
# bootnode: [/dnsaddr/bootnode.ethswarm.org]
## enable clef signer
# clef-signer-enable: false
## clef signer endpoint
# clef-signer-endpoint: ""
## config file (default is /home/<user>/.bee.yaml)
config: /etc/bee/bee.yaml
## origins with CORS headers enabled
# cors-allowed-origins: []
## data directory (default "/home/<user>/.bee")
data-dir: /var/lib/bee
## db capacity in chunks, multiply by 4096 to get approximate capacity in bytes
# db-capacity: 5000000
## debug HTTP API listen address (default ":1635")
# debug-api-addr: 127.0.0.1:1635
## enable debug HTTP API
# debug-api-enable: false
## disable a set of sensitive features in the api
# gateway-mode: false
## enable global pinning
# global-pinning-enable: false
## NAT exposed address
# nat-addr: ""
## ID of the Swarm network (default 1)
# network-id: 1
## P2P listen address (default ":1634")
# p2p-addr: :1634
## enable P2P QUIC protocol
# p2p-quic-enable: false
## enable P2P WebSocket transport
# p2p-ws-enable: false
## password for decrypting keys
# password: ""
## path to a file that contains password for decrypting keys
password-file: /var/lib/bee/password
## amount in BZZ below the peers payment threshold when we initiate settlement (default 10000)
# payment-early: 10000
## threshold in BZZ where you expect to get paid from your peers (default 100000)
# payment-threshold: 100000
## excess debt above payment threshold in BZZ where you disconnect from your peer (default 10000)
# payment-tolerance: 10000
## ENS compatible API endpoint for a TLD and with contract address, can be repeated, format [tld:][contract-addr@]url
# resolver-options: []
## whether we want the node to start with no listen addresses for p2p
# standalone: false
## enable swap (default true)
# swap-enable: true
## swap ethereum blockchain endpoint (default "http://localhost:8545")
# swap-endpoint: http://localhost:8545
## swap factory address
# swap-factory-address: ""
## initial deposit if deploying a new chequebook (default 100000000)
# swap-initial-deposit: 100000000
## enable tracing
# tracing-enable: false
## endpoint to send tracing data (default "127.0.0.1:6831")
# tracing-endpoint: 127.0.0.1:6831
## service name identifier for tracing (default "bee")
# tracing-service-name: bee
## log verbosity level 0=silent, 1=error, 2=warn, 3=info, 4=debug, 5=trace (default "info")
# verbosity: info
## send a welcome message string during handshakes
# welcome-message: ""
#!/bin/sh -e
if [ "$1" = "configure" ]; then
if [ -z "$2" ]; then
. /usr/share/debconf/confmodule
db_input high bee/ethereum-endpoint || true
if db_go; then
db_get bee/ethereum-endpoint
grep -v BEE_SWAP_ENDPOINT /etc/default/bee > /etc/default/bee.tmp
echo "BEE_SWAP_ENDPOINT=$RET" >> /etc/default/bee.tmp && mv /etc/default/bee.tmp /etc/default/bee
fi
if [ ! -f /var/lib/bee/keys/libp2p.key ]; then
/usr/bin/bee init --config /etc/bee/bee.yaml >/dev/null 2>&1
chown -R bee:bee /var/lib/bee/keys
fi
if [ -f /var/lib/bee/keys/swarm.key ]; then
parse_json() { echo $1|sed -e 's/[{}]/''/g'|sed -e 's/", "/'\",\"'/g'|sed -e 's/" ,"/'\",\"'/g'|sed -e 's/" , "/'\",\"'/g'|sed -e 's/","/'\"---SEPERATOR---\"'/g'|awk -F=':' -v RS='---SEPERATOR---' "\$1~/\"$2\"/ {print}"|sed -e "s/\"$2\"://"|tr -d "\n\t"|sed -e 's/\\"/"/g'|sed -e 's/\\\\/\\/g'|sed -e 's/^[ \t]*//g'|sed -e 's/^"//' -e 's/"$//' ; }
echo "Please make sure there is sufficient eth and bzz available on $(parse_json $(cat /var/lib/bee/keys/swarm.key) address)"
echo "You can get both goerli eth and goerli bzz from https://faucet.ethswarm.org"
fi
fi
deb-systemd-helper unmask bee.service >/dev/null || true
if deb-systemd-helper --quiet was-enabled bee.service; then
deb-systemd-helper enable bee.service >/dev/null || true
else
deb-systemd-helper update-state bee.service >/dev/null || true
fi
if [ -d /run/systemd/system ]; then
systemctl --system daemon-reload >/dev/null || true
deb-systemd-invoke start bee.service >/dev/null || true
fi
fi
\ No newline at end of file
#!/bin/sh -e
if [ -d /run/systemd/system ] ; then
systemctl --system daemon-reload >/dev/null || true
fi
if [ "$1" = "remove" ]; then
if [ -x "/usr/bin/deb-systemd-helper" ]; then
deb-systemd-helper mask bee.service >/dev/null
fi
fi
if [ "$1" = "purge" ]; then
if [ -x "/usr/bin/deb-systemd-helper" ]; then
deb-systemd-helper purge bee.service >/dev/null
deb-systemd-helper unmask bee.service >/dev/null
fi
userdel -r bee >/dev/null 2>&1 || true
fi
if [ "$1" = "purge" -a -e /usr/share/debconf/confmodule ]; then
. /usr/share/debconf/confmodule
db_purge
fi
\ No newline at end of file
#!/bin/sh -e
if [ "$1" = "install" ]; then
if ! getent passwd bee > /dev/null; then
useradd -r -d /var/lib/bee -s /sbin/nologin -U bee
fi
if ! test -d /var/lib/bee; then
mkdir -p /var/lib/bee
chmod 0750 /var/lib/bee
chown -R bee:bee /var/lib/bee
fi
if ! test -f /var/lib/bee/password; then
< /dev/urandom tr -dc _A-Z-a-z-0-9 2> /dev/null | head -c32 > /var/lib/bee/password
chmod 0600 /var/lib/bee/password
chown bee:bee /var/lib/bee/password
fi
fi
\ No newline at end of file
#!/bin/sh -e
if [ -d /run/systemd/system ]; then
deb-systemd-invoke stop bee.service >/dev/null
fi
\ No newline at end of file
Template: bee/ethereum-endpoint
Type: string
Description: Set ethereum endpoint for bee.
Bee has SWAP enabled by default and needs ethereum endpoint to operate.
# Configuration for bee daemon
#BEE_SWAP_ENDPOINT=http://localhost:8545
#BEE_RESOLVER_OPTIONS=
\ No newline at end of file
if [ $1 -eq 1 ] ; then
# Initial installation
echo "Bee has SWAP enabled by default and needs ethereum endpoint to operate"
echo "Set ethereum endpoint for bee swap-endpoint inside /etc/bee/bee.yaml or BEE_SWAP_ENDPOINT inside /etc/default/bee"
if [ ! -f /var/lib/bee/keys/libp2p.key ]; then
/usr/bin/bee init --config /etc/bee/bee.yaml >/dev/null 2>&1
chown -R bee:bee /var/lib/bee/keys
fi
if [ -f /var/lib/bee/keys/swarm.key ]; then
parse_json() { echo $1|sed -e 's/[{}]/''/g'|sed -e 's/", "/'\",\"'/g'|sed -e 's/" ,"/'\",\"'/g'|sed -e 's/" , "/'\",\"'/g'|sed -e 's/","/'\"---SEPERATOR---\"'/g'|awk -F=':' -v RS='---SEPERATOR---' "\$1~/\"$2\"/ {print}"|sed -e "s/\"$2\"://"|tr -d "\n\t"|sed -e 's/\\"/"/g'|sed -e 's/\\\\/\\/g'|sed -e 's/^[ \t]*//g'|sed -e 's/^"//' -e 's/"$//' ; }
echo "Please make sure there is sufficient eth and bzz available on $(parse_json $(cat /var/lib/bee/keys/swarm.key) address)"
echo "You can get both goerli eth and goerli bzz from https://faucet.ethswarm.org"
fi
systemctl --no-reload preset bee.service &>/dev/null || :
systemctl --no-reload enable bee.service &>/dev/null || :
echo "Service already enabled, after initial configuration"
echo "Start service with systemctl --no-reload start bee.service"
fi
if [ $1 -eq 2 ] ; then
# Upgrade
systemctl --no-reload restart bee.service &>/dev/null || :
fi
if [ $1 -eq 0 ] ; then
# Package removal, not upgrade
userdel -r bee &>/dev/null || :
fi
\ No newline at end of file
if [ $1 -eq 1 ] ; then
# Initial installation
if ! getent passwd bee > /dev/null; then
useradd -r -d /var/lib/bee -s /sbin/nologin -U bee
fi
if ! test -d /var/lib/bee; then
mkdir -p /var/lib/bee
chmod 0750 /var/lib/bee
chown -R bee:bee /var/lib/bee
fi
if ! test -f /var/lib/bee/password; then
< /dev/urandom tr -dc _A-Z-a-z-0-9 2> /dev/null | head -c32 > /var/lib/bee/password
chmod 0600 /var/lib/bee/password
chown bee:bee /var/lib/bee/password
fi
fi
\ No newline at end of file
systemctl --no-reload stop --now bee.service &>/dev/null || :
if [ $1 -eq 0 ] ; then
# Package removal, not upgrade
systemctl --no-reload disable --now bee.service &>/dev/null || :
fi
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment