rclone_script-uninstall.sh 17 KB

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