rclone_script-uninstall.sh 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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. # TODO: Issue #4: Move save files to default directories
  99. # remove base save directory
  100. printf "${NORMAL} Removing local base save directory... "
  101. { #try
  102. retval=$(rm -r ~/RetroPie/saves 2>&1) &&
  103. printf "${GREEN}Done\n"
  104. } || { #catch
  105. printf "${RED}ERROR: ${retval}\n"
  106. }
  107. }
  108. resetSavefileDirectories ()
  109. {
  110. # TODO: Issue #4: Reset savefile directories in CFG to default
  111. }
  112. # main program
  113. header
  114. read -p "${NORMAL}Remove RCLONE configuration? ([y], n): " userInput
  115. userInput=${userInput:-y}
  116. if [ "${userInput}" = "y" ]; then
  117. removeRCLONEconfiguration
  118. fi
  119. read -p "${NORMAL}Remove RCLONE binary? ([y], n): " userInput
  120. userInput=${userInput:-y}
  121. if [ "${userInput}" = "y" ]; then
  122. removeRCLONE
  123. fi
  124. read -p "${NORMAL}Remove PNGVIEW binary? ([y], n): " userInput
  125. userInput=${userInput:-y}
  126. if [ "${userInput}" = "y" ]; then
  127. removePNGVIEW
  128. fi
  129. read -p "${NORMAL}Remove IMAGEMAGICK? ([y], n): " userInput
  130. userInput=${userInput:-y}
  131. if [ "${userInput}" = "y" ]; then
  132. removeIMAGEMAGICK
  133. fi
  134. read -p "${NORMAL}Remove RUNCOMMAND calls to RCLONE_SCRIPT? ([y], n): " userInput
  135. userInput=${userInput:-y}
  136. if [ "${userInput}" = "y" ]; then
  137. printf " ${RED}ATTENTION!${NORMAL} By removing these calls your saves will no longer be\n"
  138. printf " synchronized. Your progress in games will be available on this machine only!\n"
  139. read -p " ${NORMAL}Really proceed? ([y], n): " userInput
  140. userInput=${userInput:-y}
  141. if [ "${userInput}" = "y" ]; then
  142. removeRUNCOMMAND
  143. fi
  144. fi
  145. read -p "${NORMAL}Remove RCLONE_SCRIPT? ([y], n): " userInput
  146. userInput=${userInput:-y}
  147. if [ "${userInput}" = "y" ]; then
  148. printf " ${RED}ATTENTION!${NORMAL} By removing RCLONE_SCRIPT your saves will no longer be\n"
  149. printf " synchronized. Your progress in games will be available on this machine only!\n"
  150. read -p " ${NORMAL}Really proceed? ([y], n): " userInput
  151. userInput=${userInput:-y}
  152. if [ "${userInput}" = "y" ]; then
  153. removeRCLONE_SCRIPT
  154. fi
  155. fi
  156. read -p "${NORMAL}Remove local base save directory? ([y], n): " userInput
  157. userInput=${userInput:-y}
  158. if [ "${userInput}" = "y" ]; then
  159. printf " ${RED}ATTENTION!${NORMAL} This directory contains your saves.\n"
  160. printf " By removing this directory you ${RED}WILL LOSE ${NORMAL}all saves!\n"
  161. read -p " ${NORMAL}Really proceed? ([y], n): " userInput
  162. userInput=${userInput:-y}
  163. if [ "${userInput}" = "y" ]; then
  164. removeLocalSaveDirectory
  165. fi
  166. fi