summarylogtreecommitdiffstats
path: root/hostsblock.install
blob: 77796943f04a092cef17619fc1514d4cad44f190 (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
47
48
49
50
add_user_group() {
    _changed=0
    if ! getent passwd hostsblock >/dev/null 2>&1; then
        _changed=1
        useradd -d /var/lib/hostsblock -c "hostsblock" -m -U hostsblock
    fi
    if ! getent group hostsblock >/dev/null 2>&1; then
        _changed=1
        groupadd hostsblock
    fi
    if [ $_changed = 1 ]; then
        gpasswd -a hostsblock hostsblock
        gpasswd -A hostsblock hostsblock
    fi
    chown -R hostsblock:hostsblock /var/lib/hostsblock /usr/bin/hostsblock /usr/lib/hostsblock.sh
    chmod 755 /var/lib/hostsblock
    chmod 500 /usr/lib/hostsblock.sh
    chmod 550 /usr/bin/hostsblock
    chmod 600 /var/lib/hostsblock/config.examples/*
}

post_install() {
    add_user_group
    cat << EOF

Please see https://github.com/gaenserich/hostsblock for details on how to configure hostsblock.
EOF
}

post_upgrade() {
    add_user_group
    chown hostsblock:hostsblock /usr/bin/hostsblock
    cat << EOF

As of 0.999.8, hostsblock's configuration has changed significantly. Please see
https://github.com/gaenserich/hostsblock#upgrade09998
for a guide on how to migrate your configuration

EOF
}

post_remove() {
    userdel hostsblock
    groupdel hostsblock
    cat << EOF
hostsblock's configuration and cache directory (/var/lib/hostsblock) has not been removed.

You should now remove the entries you put into sudoers (via sudo visudo) for hostsblock.
EOF
}