uninstall.sh 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. #!/bin/sh
  2. #
  3. # razercfg uninstaller
  4. #
  5. # Copyright (C) 2014-2016 Michael Buesch <m@bues.ch>
  6. #
  7. # This program is free software; you can redistribute it and/or
  8. # modify it under the terms of the GNU General Public License
  9. # as published by the Free Software Foundation; either version 2
  10. # of the License, or (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. die()
  17. {
  18. echo "$*"
  19. exit 1
  20. }
  21. # $1=message
  22. ask()
  23. {
  24. read -p "$*? [Y/n]" ok
  25. [ "$ok" = "y" -o "$ok" = "Y" -o \
  26. "$ok" = "1" -o "$ok" = "" ] && return 0
  27. return 1
  28. }
  29. # $1=file/dir
  30. uninstall()
  31. {
  32. local path="$1"
  33. ask "Delete $path" || return
  34. rm -r "$path" || die "Failed to delete '$path'"
  35. }
  36. # $1=prefix
  37. uninstall_prefix()
  38. {
  39. local prefix="$1"
  40. for f in /bin/pyrazer.py /bin/pyrazer.pyc /bin/pyrazer.pyo\
  41. /bin/razercfg\
  42. /bin/qrazercfg\
  43. /bin/qrazercfg-applet\
  44. /bin/razer-gamewrapper\
  45. /sbin/razerd /bin/razerd\
  46. /share/applications/razercfg.desktop; do
  47. local path="${prefix}${f}"
  48. [ -e "$path" -o -h "$path" ] || continue
  49. uninstall "$path"
  50. done
  51. for f in "$prefix"/lib/python*/*-packages/pyrazer\
  52. "$prefix"/lib/python*/*-packages/razercfg-*.egg-info\
  53. "$prefix"/lib/librazer.so*; do
  54. local path="$f"
  55. [ -e "$path" -o -h "$path" ] || continue
  56. uninstall "$path"
  57. done
  58. }
  59. uninstall_global()
  60. {
  61. for f in /etc/razer.conf /etc/init.d/razerd /etc/rc*.d/*razerd\
  62. /etc/pm/sleep.d/*-razer\
  63. /etc/udev/rules.d/*-razer-udev.rules\
  64. "$(pkg-config --variable=udevdir udev)/rules.d/*-razer.rules"\
  65. /lib/udev/rules.d/*-razer.rules\
  66. /usr/lib/udev/rules.d/*-razer.rules\
  67. /etc/systemd/system/razerd.service\
  68. "$(pkg-config --variable=systemdsystemunitdir systemd)/razerd.service"\
  69. /lib/systemd/system/razerd.service\
  70. /usr/lib/systemd/system/razerd.service; do
  71. local path="$f"
  72. [ -e "$path" -o -h "$path" ] || continue
  73. uninstall "$path"
  74. done
  75. }
  76. help()
  77. {
  78. echo "Usage: uninstall.sh PREFIX"
  79. echo
  80. echo "PREFIX is the prefix where razercfg was installed to."
  81. echo "This usually is /usr/local or /usr"
  82. echo
  83. echo "So an example uninstall call might look like this:"
  84. echo " ./uninstall.sh /usr/local"
  85. }
  86. [ $# -eq 1 ] || {
  87. help
  88. exit 1
  89. }
  90. PREFIX="$1"
  91. uninstall_prefix "$PREFIX"
  92. uninstall_global
  93. exit 0