1
0

rclone_script-uninstall.sh 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. #!/bin/bash
  2. # define colors for output
  3. NORMAL=$(tput sgr0)
  4. RED=$(tput setaf 1)
  5. GREEN=$(tput setaf 2)
  6. YELLOW=$(tput setaf 3)
  7. BLUE=$(tput setaf 4)
  8. UNDERLINE=$(tput smul)
  9. header ()
  10. {
  11. # clear screen
  12. clear
  13. printf "${UNDERLINE}Uninstall cloud sync via RCLONE\n"
  14. printf "\n"
  15. printf "${NORMAL}Please select the options you'd like to remove from this system.\n"
  16. printf "Please note that this script also allows you to ${RED}delete your saves${NORMAL}.\n"
  17. printf "\n"
  18. printf "To ${GREEN}keep your saves${NORMAL}, ${RED}do not remove ${NORMAL}the ${YELLOW}local base save directory${NORMAL}\n"
  19. printf "and the ${YELLOW}core overrides ${NORMAL}pointing to these directories!\n"
  20. printf "\n"
  21. }
  22. removeRCLONE ()
  23. {
  24. # remove RCLONE binary
  25. printf "${NORMAL} Removing RCLONE binary... "
  26. { #try
  27. retval=$(sudo rm /usr/bin/rclone 2>&1) &&
  28. printf "${GREEN}Done\n"
  29. } || { #catch
  30. printf "${RED}ERROR: ${retval}\n"
  31. }
  32. }
  33. removeRCLONEconfiguration ()
  34. {
  35. # remove RCLONE configuration
  36. printf "${NORMAL} Removing RCLONE configuration... "
  37. { #try
  38. retval=$(rclone config delete retropie 2>&1) &&
  39. printf "${GREEN}Done\n"
  40. } || { #catch
  41. printf "${RED}ERROR: ${retval}\n"
  42. }
  43. }
  44. removePNGVIEW ()
  45. {
  46. # remove PNGVIEW binary
  47. printf "${NORMAL} Removing PNGVIEW binary... "
  48. { #try
  49. retval=$(sudo rm /usr/bin/pngview 2>&1) &&
  50. retval=$(sudo rm /usr/lib/libraspidmx.so.1 2>&1) &&
  51. printf "${GREEN}Done\n"
  52. } || { #catch
  53. printf "${RED}ERROR: ${retval}\n"
  54. }
  55. }
  56. removeIMAGEMAGICK ()
  57. {
  58. # remove IMAGEMAGICK
  59. printf "${NORMAL} Removing IMAGEMAGICK... "
  60. { #try
  61. retval=$(sudo apt-get --yes remove imagemagick* 2>&1) &&
  62. printf "${GREEN}Done\n"
  63. } || { #catch
  64. printf "${RED}ERROR: ${retval}\n"
  65. }
  66. }
  67. removeRUNCOMMAND ()
  68. {
  69. # remove RUNCOMMAND scripts
  70. printf "${NORMAL} Removing RUNCOMMAND calls to RCLONE_SCRIPT... "
  71. { #try
  72. retval=$(sed -i "/^~\/scripts\/rclone_script.sh /d" /opt/retropie/configs/all/runcommand-onstart.sh 2>&1) &&
  73. retval=$(sed -i "/^~\/scripts\/rclone_script.sh /d" /opt/retropie/configs/all/runcommand-onend.sh 2>&1) &&
  74. printf "${GREEN}Done\n"
  75. } || { #catch
  76. printf "${RED}ERROR: ${retval}\n"
  77. }
  78. }
  79. removeRCLONE_SCRIPT ()
  80. {
  81. # remove RCLONE_SCRIPT
  82. printf "${NORMAL} Removing RCLONE_SCRIPT... "
  83. { #try
  84. #don't acutally do this while it's being made
  85. retval=$(rm -d ~/scripts/rclone_script.sh 2>&1) &&
  86. retval=$(rm -d ~/scripts/rclone_script.ini 2>&1) &&
  87. printf "${GREEN}Done\n"
  88. } || { #catch
  89. printf "${RED}ERROR: ${retval}\n"
  90. }
  91. }
  92. removeRCLONE_SCRIPT-FULLSYNC ()
  93. {
  94. # TODO
  95. }
  96. removeLocalSaveDirectory ()
  97. {
  98. # remove base save directory
  99. printf "${NORMAL} Removing local base save directory... "
  100. { #try
  101. retval=$(rm -r ~/RetroPie/saves 2>&1) &&
  102. printf "${GREEN}Done\n"
  103. } || { #catch
  104. printf "${RED}ERROR: ${retval}\n"
  105. }
  106. }
  107. # main program
  108. header
  109. read -p "${NORMAL}Remove RCLONE configuration? ([y], n): " userInput
  110. userInput=${userInput:-y}
  111. if [ "${userInput}" = "y" ]; then
  112. removeRCLONEconfiguration
  113. fi
  114. read -p "${NORMAL}Remove RCLONE binary? ([y], n): " userInput
  115. userInput=${userInput:-y}
  116. if [ "${userInput}" = "y" ]; then
  117. removeRCLONE
  118. fi
  119. read -p "${NORMAL}Remove PNGVIEW binary? ([y], n): " userInput
  120. userInput=${userInput:-y}
  121. if [ "${userInput}" = "y" ]; then
  122. removePNGVIEW
  123. fi
  124. read -p "${NORMAL}Remove IMAGEMAGICK? ([y], n): " userInput
  125. userInput=${userInput:-y}
  126. if [ "${userInput}" = "y" ]; then
  127. removeIMAGEMAGICK
  128. fi
  129. read -p "${NORMAL}Remove RUNCOMMAND calls to RCLONE_SCRIPT? ([y], n): " userInput
  130. userInput=${userInput:-y}
  131. if [ "${userInput}" = "y" ]; then
  132. printf " ${RED}ATTENTION!${NORMAL} By removing these calls your saves will no longer be\n"
  133. printf " synchronized. Your progress in games will be available on this machine only!\n"
  134. read -p " ${NORMAL}Really proceed? ([y], n): " userInput
  135. userInput=${userInput:-y}
  136. if [ "${userInput}" = "y" ]; then
  137. removeRUNCOMMAND
  138. fi
  139. fi
  140. read -p "${NORMAL}Remove RCLONE_SCRIPT? ([y], n): " userInput
  141. userInput=${userInput:-y}
  142. if [ "${userInput}" = "y" ]; then
  143. printf " ${RED}ATTENTION!${NORMAL} By removing RCLONE_SCRIPT your saves will no longer be\n"
  144. printf " synchronized. Your progress in games will be available on this machine only!\n"
  145. read -p " ${NORMAL}Really proceed? ([y], n): " userInput
  146. userInput=${userInput:-y}
  147. if [ "${userInput}" = "y" ]; then
  148. removeRCLONE_SCRIPT
  149. fi
  150. fi
  151. read -p "${NORMAL}Remove local base save directory? ([y], n): " userInput
  152. userInput=${userInput:-y}
  153. if [ "${userInput}" = "y" ]; then
  154. printf " ${RED}ATTENTION!${NORMAL} This directory contains your saves.\n"
  155. printf " By removing this directory you ${RED}WILL LOSE ${NORMAL}all saves!\n"
  156. read -p " ${NORMAL}Really proceed? ([y], n): " userInput
  157. userInput=${userInput:-y}
  158. if [ "${userInput}" = "y" ]; then
  159. removeLocalSaveDirectory
  160. fi
  161. fi