summarylogtreecommitdiffstats
path: root/asf.install
blob: fe50d9acc5b7785eb66a228471091aa231f2d65c (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
post_install() {
    if grep -q "^asf" /etc/group &> /dev/null ; then
        groupmod -n asf asf &> /dev/null                                                 
    else
        groupadd -r asf &> /dev/null
    fi
    if grep -q "^asf:" /etc/passwd 2> /dev/null ; then
        usermod -s /bin/false -c "ArchiSteamFarm daemon" -d /var/lib/asf -g asf asf &> /dev/null
    else
        useradd -s /bin/false -c "ArchiSteamFarm daemon user" -d /var/lib/asf -g asf -r asf &> /dev/null
    fi
    chown -R asf: /var/lib/asf
}

post_upgrade() {
    post_install $1
    if [ "$(vercmp $2 2.1.3.1-2)" -lt 0 ] && [ grep -q "^asf:" /etc/passwd 2> /dev/null]; then
      usermod -s /bin/false -c "ArchiSteamFarm daemon" -d /var/lib/asf -g asf asf &> /dev/null
    fi
    if [ "$(vercmp $2 2.1.3.1-2)" -lt 0 ] && [ -d /opt/asf/config ]; then
      mv /opt/asf/config/ /var/lib/asf/
      mv /opt/asf/log.txt /var/lib/asf/

      chown -R asf: /var/lib/asf

      echo "# ASF config folder has been moved to /var/lib/asf"
      echo "# Consider this change when using /usr/bin/asf (e.g. 'asf --path=/var/lib/asf')"
    fi
}

post_remove() {
    if grep -q "^asf:" /etc/passwd 2> /dev/null ; then
        userdel asf &> /dev/null
    fi
    if grep -q "^asf" /etc/group &> /dev/null ; then
        groupdel asf &> /dev/null                                                 
    fi
}