summarylogtreecommitdiffstats
path: root/zeronet.install
blob: ebe2b82865569a83f16b249caa78be19b231cf46 (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
post_install() {
    getent passwd zeronet &>/dev/null || {
        echo -n ">>> Creating zeronet user... "
        useradd --system --user-group -m --home /var/lib/zeronet zeronet
        echo "done"
    } # NOTE: we do not autoremove user due to security concerns (Arch policy)

    mkdir -p /var/log/zeronet
    chown zeronet:zeronet /var/log/zeronet

    # This is not usual practice but to editting from web interface
    chown zeronet:zeronet /etc/zeronet.conf

    # Don't run thesre operations automatically, because they are security-sensitive
    echo ">>> Default mode is clearnet+Tor. Give zeronet permissions to configure hidden service:"
    echo ">>>   sudo usermod -a -G tor zeronet"
    echo ">>> Add/edit the following options in /etc/tor/torrc:"
    echo ">>>   ControlPort 9051"
    echo ">>>   DataDirectoryGroupReadable 1"
    echo ">>>   CookieAuthentication 1"
    echo ">>>   CookieAuthFileGroupReadable 1"
    echo ">>>   CookieAuthFile /var/lib/tor/control_auth_cookie"
    echo ">>> Restart tor (reload not enough):"
    echo ">>>   sudo systemctl restart tor"
    echo ">>> Run daemon and check status and view log:"
    echo ">>>   sudo systemctl start zeronet"
    echo ">>>   sudo systemctl status zeronet"
    echo ">>>   sudo journalctl -u zeronet"
    echo ">>> NOTE: all operations including editing zerosite files,"
    echo ">>>       should be done as user zeronet and config must be passed"
    echo ">>>       for data directory to be selected to /var/lib/zeronet: "
    echo ">>>   sudo -u zeronet python zeronet.py --config_file /etc/zeronet.conf ..."
    echo ">>>      OR"
    echo ">>>   sudo su - zeronet"
    echo ">>>   cd /opt/zeronet"
    echo ">>>   python zeronet.py --config_file /etc/zeronet.conf ..."
}

## each separate version number must be less than 3 digit wide !
function version { echo "$@" | gawk -F. '{ printf("%03d%03d%03d\n", $1,$2,$3); }'; }

post_upgrade() {
    chown -R zeronet:zeronet /opt/zeronet
    chown zeronet:zeronet /etc/zeronet.conf
}