uninstall.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #!/bin/sh
  2. # Lyrebird installer script. If running as root then will install at /usr/local/{bin,share},
  3. # otherwise will install at ~/.local/{bin,share}.
  4. VERBOSE=${VERBOSE:-0}
  5. DRYRUN=${DRYRUN:-0}
  6. # Initial setup
  7. if [ $DRYRUN = 1 ]; then DRYRUN_INFO=" (dryrun)"; fi
  8. ECHO_PREFIX="[lyrebird]$DRYRUN_INFO"
  9. info_echo() {
  10. echo "$ECHO_PREFIX $1"
  11. }
  12. warning_echo() {
  13. echo "[warning]$DRYRUN_INFO $1"
  14. }
  15. verbose_echo() {
  16. if [ $VERBOSE = 1 ]; then
  17. echo "$ECHO_PREFIX $1"
  18. fi
  19. }
  20. delete_file() {
  21. if [ -f "$1" ]; then
  22. if [ "$(stat -c '%u' $1)" -ne "$(id -u)" ]; then
  23. warning_echo "Cannot delete without root access: $1"
  24. return
  25. fi
  26. info_echo "Deleting: $1"
  27. if [ $DRYRUN != 1 ]; then rm "$1"; fi
  28. else
  29. verbose_echo "File not present, skipping: $1"
  30. fi
  31. }
  32. delete_dir() {
  33. if [ -d "$1" ]; then
  34. if [ "$(stat -c '%u' $1)" -ne "$(id -u)" ]; then
  35. warning_echo "Cannot delete without root access: $1"
  36. return
  37. fi
  38. info_echo "Deleting: $1"
  39. if [ $DRYRUN != 1 ]; then rm -rf "$1"; fi
  40. else
  41. verbose_echo "Directory not present, skipping: $1"
  42. fi
  43. }
  44. if [ "$(id -u)" -eq 0 ]; then
  45. INSTALL_PREFIX="${INSTALL_PREFIX:-/usr/local}"
  46. else
  47. INSTALL_PREFIX="${INSTALL_PREFIX:-$HOME/.local}"
  48. fi
  49. verbose_echo "Uninstalling Lyrebird from prefix: ${INSTALL_PREFIX}"
  50. delete_dir "$INSTALL_PREFIX/bin/lyrebird/"
  51. delete_dir "$INSTALL_PREFIX/share/lyrebird/"
  52. delete_file "$INSTALL_PREFIX/bin/lyrebird"
  53. delete_dir "/etc/lyrebird/"
  54. delete_dir "$HOME/.config/lyrebird/"
  55. delete_file "$INSTALL_PREFIX/share/applications/Lyrebird.desktop"
  56. delete_file "$INSTALL_PREFIX/share/applications/lyrebird.desktop"