summarylogtreecommitdiffstats
path: root/sonospy-git.install
blob: 79afc11760e0cdb2625a1f387aa96642c78fb296 (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
post_install() {
  sed -i "s_'python pycpoint.py'_'python2 pycpoint.py'_" /opt/sonospy/app/sonospy_proxy
  touch /opt/sonospy/data/sonospy.db
  ln -s /opt/sonospy/data/sonospy.db /opt/sonospy/app/sonospy/sonospy.db
  mv -n /opt/sonospy/app/sonospy/pycpoint.ini.example /opt/sonospy/data/pycpoint.ini
  ln -s /opt/sonospy/data/pycpoint.ini /opt/sonospy/app/sonospy/pycpoint.ini
  mv -n /opt/sonospy/app/sonospy/scan.ini.example /opt/sonospy/data/scan.ini
  ln -s /opt/sonospy/data/scan.ini /opt/sonospy/app/sonospy/scan.ini
  mv -n /opt/sonospy/app/sonospy/userindex2.ini.example /opt/sonospy/data/userindex.ini
  ln -s /opt/sonospy/data/userindex.ini /opt/sonospy/app/sonospy/userindex.ini
  mv -n /opt/sonospy/app/sonospy/defaultindex.ini.example /opt/sonospy/data/defaultindex.ini
  ln -s /opt/sonospy/data/defaultindex.ini /opt/sonospy/app/sonospy/defaultindex.ini
  systemd-sysusers sonospy.conf
  systemd-tmpfiles --create sonospy.conf
  chown -R sonospy:sonospy /opt/sonospy
  systemctl daemon-reload

 echo "Add sonospy path /opt/sonospy/app/* to /usr/local/bin/python script: "
 echo "see https://wiki.archlinux.org/index.php/Python#Dealing_with_version_problem_in_build_scripts"
 echo "set music library location in /etc/sonospy/sonospy.conf"
 echo "Sonospy config files are stored in /opt/sonospy/data"
}

post_upgrade() {
  if [ ! -d /opt/sonospy/app ]; then
    post_install $1
  else
    chown -R sonospy:sonospy /opt/sonospy
    systemctl daemon-reload    
  fi
}

pre_remove() {
  systemctl stop sonospy.service
  systemctl stop sonospy-scan.service
}

post_remove() {
  rm -rf /opt/sonospy/app 

  echo "==> To remove config files, run as root: rm -rf /opt/sonospy"
  echo "====> rm -rf /etc/sonospy"
  echo "# Do not delete the 'sonospy' user automatically. It may still own files."
  echo "# If 'sonospy' is the only user in group 'sonospy', then userdel will also delete the group."
  echo "==> To delete the \"sonospy\" user, run as root: userdel --force sonospy"
}