summarylogtreecommitdiffstats
path: root/swarm-bee.install
blob: bd7d56e718193d90ddedf0ea84ee6b7928f8fc8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
pre_install() {
    if ! getent passwd bee >/dev/null; then
        useradd -r -d /var/lib/bee -s /sbin/nologin -c 'Bee user' -U bee
    fi

    if getent passwd bee-clef >/dev/null; then
        usermod -a -G bee-clef bee >/dev/null
    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
        tr </dev/urandom -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
}

post_install() {
    # If first install
    if ! test -f /var/lib/bee/keys/libp2p.key; then
        /usr/bin/bee init --config /etc/bee/bee.yaml >/dev/null && chown -R bee:bee /var/lib/bee/keys

        echo "
Logs:   journalctl -f -u bee.service
Config: /etc/bee/bee.yaml
Bee requires a Gnosis Chain RPC endpoint to function. By default this is expected to be found at ws://localhost:8546.
Please see https://docs.ethswarm.org/docs/installation/install for more details on how to configure your node.
After you finish configuration run 'sudo bee-get-addr' and fund your node with XDAI, and also XBZZ if so desired.
        "
    fi

    # allow group members (bee user) to use clef's socket
    if [ -S /var/lib/bee-clef/clef.ipc ]; then
        chmod 660 /var/lib/bee-clef/clef.ipc
    fi
}

post_remove() {
    userdel bee >/dev/null 2>&1 || true
    groupdel bee >/dev/null 2>&1 || true
}