1
0

rclone_script-uninstall.sh 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  1. #!/bin/bash
  2. # define colors for output
  3. NORMAL="\Zn"
  4. BLACK="\Z0"
  5. RED="\Z1"
  6. GREEN="\Z2"
  7. YELLOW="\Z3\Zb"
  8. BLUE="\Z4"
  9. MAGENTA="\Z5"
  10. CYAN="\Z6"
  11. WHITE="\Z7"
  12. BOLD="\Zb"
  13. REVERSE="\Zr"
  14. UNDERLINE="\Zu"
  15. backtitle="RCLONE_SCRIPT uninstaller"
  16. logfile=~/scripts/rclone_script/rclone_script-uninstall.log
  17. source ~/scripts/rclone_script/rclone_script.ini
  18. oldRemote=""
  19. ##################
  20. # WELCOME DIALOG #
  21. ##################
  22. dialog \
  23. --stdout \
  24. --backtitle "${backtitle}" \
  25. --title "Welcome" \
  26. --ascii-lines \
  27. --colors \
  28. --no-collapse \
  29. --cr-wrap \
  30. --yesno \
  31. "\nThis script will ${RED}uninstall RCLONE_SCRIPT${NORMAL}. If you do this, your savefiles will no longer be synchonized!\n\nAre you sure you wish to continue?" \
  32. 20 90 2>&1 > /dev/tty \
  33. || exit
  34. ####################
  35. # DIALOG FUNCTIONS #
  36. ####################
  37. # Build progress from array $STEPS()
  38. # INPUT
  39. # $steps()
  40. # OUTPUT
  41. # $progress
  42. function buildProgress ()
  43. {
  44. progress=""
  45. for ((i=0; i<=${#steps[*]}; i++))
  46. do
  47. progress="${progress}${steps[i]}\n"
  48. done
  49. }
  50. # Show Progress dialog
  51. # INPUT
  52. # 1 > Percentage to show in dialog
  53. # $backtitle
  54. # $progress
  55. function dialogShowProgress ()
  56. {
  57. local percent="$1"
  58. buildProgress
  59. clear
  60. clear
  61. echo "${percent}" | dialog \
  62. --stdout \
  63. --colors \
  64. --ascii-lines \
  65. --no-collapse \
  66. --cr-wrap \
  67. --backtitle "${backtitle}" \
  68. --title "Uninstaller" \
  69. --gauge "${progress}" 36 90 0 \
  70. 2>&1 > /dev/tty
  71. sleep 1
  72. }
  73. ##################
  74. # STEP FUNCTIONS #
  75. ##################
  76. # Initialize array $STEPS()
  77. # OUTPUT
  78. # $steps()
  79. function initSteps ()
  80. {
  81. steps[1]="1. RCLONE"
  82. steps[2]=" 1a. Remove RCLONE configuration [ waiting... ]"
  83. steps[3]=" 1b. Remove RCLONE binary [ waiting... ]"
  84. steps[4]="2. PNGVIEW"
  85. steps[5]=" 2a. Remove PNGVIEW binary [ waiting... ]"
  86. steps[6]="3. IMAGEMAGICK"
  87. steps[7]=" 3a. Remove IMAGEMAGICK binary [ waiting... ]"
  88. steps[8]="4. RCLONE_SCRIPT"
  89. steps[9]=" 4a. Remove RCLONE_SCRIPT files [ waiting... ]"
  90. steps[10]=" 4b. Remove RCLONE_SCRIPT menu item [ waiting... ]"
  91. steps[11]="5. RUNCOMMAND"
  92. steps[12]=" 5a. Remove call from RUNCOMMAND-ONSTART [ waiting... ]"
  93. steps[13]=" 5b. Remove call from RUNCOMMAND-ONEND [ waiting... ]"
  94. steps[14]="6. Local SAVEFILE directory"
  95. steps[15]=" 6a. Move savefiles to default [ waiting... ]"
  96. steps[16]=" 6b. Remove local SAVEFILE directory [ waiting... ]"
  97. steps[17]="7. Configure RETROARCH"
  98. steps[18]=" 7a. Reset local SAVEFILE directories [ waiting... ]"
  99. steps[19]="8 Finalizing"
  100. steps[20]=" 8a. Remove UNINSTALL script [ waiting... ]"
  101. }
  102. # Update item of $STEPS() and show updated progress dialog
  103. # INPUT
  104. # 1 > Number of step to update
  105. # 2 > New status for step
  106. # 3 > Percentage to show in progress dialog
  107. # $steps()
  108. # OUTPUT
  109. # $steps()
  110. function updateStep ()
  111. {
  112. local step="$1"
  113. local newStatus="$2"
  114. local percent="$3"
  115. local oldline
  116. local newline
  117. # translate and colorize $NEWSTATUS
  118. case "${newStatus}" in
  119. "waiting") newStatus="[ ${NORMAL}WAITING...${NORMAL} ]" ;;
  120. "in progress") newStatus="[ ${NORMAL}IN PROGRESS${NORMAL} ]" ;;
  121. "done") newStatus="[ ${GREEN}DONE${NORMAL} ]" ;;
  122. "found") newStatus="[ ${GREEN}FOUND${NORMAL} ]" ;;
  123. "not found") newStatus="[ ${RED}NOT FOUND${NORMAL} ]" ;;
  124. "created") newStatus="[ ${GREEN}CREATED${NORMAL} ]" ;;
  125. "failed") newStatus="[ ${RED}FAILED${NORMAL} ]" ;;
  126. "skipped") newStatus="[ ${YELLOW}SKIPPED${NORMAL} ]" ;;
  127. *) newStatus="[ ${RED}UNDEFINED${NORMAL} ]" ;;
  128. esac
  129. # search $STEP in $STEPS
  130. for ((i=0; i<${#steps[*]}; i++))
  131. do
  132. if [[ ${steps[i]} =~ .*$step.* ]]
  133. then
  134. # update $STEP with $NEWSTATUS
  135. oldline="${steps[i]}"
  136. oldline="${oldline%%[*}"
  137. newline="${oldline}${newStatus}"
  138. steps[i]="${newline}"
  139. break
  140. fi
  141. done
  142. # show progress dialog
  143. dialogShowProgress ${percent}
  144. }
  145. # Show summary dialog
  146. function dialogShowSummary ()
  147. {
  148. dialog \
  149. --backtitle "${backtitle}" \
  150. --title "Summary" \
  151. --ascii-lines \
  152. --colors \
  153. --no-collapse \
  154. --cr-wrap \
  155. --yesno \
  156. "\n${GREEN}All done!${NORMAL}\n\nRCLONE_SCRIPT and its components have been removed. From now on, your saves and states will ${RED}NOT${NORMAL} be synchronized any longer. Your local savefiles have been moved to their default directories (inside each ROMS directory). Your remote files on\n ${YELLOW}${oldRemote}${NORMAL}\nhave ${GREEN}NOT${NORMAL} been removed.\n\nTo finish the uninstaller you should reboot your RetroPie now.\n\n${RED}Reboot RetroPie now?${NORMAL}" 25 90
  157. case $? in
  158. 0) sudo shutdown -r now ;;
  159. esac
  160. }
  161. #########################
  162. # UNINSTALLER FUNCTIONS #
  163. #########################
  164. # Uninstaller
  165. function uninstaller ()
  166. {
  167. initSteps
  168. dialogShowProgress 0
  169. saveRemote
  170. 1RCLONE
  171. 2PNGVIEW
  172. 3IMAGEMAGICK
  173. 4RCLONE_SCRIPT
  174. 5RUNCOMMAND
  175. 6LocalSAVEFILEDirectory
  176. 7RetroArch
  177. 8Finalize
  178. dialogShowSummary
  179. }
  180. function saveRemote ()
  181. {
  182. # list all remotes and their type
  183. remotes=$(rclone listremotes -l)
  184. # get line with RETROPIE remote
  185. retval=$(grep -i "^retropie:" <<< ${remotes})
  186. remoteType="${retval#*:}"
  187. remoteType=$(echo ${remoteType} | xargs)
  188. oldRemote="retropie:${remotebasedir} (${remoteType})"
  189. }
  190. function 1RCLONE ()
  191. {
  192. printf "$(date +%FT%T%:z):\t1RCLONE\tSTART\n" >> "${logfile}"
  193. # 1a. Remove RCLONE configuration
  194. printf "$(date +%FT%T%:z):\t1aRCLONEconfiguration\tSTART\n" >> "${logfile}"
  195. updateStep "1a" "in progress" 0
  196. if [ -d ~/.config/rclone ]
  197. then
  198. { #try
  199. sudo rm -r ~/.config/rclone >> "${logfile}" &&
  200. printf "$(date +%FT%T%:z):\t1aRCLONEconfiguration\tDONE\n" >> "${logfile}" &&
  201. updateStep "1a" "done" 8
  202. } || { #catch
  203. printf "$(date +%FT%T%:z):\t1aRCLONEconfiguration\tERROR\n" >> "${logfile}" &&
  204. updateStep "1a" "failed" 0 &&
  205. exit
  206. }
  207. else
  208. printf "$(date +%FT%T%:z):\t1aRCLONEconfiguration\tNOT FOUND\n" >> "${logfile}"
  209. updateStep "1a" "not found" 8
  210. fi
  211. # 1b. Remove RCLONE binary
  212. printf "$(date +%FT%T%:z):\t1bRCLONEbinary\tSTART\n" >> "${logfile}"
  213. updateStep "1b" "in progress" 8
  214. if [ -f /usr/bin/rclone ]
  215. then
  216. { #try
  217. sudo rm /usr/bin/rclone >> "${logfile}" &&
  218. printf "$(date +%FT%T%:z):\t1bRCLONEbinary\tDONE\n" >> "${logfile}" &&
  219. updateStep "1b" "done" 16
  220. } || { #catch
  221. printf "$(date +%FT%T%:z):\t1bRCLONEbinary\tERROR\n" >> "${logfile}" &&
  222. updateStep "1b" "failed" 8 &&
  223. exit
  224. }
  225. else
  226. printf "$(date +%FT%T%:z):\t1bRCLONEbinary\tNOT FOUND\n" >> "${logfile}"
  227. updateStep "1b" "not found" 16
  228. fi
  229. printf "$(date +%FT%T%:z):\t1RCLONE\tEND\n" >> "${logfile}"
  230. }
  231. function 2PNGVIEW ()
  232. {
  233. printf "$(date +%FT%T%:z):\t2PNGVIEW\tSTART\n" >> "${logfile}"
  234. # 2a. Remove PNGVIEW binary
  235. printf "$(date +%FT%T%:z):\t2aPNGVIEWbinary\tSTART\n" >> "${logfile}"
  236. updateStep "2a" "in progress" 16
  237. if [ -f /usr/bin/pngview ]
  238. then
  239. { #try
  240. sudo rm /usr/bin/pngview >> "${logfile}" &&
  241. sudo rm /usr/lib/libraspidmx.so.1 >> "${logfile}" &&
  242. printf "$(date +%FT%T%:z):\t2aPNGVIEWbinary\tDONE\n" >> "${logfile}" &&
  243. updateStep "2a" "done" 24
  244. } || { # catch
  245. printf "$(date +%FT%T%:z):\t2aPNGVIEWbinary\tERROR\n" >> "${logfile}" &&
  246. updateStep "2a" "failed" 16 &&
  247. exit
  248. }
  249. else
  250. printf "$(date +%FT%T%:z):\t2aPNGVIEWbinary\tNOT FOUND\n" >> "${logfile}" &&
  251. updateStep "2a" "not found" 24
  252. fi
  253. printf "$(date +%FT%T%:z):\t2PNGVIEW\tDONE\n" >> "${logfile}"
  254. }
  255. function 3IMAGEMAGICK ()
  256. {
  257. printf "$(date +%FT%T%:z):\t3IMAGEMAGICK\tSTART\n" >> "${logfile}"
  258. # 3a. Remove IMAGEMAGICK binary
  259. printf "$(date +%FT%T%:z):\t3aIMAGEMAGICKbinary\tSTART\n" >> "${logfile}"
  260. updateStep "3a" "in progress" 24
  261. if [ -f /usr/bin/convert ]
  262. then
  263. { # try
  264. sudo apt-get --yes remove imagemagick* >> "${logfile}" &&
  265. printf "$(date +%FT%T%:z):\t3aIMAGEMAGICKbinary\tDONE\n" >> "${logfile}" &&
  266. updateStep "3a" "done" 32
  267. } || { # catch
  268. printf "$(date +%FT%T%:z):\t3aIMAGEMAGICKbinary\tERROR\n" >> "${logfile}" &&
  269. updateStep "3a" "failed" 24 &&
  270. exit
  271. }
  272. else
  273. printf "$(date +%FT%T%:z):\t3aPIMAGEMAGICKbinary\tNOT FOUND\n" >> "${logfile}"
  274. updateStep "3a" "not found" 32
  275. fi
  276. printf "$(date +%FT%T%:z):\t3IMAGEMAGICK\tDONE\n" >> "${logfile}"
  277. }
  278. function 4RCLONE_SCRIPT ()
  279. {
  280. printf "$(date +%FT%T%:z):\t4RCLONE_SCRIPT\tSTART\n" >> "${logfile}"
  281. # 4a. Remove RCLONE_SCRIPT
  282. printf "$(date +%FT%T%:z):\t4aRCLONE_SCRIPTfiles\tSTART\n" >> "${logfile}"
  283. updateStep "4a" "in progress" 32
  284. if [ -f ~/scripts/rclone_script/rclone_script.sh ]
  285. then
  286. { # try
  287. sudo rm -f ~/scripts/rclone_script/rclone_script-install.* >> "${logfile}" &&
  288. sudo rm -f ~/scripts/rclone_script/rclone_script.* >> "${logfile}" &&
  289. printf "$(date +%FT%T%:z):\t4aRCLONE_SCRIPTfiles\tDONE\n" >> "${logfile}" &&
  290. updateStep "4a" "done" 40
  291. } || { # catch
  292. printf "$(date +%FT%T%:z):\t4aRCLONE_SCRIPTfiles\tERROR\n" >> "${logfile}" &&
  293. updateStep "4a" "failed" 32 &&
  294. exit
  295. }
  296. else
  297. printf "$(date +%FT%T%:z):\t4aRCLONE_SCRIPTfiles\tNOT FOUND\n" >> "${logfile}"
  298. updateStep "4a" "not found" 40
  299. fi
  300. # 4b. Remove RCLONE_SCRIPT menu item
  301. printf "$(date +%FT%T%:z):\t4bRCLONE_SCRIPTMenuItem\tSTART\n" >> "${logfile}"
  302. updateStep "4b" "in progress" 40
  303. local found=0
  304. if [[ $(xmlstarlet sel -t -v "count(/gameList/game[path='./rclone_script-redirect.sh.sh'])" ~/.emulationstation/gamelists/retropie/gamelist.xml) -ne 0 ]]
  305. then
  306. found=$(($found + 1))
  307. printf "$(date +%FT%T%:z):\t4bRCLONE_SCRIPTMenuItem\tFOUND\n" >> "${logfile}"
  308. xmlstarlet ed \
  309. --inplace \
  310. --delete "//game[path='./rclone_script-redirect.sh']" \
  311. ~/.emulationstation/gamelists/retropie/gamelist.xml
  312. printf "$(date +%FT%T%:z):\t4bRCLONE_SCRIPTMenuItem\tREMOVED\n" >> "${logfile}"
  313. else
  314. printf "$(date +%FT%T%:z):\t4bRCLONE_SCRIPTMenuItem\tNOT FOUND\n" >> "${logfile}"
  315. fi
  316. if [ -f ~/RetroPie/retropiemenu/rclone_script-redirect.sh ]
  317. then
  318. found=$(($found + 1))
  319. printf "$(date +%FT%T%:z):\t4bRCLONE_SCRIPTMenuItemScript\tFOUND\n" >> "${logfile}"
  320. sudo rm ~/RetroPie/retropiemenu/rclone_script-redirect.sh >> "${logfile}"
  321. sudo rm ~/scripts/rclone_script/rclone_script-menu.sh >> "${logfile}"
  322. printf "$(date +%FT%T%:z):\t4bRCLONE_SCRIPTMenuItemScript\tREMOVED\n" >> "${logfile}"
  323. else
  324. printf "$(date +%FT%T%:z):\t4bRCLONE_SCRIPTMenuItemScript\tNOT FOUND\n" >> "${logfile}"
  325. fi
  326. case $found in
  327. 0) updateStep "4b" "not found" 48 ;;
  328. 1) updateStep "4b" "done" 48 ;;
  329. 2) updateStep "4b" "done" 48 ;;
  330. esac
  331. printf "$(date +%FT%T%:z):\t4RCLONE_SCRIPT\tDONE\n" >> "${logfile}"
  332. }
  333. function 5RUNCOMMAND ()
  334. {
  335. printf "$(date +%FT%T%:z):\t5RUNCOMMAND\tSTART\n" >> "${logfile}"
  336. # 5a. Remove call from RUNCOMMAND-ONSTART
  337. printf "$(date +%FT%T%:z):\t5RUNCOMMAND-ONSTART\tSTART\n" >> "${logfile}"
  338. updateStep "5a" "in progress" 48
  339. if [[ $(grep -c "~/scripts/rclone_script/rclone_script.sh" /opt/retropie/configs/all/runcommand-onstart.sh) -gt 0 ]]
  340. then
  341. { #try
  342. sed -i "/~\/scripts\/rclone_script\/rclone_script.sh /d" /opt/retropie/configs/all/runcommand-onstart.sh &&
  343. printf "$(date +%FT%T%:z):\t5RUNCOMMAND-ONSTART\tDONE\n" >> "${logfile}" &&
  344. updateStep "5a" "done" 56
  345. } || { # catch
  346. printf "$(date +%FT%T%:z):\t5RUNCOMMAND-ONSTART\tERROR\n" >> "${logfile}" &&
  347. updateStep "5a" "failed" 48
  348. }
  349. else
  350. printf "$(date +%FT%T%:z):\t5RUNCOMMAND-ONSTART\tNOT FOUND\n" >> "${logfile}"
  351. updateStep "5a" "not found" 56
  352. fi
  353. # 5b. Remove call from RUNCOMMAND-ONEND
  354. printf "$(date +%FT%T%:z):\t5RUNCOMMAND-ONEND\tSTART\n" >> "${logfile}"
  355. updateStep "5b" "in progress" 56
  356. if [[ $(grep -c "~/scripts/rclone_script/rclone_script.sh" /opt/retropie/configs/all/runcommand-onend.sh) -gt 0 ]]
  357. then
  358. { #try
  359. sed -i "/~\/scripts\/rclone_script\/rclone_script.sh /d" /opt/retropie/configs/all/runcommand-onend.sh &&
  360. printf "$(date +%FT%T%:z):\t5RUNCOMMAND-ONEND\tDONE\n" >> "${logfile}" &&
  361. updateStep "5b" "done" 64
  362. } || { # catch
  363. printf "$(date +%FT%T%:z):\t5RUNCOMMAND-ONEND\tERROR\n" >> "${logfile}" &&
  364. updateStep "5b" "failed" 56
  365. }
  366. else
  367. printf "$(date +%FT%T%:z):\t5RUNCOMMAND-ONEND\tNOT FOUND\n" >> "${logfile}"
  368. updateStep "5b" "not found" 64
  369. fi
  370. printf "$(date +%FT%T%:z):\t5RUNCOMMAND\tDONE\n" >> "${logfile}"
  371. }
  372. function 6LocalSAVEFILEDirectory ()
  373. {
  374. printf "$(date +%FT%T%:z):\t6LocalSAVEFILEDirectory\tSTART\n" >> "${logfile}"
  375. # 6a. Move savefiles to default
  376. printf "$(date +%FT%T%:z):\t6a moveFilesToDefault\tSTART\n" >> "${logfile}"
  377. updateStep "6a" "in progress" 64
  378. #counter=1
  379. #while [ $counter -le 10000 ]
  380. #do
  381. # echo "." > ~/RetroPie/saves/gba/datei_${counter}.srm
  382. # ((counter++))
  383. #done
  384. if [ -d ~/RetroPie/saves ]
  385. then
  386. # start copy task in background, pipe numbered output into COPY.TXT and to LOGFILE
  387. $(cp -v -r ~/RetroPie/saves/* ~/RetroPie/roms | cat -n | tee copy.txt | cat >> "${logfile}") &
  388. # show content of COPY.TXT
  389. dialog \
  390. --backtitle "${backtitle}" \
  391. --title "Copying savefiles to default..." \
  392. --ascii-lines \
  393. --colors \
  394. --no-collapse \
  395. --cr-wrap \
  396. --tailbox copy.txt 40 120
  397. wait
  398. rm copy.txt
  399. #rm ~/RetroPie/saves/gba/datei*
  400. #rm ~/RetroPie/roms/gba/datei*
  401. updateStep "6a" "done" 72
  402. else
  403. printf "$(date +%FT%T%:z):\t6a moveFilesToDefault\tNOT FOUND\n" >> "${logfile}"
  404. updateStep "6a" "not found" 72
  405. fi
  406. # 6b. Remove local SAVEFILE directory
  407. printf "$(date +%FT%T%:z):\t6b removeLocalSAVEFILEbasedir\tSTART\n" >> "${logfile}"
  408. updateStep "6b" "in progress" 72
  409. if [ -d ~/RetroPie/saves ]
  410. then
  411. # start remove task in background, pipe numbered output into DELETE.TXT and to LOGFILE
  412. $(sudo rm --recursive --force --verbose ~/RetroPie/saves | cat -n | tee delete.txt | cat >> "${logfile}") &
  413. # show content of REMOVE.TXT
  414. dialog \
  415. --backtitle "${backtitle}" \
  416. --title "Removing savefiles from local base dir..." \
  417. --ascii-lines \
  418. --colors \
  419. --no-collapse \
  420. --cr-wrap \
  421. --tailbox delete.txt 40 120
  422. wait
  423. rm delete.txt
  424. printf "$(date +%FT%T%:z):\t6b removeLocalSAVEFILEbasedir\tDONE\n" >> "${logfile}"
  425. updateStep "6b" "done" 80
  426. else
  427. printf "$(date +%FT%T%:z):\t6b removeLocalSAVEFILEbasedir\tNOT FOUND\n" >> "${logfile}"
  428. updateStep "6b" "skipped" 80
  429. fi
  430. printf "$(date +%FT%T%:z):\t6LocalSAVEFILEDirectory\tDONE\n" >> "${logfile}"
  431. }
  432. function 7RetroArch ()
  433. {
  434. printf "$(date +%FT%T%:z):\t7RetroArch\tSTART\n" >> "${logfile}"
  435. # 7a. Reset local SAVEFILE directories
  436. printf "$(date +%FT%T%:z):\t7a resetSAVEFILEdirectories\tSTART\n" >> "${logfile}"
  437. updateStep "7a" "in progress" 80
  438. local found=0
  439. # for each directory...
  440. for directory in /opt/retropie/configs/*
  441. do
  442. system="${directory##*/}"
  443. # skip system "all"
  444. if [ "${system}" == "all" ]
  445. then
  446. continue
  447. fi
  448. # check if there'a system specific RETROARCH.CFG
  449. if [ -f "${directory}/retroarch.cfg" ]
  450. then
  451. printf "$(date +%FT%T%:z):\t7a resetSAVEFILEdirectories\tFOUND retroarch.cfg for ${system}\n" >> "${logfile}"
  452. # check if RETROARCH.CFG contains SAVEFILE pointing to ~/RetroPie/saves/<SYSTEM>
  453. if [[ $(grep -c "^savefile_directory = \"~/RetroPie/saves/${system}\"" ${directory}/retroarch.cfg) -gt 0 ]]
  454. then
  455. printf "$(date +%FT%T%:z):\t7a resetSAVEFILEdirectories\tFOUND savefile_directory\n" >> "${logfile}"
  456. found=$(($found + 1))
  457. # replace parameter
  458. sed -i "/^savefile_directory = \"~\/RetroPie\/saves\/${system}\"/c\savefile_directory = \"default\"" ${directory}/retroarch.cfg
  459. printf "$(date +%FT%T%:z):\t7a resetSAVEFILEdirectories\tREPLACED savefile_directory\n" >> "${logfile}"
  460. else
  461. printf "$(date +%FT%T%:z):\t7a resetSAVEFILEdirectories\tNOT FOUND savefile_directory\n" >> "${logfile}"
  462. fi
  463. # check if RETROARCH.CFG contains SAVESTATE pointing to ~/RetroPie/saves/<SYSTEM>
  464. if [[ $(grep -c "^savestate_directory = \"~/RetroPie/saves/${system}\"" ${directory}/retroarch.cfg) -gt 0 ]]
  465. then
  466. printf "$(date +%FT%T%:z):\t7a resetSAVESTATEdirectories\tFOUND savestate_directory\n" >> "${logfile}"
  467. found=$(($found + 1))
  468. # replace parameter
  469. sed -i "/^savestate_directory = \"~\/RetroPie\/saves\/${system}\"/c\savestate_directory = \"default\"" ${directory}/retroarch.cfg
  470. printf "$(date +%FT%T%:z):\t7a resetSAVESTATEdirectories\tREPLACED savestate_directory\n" >> "${logfile}"
  471. else
  472. printf "$(date +%FT%T%:z):\t7a resetSAVESTATEdirectories\tNOT FOUND savestate_directory\n" >> "${logfile}"
  473. fi
  474. fi
  475. done
  476. printf "$(date +%FT%T%:z):\t7a resetSAVEFILEdirectories\tDINE\n" >> "${logfile}"
  477. if [[ $found -eq 0 ]]
  478. then
  479. updateStep "7a" "not found" 88
  480. else
  481. updateStep "7a" "done" 88
  482. fi
  483. printf "$(date +%FT%T%:z):\t7RetroArch\tDONE\n" >> "${logfile}"
  484. }
  485. function 8Finalize ()
  486. {
  487. printf "$(date +%FT%T%:z):\t8Finalize\tSTART\n" >> "${logfile}"
  488. # 8a. Remove UNINSTALL script
  489. printf "$(date +%FT%T%:z):\t8a removeUNINSTALLscript\tSTART\n" >> "${logfile}"
  490. updateStep "8a" "in progress" 88
  491. printf "$(date +%FT%T%:z):\t8a removeUNINSTALLscript\tDONE\n" >> "${logfile}"
  492. updateStep "8a" "done" 100
  493. printf "$(date +%FT%T%:z):\t8Finalize\tDONE\n" >> "${logfile}"
  494. # move LOGFILE to HOME
  495. mv ~/scripts/rclone_script/rclone_script-uninstall.log ~
  496. # remove RCLONE_SCRIPT directory
  497. rm -rf ~/scripts/rclone_script
  498. }
  499. ########
  500. # MAIN #
  501. ########
  502. uninstaller