summarylogtreecommitdiffstats
path: root/epoptes.install
blob: 0eb5462f2cdfa493104c63dfa302cda615fc2a6f (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
post_install() {

    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
        faketime '1970-01-01 00:00:00 UTC' \
            openssl req -batch -x509 -nodes \
            -newkey rsa:4096 -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 -f /etc/epoptes/server.key
    rm -f /etc/epoptes/server.crt

    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
}