summarylogtreecommitdiffstats
path: root/goweatherserver.install
blob: d6ff096e8c6b4003024619d8505c290929fcf0d3 (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
56
57
pre_install() {
    # Create group and goweatherserver user
    name=goweatherserver
    num=488
    getent group $name &>/dev/null || groupadd -r -g $num $name >/dev/null
    getent passwd $name &>/dev/null || useradd -r -u $num -g $name -d /tmp -s /bin/bash >/dev/null $name

    true
}

post_install() {
    pkgname=goweatherserver

    # Fixing membership
    chown goweatherserver: /var/log/$pkgname
    chown goweatherserver: /var/lib/$pkgname
    chown -R goweatherserver: /etc/$pkgname

    # Reload systemctl
    systemctl daemon-reload

    echo "Adding goweatherserver in systemctl:"
    echo "  systemctl enable goweatherserver"
    echo "  systemctl start goweatherserver"

    true
}

post_upgrade() {
    # Reload systemctl
    systemctl daemon-reload

    echo "You should restart goweatherserver:"
    echo "  systemctl restart goweatherserver"

    true
}

pre_remove() {
    # Remove symlink in systemd
    systemctl disable goweatherserver
    # Stop server
    systemctl stop goweatherserver
    # Reload systemctl
    systemctl daemon-reload

    true
}

post_remove() {
    # Remove group and goweatherserver user
    name=goweatherserver
    getent passwd $name &>/dev/null && userdel $name >/dev/null
    getent group $name &>/dev/null && groupdel $name >/dev/null

    true
}