uninstall.sh 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. #!/bin/sh
  2. #
  3. # razercfg uninstaller
  4. #
  5. # Copyright (C) 2014-2019 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. /lib/tmpfiles.d/razerd.conf\
  46. /sbin/razerd /bin/razerd\
  47. /share/applications/razercfg.desktop; do
  48. local path="${prefix}${f}"
  49. [ -e "$path" -o -h "$path" ] || continue
  50. uninstall "$path"
  51. done
  52. for f in "$prefix"/lib/python*/*-packages/pyrazer\
  53. "$prefix"/lib/python*/*-packages/razercfg-*.egg-info\
  54. "$prefix"/lib/librazer.so*\
  55. "$prefix"/share/icons/hicolor/scalable/apps/razercfg*.svg; do
  56. local path="$f"
  57. [ -e "$path" -o -h "$path" ] || continue
  58. uninstall "$path"
  59. done
  60. }
  61. uninstall_global()
  62. {
  63. for f in /etc/razer.conf /etc/init.d/razerd /etc/rc*.d/*razerd\
  64. /etc/pm/sleep.d/*-razer\
  65. /etc/udev/rules.d/*-razer-udev.rules\
  66. "$(pkg-config --variable=udevdir udev)/rules.d/*-razer.rules"\
  67. /lib/udev/rules.d/*-razer.rules\
  68. /usr/lib/udev/rules.d/*-razer.rules\
  69. /etc/systemd/system/razerd.service\
  70. "$(pkg-config --variable=systemdsystemunitdir systemd)/razerd.service"\
  71. /lib/systemd/system/razerd.service\
  72. /usr/lib/systemd/system/razerd.service; do
  73. local path="$f"
  74. [ -e "$path" -o -h "$path" ] || continue
  75. uninstall "$path"
  76. done
  77. }
  78. help()
  79. {
  80. echo "Usage: uninstall.sh PREFIX"
  81. echo
  82. echo "PREFIX is the prefix where razercfg was installed to."
  83. echo "This usually is /usr/local or /usr"
  84. echo
  85. echo "So an example uninstall call might look like this:"
  86. echo " ./uninstall.sh /usr/local"
  87. }
  88. if [ $# -eq 0 ]; then
  89. PREFIX="/usr/local"
  90. elif [ $# -eq 1 ]; then
  91. if [ "$1" = "-h" -o "$1" = "--help" ]; then
  92. help
  93. exit 0
  94. fi
  95. PREFIX="$1"
  96. else
  97. help
  98. exit 1
  99. fi
  100. uninstall_prefix "$PREFIX"
  101. uninstall_global
  102. exit 0