uninstall.sh 2.6 KB

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