summarylogtreecommitdiffstats
path: root/epoptes.install
blob: d1f4fb50621036c933a8e5e316d4b3c01094b0a8 (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
51
52
53
54
55
post_install() {
    gtk-update-icon-cache -q -t -f usr/share/icons/hicolor

    if getent group epoptes
    then
        "Group 'epoptes' already exists. Skipping group's creation."
    else
        groupadd epoptes
        echo "Group 'epoptes' has been added."
    fi

    if ! [ -s /etc/epoptes/server.key ] || ! [ -s /etc/epoptes/server.crt ]
    then
        mkdir -p /etc/epoptes

        faketime '1970-01-01 00:00:00 UTC' \
            openssl req -batch -x509 -nodes -newkey rsa:1024 \
                -days $(($(date --utc +%s) / 86400 + 3652)) \
                -keyout /etc/epoptes/server.key \
                -out /etc/epoptes/server.crt
        chmod 600 /etc/epoptes/server.key
    fi

    echo "The installation has finished. Please bare in mind you'll have to do the following before using Epoptes:"
    echo "1.- You will have to add yourself to the 'epoptes' group."
    echo "2.- You will have to run as root:"
    echo "    'systemctl enable epoptes' to enable the Epoptes server daemon."
    echo "3.- You may need to restart your system for everything to work."
    echo "4.- If you don't want to restart your system, then [after doing all of the above] you will have to run as root:"
    echo "    'systemctl start epoptes' to start the Epoptes server daemon."
    echo "After all this you still have to log out and then log back in and now Epoptes should work without a problem."
}

post_upgrade() {
    systemctl daemon-reload 
}

pre_remove() {
    systemctl stop epoptes.service
    systemctl disable epoptes.service
}

post_remove() {
    rm -rf /etc/epoptes

    if getent group epoptes
    then
        groupdel epoptes
        echo "Group 'epoptes' has been deteled."
    else
        echo "Group 'epoptes' doesn't exist. Skipping group's removal."
    fi

    systemctl daemon-reload
}