summarylogtreecommitdiffstats
path: root/headphones.install
blob: 2dfb8347452d6d8d51c882d4f4c83b70fdfd17bb (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
post_upgrade() {
  if (( $(vercmp "0.5.18.r159.gda9287d7-2" "$2") > 0 )); then
    if [[ -f /opt/headphones/config.ini && ! -f /var/lib/headphones/config.ini ]]; then
      cp -a /opt/headphones/config.ini /var/lib/headphones/
      echo "Copied config.ini from /opt/headphones/ -> /var/lib/headphones/"
    fi

    if [[ -f /opt/headphones/headphones.db && ! -f /var/lib/headphones/headphones.db ]]; then
      cp -a /opt/headphones/headphones.db /var/lib/headphones/
      echo "Copied headphones.db from /opt/headphones/ -> /var/lib/headphones/"
    fi

    if [[ -d /opt/headphones/logs && ! -d /var/lib/headphones/logs ]]; then
      cp -a /opt/headphones/logs /var/lib/headphones/
      echo "Copied logs from /opt/headphones/ -> /var/lib/headphones/"
    fi

    if [[ -d /opt/headphones/cache && ! -d /var/lib/headphones/cache ]]; then
      cp -a /opt/headphones/cache /var/lib/headphones/
      echo "Copied cache from /opt/headphones/ -> /var/lib/headphones/"
    fi
  fi

  if [[ "$( getent passwd headphones | cut -d: -f6 )" != "/var/lib/headphones" ]]; then
    usermod -d /var/lib/headphones headphones
    if [[ $? -ne 0 ]]; then
      echo "Could not change headphones users home directory."
      echo "Run: sudo systemctl stop headphones ; sudo usermod -d /var/lib/headphones headphones ; sudo systemctl start headphones"
    fi
  fi

  if [[ -d /opt/lazylibrarian ]]; then
    echo "Remove /opt/lazylibrarian if everything is working correctly from /var/lib/lazylibrarian now."
  fi
}