rclone_script-uninstall.sh 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606
  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-menu.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-menu.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-menu.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-menu.sh >> "${logfile}"
  321. printf "$(date +%FT%T%:z):\t4bRCLONE_SCRIPTMenuItemScript\tREMOVED\n" >> "${logfile}"
  322. else
  323. printf "$(date +%FT%T%:z):\t4bRCLONE_SCRIPTMenuItemScript\tNOT FOUND\n" >> "${logfile}"
  324. fi
  325. case $found in
  326. 0) updateStep "4b" "not found" 48 ;;
  327. 1) updateStep "4b" "done" 48 ;;
  328. 2) updateStep "4b" "done" 48 ;;
  329. esac
  330. printf "$(date +%FT%T%:z):\t4RCLONE_SCRIPT\tDONE\n" >> "${logfile}"
  331. }
  332. function 5RUNCOMMAND ()
  333. {
  334. printf "$(date +%FT%T%:z):\t5RUNCOMMAND\tSTART\n" >> "${logfile}"
  335. # 5a. Remove call from RUNCOMMAND-ONSTART
  336. printf "$(date +%FT%T%:z):\t5RUNCOMMAND-ONSTART\tSTART\n" >> "${logfile}"
  337. updateStep "5a" "in progress" 48
  338. if [[ $(grep -c "~/scripts/rclone_script/rclone_script.sh" /opt/retropie/configs/all/runcommand-onstart.sh) -gt 0 ]]
  339. then
  340. { #try
  341. sed -i "/~\/scripts\/rclone_script\/rclone_script.sh /d" /opt/retropie/configs/all/runcommand-onstart.sh &&
  342. printf "$(date +%FT%T%:z):\t5RUNCOMMAND-ONSTART\tDONE\n" >> "${logfile}" &&
  343. updateStep "5a" "done" 56
  344. } || { # catch
  345. printf "$(date +%FT%T%:z):\t5RUNCOMMAND-ONSTART\tERROR\n" >> "${logfile}" &&
  346. updateStep "5a" "failed" 48
  347. }
  348. else
  349. printf "$(date +%FT%T%:z):\t5RUNCOMMAND-ONSTART\tNOT FOUND\n" >> "${logfile}"
  350. updateStep "5a" "not found" 56
  351. fi
  352. # 5b. Remove call from RUNCOMMAND-ONEND
  353. printf "$(date +%FT%T%:z):\t5RUNCOMMAND-ONEND\tSTART\n" >> "${logfile}"
  354. updateStep "5b" "in progress" 56
  355. if [[ $(grep -c "~/scripts/rclone_script/rclone_script.sh" /opt/retropie/configs/all/runcommand-onend.sh) -gt 0 ]]
  356. then
  357. { #try
  358. sed -i "/~\/scripts\/rclone_script\/rclone_script.sh /d" /opt/retropie/configs/all/runcommand-onend.sh &&
  359. printf "$(date +%FT%T%:z):\t5RUNCOMMAND-ONEND\tDONE\n" >> "${logfile}" &&
  360. updateStep "5b" "done" 64
  361. } || { # catch
  362. printf "$(date +%FT%T%:z):\t5RUNCOMMAND-ONEND\tERROR\n" >> "${logfile}" &&
  363. updateStep "5b" "failed" 56
  364. }
  365. else
  366. printf "$(date +%FT%T%:z):\t5RUNCOMMAND-ONEND\tNOT FOUND\n" >> "${logfile}"
  367. updateStep "5b" "not found" 64
  368. fi
  369. printf "$(date +%FT%T%:z):\t5RUNCOMMAND\tDONE\n" >> "${logfile}"
  370. }
  371. function 6LocalSAVEFILEDirectory ()
  372. {
  373. printf "$(date +%FT%T%:z):\t6LocalSAVEFILEDirectory\tSTART\n" >> "${logfile}"
  374. # 6a. Move savefiles to default
  375. printf "$(date +%FT%T%:z):\t6a moveFilesToDefault\tSTART\n" >> "${logfile}"
  376. updateStep "6a" "in progress" 64
  377. #counter=1
  378. #while [ $counter -le 10000 ]
  379. #do
  380. # echo "." > ~/RetroPie/saves/gba/datei_${counter}.srm
  381. # ((counter++))
  382. #done
  383. if [ -d ~/RetroPie/saves ]
  384. then
  385. # start copy task in background, pipe numbered output into COPY.TXT and to LOGFILE
  386. $(cp -v -r ~/RetroPie/saves/* ~/RetroPie/roms | cat -n | tee copy.txt | cat >> "${logfile}") &
  387. # show content of COPY.TXT
  388. dialog \
  389. --backtitle "${backtitle}" \
  390. --title "Copying savefiles to default..." \
  391. --ascii-lines \
  392. --colors \
  393. --no-collapse \
  394. --cr-wrap \
  395. --tailbox copy.txt 40 120
  396. wait
  397. rm copy.txt
  398. #rm ~/RetroPie/saves/gba/datei*
  399. #rm ~/RetroPie/roms/gba/datei*
  400. updateStep "6a" "done" 72
  401. else
  402. printf "$(date +%FT%T%:z):\t6a moveFilesToDefault\tNOT FOUND\n" >> "${logfile}"
  403. updateStep "6a" "not found" 72
  404. fi
  405. # 6b. Remove local SAVEFILE directory
  406. printf "$(date +%FT%T%:z):\t6b removeLocalSAVEFILEbasedir\tSTART\n" >> "${logfile}"
  407. updateStep "6b" "in progress" 72
  408. if [ -d ~/RetroPie/saves ]
  409. then
  410. # start remove task in background, pipe numbered output into DELETE.TXT and to LOGFILE
  411. $(sudo rm --recursive --force --verbose ~/RetroPie/saves | cat -n | tee delete.txt | cat >> "${logfile}") &
  412. # show content of REMOVE.TXT
  413. dialog \
  414. --backtitle "${backtitle}" \
  415. --title "Removing savefiles from local base dir..." \
  416. --ascii-lines \
  417. --colors \
  418. --no-collapse \
  419. --cr-wrap \
  420. --tailbox delete.txt 40 120
  421. wait
  422. rm delete.txt
  423. printf "$(date +%FT%T%:z):\t6b removeLocalSAVEFILEbasedir\tDONE\n" >> "${logfile}"
  424. updateStep "6b" "done" 80
  425. else
  426. printf "$(date +%FT%T%:z):\t6b removeLocalSAVEFILEbasedir\tNOT FOUND\n" >> "${logfile}"
  427. updateStep "6b" "skipped" 80
  428. fi
  429. printf "$(date +%FT%T%:z):\t6LocalSAVEFILEDirectory\tDONE\n" >> "${logfile}"
  430. }
  431. function 7RetroArch ()
  432. {
  433. printf "$(date +%FT%T%:z):\t7RetroArch\tSTART\n" >> "${logfile}"
  434. # 7a. Reset local SAVEFILE directories
  435. printf "$(date +%FT%T%:z):\t7a resetSAVEFILEdirectories\tSTART\n" >> "${logfile}"
  436. updateStep "7a" "in progress" 80
  437. local found=0
  438. # for each directory...
  439. for directory in /opt/retropie/configs/*
  440. do
  441. system="${directory##*/}"
  442. # skip system "all"
  443. if [ "${system}" == "all" ]
  444. then
  445. continue
  446. fi
  447. # check if there'a system specific RETROARCH.CFG
  448. if [ -f "${directory}/retroarch.cfg" ]
  449. then
  450. printf "$(date +%FT%T%:z):\t7a resetSAVEFILEdirectories\tFOUND retroarch.cfg for ${system}\n" >> "${logfile}"
  451. # check if RETROARCH.CFG contains SAVEFILE pointing to ~/RetroPie/saves/<SYSTEM>
  452. if [[ $(grep -c "^savefile_directory = \"~/RetroPie/saves/${system}\"" ${directory}/retroarch.cfg) -gt 0 ]]
  453. then
  454. printf "$(date +%FT%T%:z):\t7a resetSAVEFILEdirectories\tFOUND savefile_directory\n" >> "${logfile}"
  455. found=$(($found + 1))
  456. # replace parameter
  457. sed -i "/^savefile_directory = \"~\/RetroPie\/saves\/${system}\"/c\savefile_directory = \"default\"" ${directory}/retroarch.cfg
  458. printf "$(date +%FT%T%:z):\t7a resetSAVEFILEdirectories\tREPLACED savefile_directory\n" >> "${logfile}"
  459. else
  460. printf "$(date +%FT%T%:z):\t7a resetSAVEFILEdirectories\tNOT FOUND savefile_directory\n" >> "${logfile}"
  461. fi
  462. # check if RETROARCH.CFG contains SAVESTATE pointing to ~/RetroPie/saves/<SYSTEM>
  463. if [[ $(grep -c "^savestate_directory = \"~/RetroPie/saves/${system}\"" ${directory}/retroarch.cfg) -gt 0 ]]
  464. then
  465. printf "$(date +%FT%T%:z):\t7a resetSAVESTATEdirectories\tFOUND savestate_directory\n" >> "${logfile}"
  466. found=$(($found + 1))
  467. # replace parameter
  468. sed -i "/^savestate_directory = \"~\/RetroPie\/saves\/${system}\"/c\savestate_directory = \"default\"" ${directory}/retroarch.cfg
  469. printf "$(date +%FT%T%:z):\t7a resetSAVESTATEdirectories\tREPLACED savestate_directory\n" >> "${logfile}"
  470. else
  471. printf "$(date +%FT%T%:z):\t7a resetSAVESTATEdirectories\tNOT FOUND savestate_directory\n" >> "${logfile}"
  472. fi
  473. fi
  474. done
  475. printf "$(date +%FT%T%:z):\t7a resetSAVEFILEdirectories\tDINE\n" >> "${logfile}"
  476. if [[ $found -eq 0 ]]
  477. then
  478. updateStep "7a" "not found" 88
  479. else
  480. updateStep "7a" "done" 88
  481. fi
  482. printf "$(date +%FT%T%:z):\t7RetroArch\tDONE\n" >> "${logfile}"
  483. }
  484. function 8Finalize ()
  485. {
  486. printf "$(date +%FT%T%:z):\t8Finalize\tSTART\n" >> "${logfile}"
  487. # 8a. Remove UNINSTALL script
  488. printf "$(date +%FT%T%:z):\t8a removeUNINSTALLscript\tSTART\n" >> "${logfile}"
  489. updateStep "8a" "in progress" 88
  490. printf "$(date +%FT%T%:z):\t8a removeUNINSTALLscript\tDONE\n" >> "${logfile}"
  491. updateStep "8a" "done" 100
  492. printf "$(date +%FT%T%:z):\t8Finalize\tDONE\n" >> "${logfile}"
  493. # move LOGFILE to HOME
  494. mv ~/scripts/rclone_script/rclone_script-uninstall.log ~
  495. # remove RCLONE_SCRIPT directory
  496. rm -rf ~/scripts/rclone_script
  497. }
  498. ########
  499. # MAIN #
  500. ########
  501. uninstaller