summarylogtreecommitdiffstats
path: root/terraria-server.install
blob: 9972ba2c99d54665e1b3d1f1e061f74bcd3fd4e3 (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
post_install() {
    if ! getent group terraria &>/dev/null; then
      groupadd -r -g 697 terraria >/dev/null
    fi

    if ! getent passwd terraria &>/dev/null; then
        useradd -r -u 697 -g terraria -d /var/lib/terraria-server/ \
            -s /bin/bash terraria >/dev/null
    fi
}

post_upgrade() {
    if getent passwd terraria && [[ $(id -u terraria) == 197 ]]; then
        userdel terraria
    fi
    if getent group terraria && [[ $(id -g terraria) == 197 ]]; then
        groupdel terraria
    fi
    post_install
}

post_remove() {
    if getent passwd terraria &>/dev/null; then
        userdel terraria >/dev/null
    fi

    if getent group terraria &>/dev/null; then
      groupdel terraria >/dev/null
    fi
}