summarylogtreecommitdiffstats
path: root/jackett.install
blob: e5051f9aedad7c60e817c867bf6828b61a241dd0 (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
post_install() {
  chown -R jackett: /usr/lib/jackett /var/lib/jackett
}

post_upgrade() {
  # At version 0.8.749-2 we moved configs to /var/lib/jackett, so
  # migrate old config directory.
  if [[ $(vercmp "0.8.749-2" "$2") -eq 1 ]]; then

    # Check for existing old config directory and non-existance of new config file.
    if [[ -d /usr/share/Jackett/.config/Jackett && ! -f /var/lib/jackett/ServerConfig.json ]]; then
      cp -a /usr/share/Jackett/.config/Jackett/* /var/lib/jackett/
    fi

    # Check for existing old mono config directory and non-existance of new mono config directory.
    if [[ -d /usr/share/Jackett/.config/.mono && ! -d /var/lib/jackett/.config/.mono ]]; then
      mkdir -p /var/lib/jackett/.config/
      cp -a /usr/share/Jackett/.config/.mono /var/lib/jackett/.config/
    fi

    # The jackett user's home directory needs to change too.
    if [[ "$( getent passwd jackett | cut -d: -f6 )" != "/var/lib/jackett" ]]; then
      usermod -d /var/lib/jackett jackett
    fi

    echo "Configs copied from /usr/share/Jackett/.config/Jackett -> /var/lib/jackett/."
    echo "After confirming, rm -rf /opt/Jackett /usr/share/Jackett."
  fi

  post_install "$1"
}