Commit bcb3ab60 authored by Ivan Vandot's avatar Ivan Vandot Committed by GitHub

remove templates, unify deb and rpm install and add bee-get-addr wrapper (#992)

parent fe7a64f8
...@@ -65,11 +65,14 @@ nfpms: ...@@ -65,11 +65,14 @@ nfpms:
formats: formats:
- deb - deb
- rpm - rpm
files:
"packaging/bee.service": "/lib/systemd/system/bee.service"
"packaging/bee-get-addr": "/usr/bin/bee-get-addr"
config_files: config_files:
"packaging/bee.yaml": "/etc/bee/bee.yaml" "packaging/bee.yaml": "/etc/bee/bee.yaml"
"packaging/default": "/etc/default/bee" "packaging/default": "/etc/default/bee"
"packaging/bee.service": "/lib/systemd/system/bee.service"
overrides: overrides:
deb: deb:
...@@ -90,8 +93,5 @@ nfpms: ...@@ -90,8 +93,5 @@ nfpms:
postinstall: ./packaging/rpm/post postinstall: ./packaging/rpm/post
preremove: ./packaging/rpm/preun preremove: ./packaging/rpm/preun
postremove: ./packaging/rpm/postun postremove: ./packaging/rpm/postun
deb:
scripts:
templates: ./packaging/deb/templates
bindir: /usr/bin bindir: /usr/bin
#!/bin/sh
if [ ! `id -u` -eq 0 ] ; then
echo "
use sudo!
"
exit 1
fi
RESP=$(/usr/bin/bee init --config /etc/bee/bee.yaml 2>&1)
case "$RESP" in
Error*)
echo "
Enabled clef-signer but clef is not running.
Check https://docs.ethswarm.org/ for more info.
After you fix configuration run 'sudo bee-get-addr' again.
"
;;
*)
ETH_ADDRESS=$(echo "$RESP" | grep ethereum | cut -d' ' -f6 | tr -d '"')
echo "
Please make sure there is sufficient eth and bzz available on $ETH_ADDRESS address.
You can get both goerli eth and goerli bzz from https://faucet.ethswarm.org
After you get the funds start service with 'systemctl start bee.service'.
"
;;
esac
#!/bin/sh -e #!/bin/sh -e
if [ "$1" = "configure" ]; then if [ "$1" = "configure" ]; then
START=true
if [ -z "$2" ]; then if [ -z "$2" ]; then
. /usr/share/debconf/confmodule # initial installation
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 if [ ! -f /var/lib/bee/keys/libp2p.key ]; then
/usr/bin/bee init --config /etc/bee/bee.yaml >/dev/null 2>&1 /usr/bin/bee init --config /etc/bee/bee.yaml >/dev/null 2>&1
chown -R bee:bee /var/lib/bee/keys chown -R bee:bee /var/lib/bee/keys
fi fi
db_input high bee/clef-enable || true echo "
if db_go; then Bee has SWAP enabled by default and it needs ethereum endpoint to operate.
db_get bee/clef-enable It is recommended to use external signer with bee.
if [ "$RET" = true ]; then Check documentation for more info https://docs.ethswarm.org/
grep -v BEE_CLEF_SIGNER_ENABLE /etc/default/bee > /etc/default/bee.tmp
echo "BEE_CLEF_SIGNER_ENABLE=true" >> /etc/default/bee.tmp && mv /etc/default/bee.tmp /etc/default/bee After you finish configuration run 'sudo bee-get-addr'.
fi "
fi
set +e
RESP=$(BEE_CLEF_SIGNER_ENABLE=$RET /usr/bin/bee init --config /etc/bee/bee.yaml 2>&1)
set -e
case "$RESP" in
Error*)
START=false
echo "Enabled clef-signer but clef is not running."
echo "Check https://docs.ethswarm.org/ for more info and how to fix."
echo "Or install latest release of bee-clef from https://github.com/ethersphere/bee-clef and reinstall bee."
echo "Start bee with systemctl --no-reload start bee.service"
;;
*)
ETH_ADDRESS=$(echo "$RESP" | grep ethereum | cut -d' ' -f6 | tr -d '"')
echo "Please make sure there is sufficient eth and bzz available on $ETH_ADDRESS address."
echo "You can get both goerli eth and goerli bzz from https://faucet.ethswarm.org."
;;
esac
fi fi
# allow group members (bee user) to use clef's socket
if [ -S /var/lib/bee-clef/clef.ipc ]; then if [ -S /var/lib/bee-clef/clef.ipc ]; then
chmod 660 /var/lib/bee-clef/clef.ipc chmod 660 /var/lib/bee-clef/clef.ipc
fi fi
...@@ -55,7 +30,8 @@ if [ "$1" = "configure" ]; then ...@@ -55,7 +30,8 @@ if [ "$1" = "configure" ]; then
fi fi
if [ -d /run/systemd/system ]; then if [ -d /run/systemd/system ]; then
systemctl --system daemon-reload >/dev/null || true systemctl --system daemon-reload >/dev/null || true
if [ $START = true ]; then # upgrade
if [ ! -z "$2" ]; then
deb-systemd-invoke start bee.service >/dev/null || true deb-systemd-invoke start bee.service >/dev/null || true
fi fi
fi fi
......
Template: bee/ethereum-endpoint
Type: string
Description: Set ethereum endpoint for bee.
Bee has SWAP enabled by default and needs ethereum endpoint to operate.
Template: bee/clef-enable
Type: boolean
Description: Do you want to enable clef support?
It is recommended to use external signer with bee. Bee has support for clef.
Download and install latest bee-clef release from https://github.com/ethersphere/bee-clef
if [ $1 -eq 1 ] ; then if [ $1 -eq 1 ] ; then
# Initial installation # 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"
if [ ! -f /var/lib/bee/keys/libp2p.key ]; then if [ ! -f /var/lib/bee/keys/libp2p.key ]; then
/usr/bin/bee init --config /etc/bee/bee.yaml >/dev/null 2>&1 /usr/bin/bee init --config /etc/bee/bee.yaml >/dev/null 2>&1
chown -R bee:bee /var/lib/bee/keys chown -R bee:bee /var/lib/bee/keys
fi fi
echo "It is recommended to use external signer with bee. Bee has support for clef."
echo "Download and install latest bee-clef release from https://github.com/ethersphere/bee-clef"
echo "Enable external signer setting clef-signer-enable to true inside /etc/bee/bee.yaml"
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 "If you don't want to use external signer even if we recommended it."
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 preset bee.service &>/dev/null || :
systemctl --no-reload enable bee.service &>/dev/null || : systemctl --no-reload enable bee.service &>/dev/null || :
echo "If you enabled external signer. Run" echo "
echo "sudo /usr/bin/bee init --config /etc/bee/bee.yaml 2>&1 | grep ethereum | cut -d' ' -f6 | tr -d '\"'" Bee has SWAP enabled by default and it needs ethereum endpoint to operate.
echo "Prefund that address at https://faucet.ethswarm.org" It is recommended to use external signer with bee.
echo "Service already enabled, after initial configuration." Check documentation for more info https://docs.ethswarm.org/
echo "Start service with systemctl --no-reload start bee.service"
After you finish configuration run 'sudo bee-get-addr'.
"
fi fi
# allow group members (bee user) to use clef's socket
if [ -S /var/lib/bee-clef/clef.ipc ]; then if [ -S /var/lib/bee-clef/clef.ipc ]; then
chmod 660 /var/lib/bee-clef/clef.ipc chmod 660 /var/lib/bee-clef/clef.ipc
fi fi
if [ $1 -eq 2 ] ; then if [ $1 -eq 2 ] ; then
# Upgrade # upgrade
systemctl --no-reload restart bee.service &>/dev/null || : systemctl --no-reload start bee.service &>/dev/null || :
fi 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