rclone_script-install.sh 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158
  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. # global variables
  16. url="https://raw.githubusercontent.com/Jandalf81/rclone_script"
  17. branch="master"
  18. # configuration variables
  19. remotebasedir=""
  20. shownotifications=""
  21. backtitle="RCLONE_SCRIPT installer (https://github.com/Jandalf81/rclone_script)"
  22. logfile=~/scripts/rclone_script/rclone_script-install.log
  23. ##################
  24. # WELCOME DIALOG #
  25. ##################
  26. dialog \
  27. --backtitle "${backtitle}" \
  28. --title "Welcome" \
  29. --colors \
  30. --no-collapse \
  31. --cr-wrap \
  32. --yesno \
  33. "\nThis script will configure RetroPie so that your savefiles and statefiles will be ${YELLOW}synchronized with a remote destination${NORMAL}. Several packages and scripts will be installed, see\n\n https://github.com/Jandalf81/rclone_script/blob/master/ReadMe.md\n\nfor a rundown. In short, any time you ${GREEN}start${NORMAL} or ${RED}stop${NORMAL} a ROM the savefiles and savestates for that ROM will be ${GREEN}down-${NORMAL} and ${RED}uploaded${NORMAL} ${GREEN}from${NORMAL} and ${RED}to${NORMAL} a remote destination. To do so, RetroPie will be configured to put all savefiles and statefiles in distinct directories, seperated from the ROMS directories. This installer will guide you through the necessary steps. If you wish to see what exactly is done at each step, open a second console and execute\n ${YELLOW}tail -f ~/scripts/rclone_script/rclone_script-install.log${NORMAL}\n\nIf you already have some savefiles in the ROMS directory, you will need to ${YELLOW}move them manually${NORMAL} after installation. You can use the new network share\n ${YELLOW}\\\\$(hostname)\\saves${NORMAL}\nfor this.\n\nAre you sure you wish to continue?" \
  34. 26 90 2>&1 > /dev/tty \
  35. || exit
  36. ####################
  37. # DIALOG FUNCTIONS #
  38. ####################
  39. # Warn the user if they are using the BETA branch
  40. function dialogBetaWarning ()
  41. {
  42. dialog \
  43. --backtitle "${backtitle}" \
  44. --title "Beta Warning" \
  45. --colors \
  46. --no-collapse \
  47. --cr-wrap \
  48. --yesno \
  49. "\n${RED}${UNDERLINE}WARNING!${NORMAL}\n\nYou are about to install a beta version!\nAre you ${RED}REALLY${NORMAL} sure you want to continue?" \
  50. 10 50 2>&1 > /dev/tty \
  51. || exit
  52. }
  53. # Build progress from array $STEPS()
  54. # INPUT
  55. # $steps()
  56. # OUTPUT
  57. # $progress
  58. function buildProgress ()
  59. {
  60. progress=""
  61. for ((i=0; i<=${#steps[*]}; i++))
  62. do
  63. progress="${progress}${steps[i]}\n"
  64. done
  65. }
  66. # Show Progress dialog
  67. # INPUT
  68. # 1 > Percentage to show in dialog
  69. # $backtitle
  70. # $progress
  71. function dialogShowProgress ()
  72. {
  73. local percent="$1"
  74. buildProgress
  75. clear
  76. echo "${percent}" | dialog \
  77. --stdout \
  78. --colors \
  79. --no-collapse \
  80. --cr-wrap \
  81. --backtitle "${backtitle}" \
  82. --title "Installer" \
  83. --gauge "${progress}" 36 90 0 \
  84. 2>&1 > /dev/tty
  85. sleep 1
  86. }
  87. # Show summary dialog
  88. function dialogShowSummary ()
  89. {
  90. # list all remotes and their type
  91. remotes=$(rclone listremotes -l)
  92. # get line with RETROPIE remote
  93. retval=$(grep -i "^retropie:" <<< ${remotes})
  94. remoteType="${retval#*:}"
  95. remoteType=$(echo ${remoteType} | xargs)
  96. dialog \
  97. --backtitle "${backtitle}" \
  98. --title "Summary" \
  99. --colors \
  100. --no-collapse \
  101. --cr-wrap \
  102. --yesno \
  103. "\n${GREEN}All done!${NORMAL}\n\nFrom now on, all your saves and states will be synchronized each time you start or stop a ROM.\n\nAll systems will put their saves and states in\n Local: \"${YELLOW}~/RetroPie/saves/<SYSTEM>${NORMAL}\"\n Remote: \"${YELLOW}retropie:${remotebasedir}/<SYSTEM>${NORMAL}\" (${remoteType})\nIf you already have some saves in the ROM directories, you need to move them there manually now! You can use the new network share\n ${YELLOW}\\\\$(hostname)\\saves${NORMAL}\nfor this. Afterward, you should ${red}reboot${NORMAL} your RetroPie. Then, you should start a full sync via\n ${YELLOW}RetroPie / RCLONE_SCRIPT menu / 1 Full sync${NORMAL}\n\nStart\n ${YELLOW}RetroPie / RCLONE_SCRIPT menu / 9 uninstall${NORMAL}\nto revert all changes and remove this script.\n\nTo finish the installer you should reboot your RetroPie now.\n\n${RED}Reboot RetroPie now?${NORMAL}" \
  104. 28 90 2>&1 > /dev/tty
  105. case $? in
  106. 0) sudo shutdown -r now ;;
  107. esac
  108. }
  109. ##################
  110. # STEP FUNCTIONS #
  111. ##################
  112. # Initialize array $STEPS()
  113. # OUTPUT
  114. # $steps()
  115. function initSteps ()
  116. {
  117. steps[1]="1. RCLONE"
  118. steps[2]=" 1a. Test for RCLONE binary [ waiting... ]"
  119. steps[3]=" 1b. Download RCLONE binary [ waiting... ]"
  120. steps[4]=" 1c. Test RCLONE remote [ waiting... ]"
  121. steps[5]=" 1d. Create RCLONE remote [ waiting... ]"
  122. steps[6]="2. PNGVIEW"
  123. steps[7]=" 2a. Test for PNGVIEW binary [ waiting... ]"
  124. steps[8]=" 2b. Download PNGVIEW source [ waiting... ]"
  125. steps[9]=" 2c. Compile PNGVIEW [ waiting... ]"
  126. steps[10]="3. IMAGEMAGICK"
  127. steps[11]=" 3a. Test for IMAGEMAGICK [ waiting... ]"
  128. steps[12]=" 3b. apt-get install IMAGEMAGICK [ waiting... ]"
  129. steps[13]="4. RCLONE_SCRIPT"
  130. steps[14]=" 4a. Download RCLONE_SCRIPT files [ waiting... ]"
  131. steps[15]=" 4b. Create RCLONE_SCRIPT menu item [ waiting... ]"
  132. steps[16]=" 4c. Configure RCLONE_SCRIPT [ waiting... ]"
  133. steps[17]="5. RUNCOMMAND"
  134. steps[18]=" 5a. Add call to RUNCOMMAND-ONSTART [ waiting... ]"
  135. steps[19]=" 5b. Add call to RUNCOMMAND-ONEND [ waiting... ]"
  136. steps[20]="6. Local SAVEFILE directory"
  137. steps[21]=" 6a. Check local base directory [ waiting... ]"
  138. steps[22]=" 6b. Check local <SYSTEM> directories [ waiting... ]"
  139. steps[23]="7. Remote SAVEFILE directory"
  140. steps[24]=" 7a. Check remote base directory [ waiting... ]"
  141. steps[25]=" 7b. Check remote <SYSTEM> directories [ waiting... ]"
  142. steps[26]="8. Configure RETROARCH"
  143. steps[27]=" 8a. Set local SAVEFILE directories [ waiting... ]"
  144. steps[28]="9. Finalizing"
  145. steps[29]=" 9a. Save configuration [ waiting... ]"
  146. }
  147. # Update item of $STEPS() and show updated progress dialog
  148. # INPUT
  149. # 1 > Number of step to update
  150. # 2 > New status for step
  151. # 3 > Percentage to show in progress dialog
  152. # $steps()
  153. # OUTPUT
  154. # $steps()
  155. function updateStep ()
  156. {
  157. local step="$1"
  158. local newStatus="$2"
  159. local percent="$3"
  160. local oldline
  161. local newline
  162. # translate and colorize $NEWSTATUS
  163. case "${newStatus}" in
  164. "waiting") newStatus="[ ${NORMAL}WAITING...${NORMAL} ]" ;;
  165. "in progress") newStatus="[ ${NORMAL}IN PROGRESS${NORMAL} ]" ;;
  166. "done") newStatus="[ ${GREEN}DONE${NORMAL} ]" ;;
  167. "found") newStatus="[ ${GREEN}FOUND${NORMAL} ]" ;;
  168. "not found") newStatus="[ ${RED}NOT FOUND${NORMAL} ]" ;;
  169. "created") newStatus="[ ${GREEN}CREATED${NORMAL} ]" ;;
  170. "failed") newStatus="[ ${RED}FAILED${NORMAL} ]" ;;
  171. "skipped") newStatus="[ ${YELLOW}SKIPPED${NORMAL} ]" ;;
  172. *) newStatus="[ ${RED}UNDEFINED${NORMAL} ]" ;;
  173. esac
  174. # search $STEP in $STEPS
  175. for ((i=0; i<${#steps[*]}; i++))
  176. do
  177. if [[ ${steps[i]} =~ .*$step.* ]]
  178. then
  179. # update $STEP with $NEWSTATUS
  180. oldline="${steps[i]}"
  181. oldline="${oldline%%[*}"
  182. newline="${oldline}${newStatus}"
  183. steps[i]="${newline}"
  184. break
  185. fi
  186. done
  187. # show progress dialog
  188. dialogShowProgress ${percent}
  189. }
  190. #######################
  191. # INSTALLER FUNCTIONS #
  192. #######################
  193. # Installer
  194. function installer ()
  195. {
  196. initSteps
  197. dialogShowProgress 0
  198. 1RCLONE
  199. 2PNGVIEW
  200. 3IMAGEMAGICK
  201. 4RCLONE_SCRIPT
  202. 5RUNCOMMAND
  203. 6LocalSAVEFILEDirectory
  204. 7RemoteSAVEFILEDirectory
  205. 8ConfigureRETROARCH
  206. 9Finalize
  207. dialogShowSummary
  208. }
  209. function 1RCLONE ()
  210. {
  211. # 1a. Testing for RCLONE binary
  212. updateStep "1a" "in progress" 0
  213. 1aTestRCLONE
  214. if [[ $? -eq 0 ]]
  215. then
  216. updateStep "1a" "found" 5
  217. updateStep "1b" "skipped" 10
  218. else
  219. updateStep "1a" "not found" 5
  220. # 1b. Getting RCLONE binary
  221. updateStep "1b" "in progress" 5
  222. 1bInstallRCLONE
  223. if [[ $? -eq 0 ]]
  224. then
  225. updateStep "1b" "done" 10
  226. else
  227. updateStep "1b" "failed" 5
  228. exit
  229. fi
  230. fi
  231. # 1c. Testing RCLONE configuration
  232. updateStep "1c" "in progress" 10
  233. 1cTestRCLONEremote
  234. if [[ $? -eq 0 ]]
  235. then
  236. updateStep "1c" "found" 15
  237. updateStep "1d" "skipped" 20
  238. else
  239. updateStep "1c" "not found" 15
  240. # 1d. Create RCLONE remote
  241. updateStep "1d" "in progress" 15
  242. 1dCreateRCLONEremote
  243. updateStep "1d" "done" 20
  244. fi
  245. }
  246. # Checks if RCLONE is installed
  247. # RETURN
  248. # 0 > RCLONE is installed
  249. # 1 > RCLONE is not installed
  250. function 1aTestRCLONE ()
  251. {
  252. printf "$(date +%FT%T%:z):\t1aTestRCLONE\tSTART\n" >> "${logfile}"
  253. if [ -f /usr/bin/rclone ]
  254. then
  255. printf "$(date +%FT%T%:z):\t1aTestRCLONE\tFOUND\n" >> "${logfile}"
  256. return 0
  257. else
  258. printf "$(date +%FT%T%:z):\t1aTestRCLONE\tNOT FOUND\n" >> "${logfile}"
  259. return 1
  260. fi
  261. }
  262. # Installs RCLONE by download
  263. # RETURN
  264. # 0 > RCLONE has been installed
  265. # 1 > Error while installing RCLONE
  266. function 1bInstallRCLONE ()
  267. {
  268. printf "$(date +%FT%T%:z):\t1bInstallRCLONE\tSTART\n" >> "${logfile}"
  269. # TODO get RCLONE for 64bit
  270. { # try
  271. # get binary
  272. wget -P ~ https://downloads.rclone.org/rclone-current-linux-arm.zip --append-output="${logfile}" &&
  273. unzip ~/rclone-current-linux-arm.zip -d ~ >> "${logfile}" &&
  274. cd ~/rclone-v* &&
  275. # move binary
  276. sudo mv rclone /usr/bin >> "${logfile}" &&
  277. sudo chown root:root /usr/bin/rclone >> "${logfile}" &&
  278. sudo chmod 755 /usr/bin/rclone >> "${logfile}" &&
  279. cd ~ &&
  280. # remove temp files
  281. rm ~/rclone-current-linux-arm.zip >> "${logfile}" &&
  282. rm -r ~/rclone-v* >> "${logfile}" &&
  283. printf "$(date +%FT%T%:z):\t1bInstallRCLONE\tDONE\n" >> "${logfile}" &&
  284. return 0
  285. } || { #catch
  286. printf "$(date +%FT%T%:z):\t1bInstallRCLONE\tERROR\n" >> "${logfile}" &&
  287. # remove temp files
  288. rm ~/rclone-current-linux-arm.zip >> "${logfile}" &&
  289. rm -r ~/rclone-v* >> "${logfile}" &&
  290. return 1
  291. }
  292. }
  293. # Checks if there's a RCLONE remote called RETROPIE
  294. # RETURN
  295. # 0 > remote RETROPIE has been found
  296. # 1 > no remote RETROPIE found
  297. function 1cTestRCLONEremote ()
  298. {
  299. printf "$(date +%FT%T%:z):\t1cTestRCLONEremote\tSTART\n" >> "${logfile}"
  300. local remotes=$(rclone listremotes)
  301. local retval=$(grep -i "^retropie:" <<< ${remotes})
  302. if [ "${retval}" == "retropie:" ]
  303. then
  304. printf "$(date +%FT%T%:z):\t1cTestRCLONEremote\tFOUND\n" >> "${logfile}"
  305. return 0
  306. else
  307. printf "$(date +%FT%T%:z):\t1cTestRCLONEremote\tNOT FOUND\n" >> "${logfile}"
  308. return 1
  309. fi
  310. }
  311. # Tells the user to create a new RCLONE remote called RETROPIE
  312. # RETURN
  313. # 0 > remote RETROPIE has been created (no other OUTPUT possible)
  314. function 1dCreateRCLONEremote ()
  315. {
  316. printf "$(date +%FT%T%:z):\t1dCreateRCLONEremote\tSTART\n" >> "${logfile}"
  317. dialog \
  318. --stdout \
  319. --colors \
  320. --no-collapse \
  321. --cr-wrap \
  322. --backtitle "${backtitle}" \
  323. --title "Installer" \
  324. --msgbox "\nPlease create a new remote within RCLONE now. Name that remote ${RED}retropie${NORMAL}. Please consult the RCLONE documentation for further information:\n https://www.rclone.org\n\nOpening RCLONE CONFIG now..." 20 50 \
  325. 2>&1 > /dev/tty
  326. clear
  327. rclone config
  328. 1cTestRCLONEremote
  329. if [[ $? -eq 1 ]]
  330. then
  331. dialog \
  332. --stdout \
  333. --colors \
  334. --no-collapse \
  335. --cr-wrap \
  336. --backtitle "${backtitle}" \
  337. --title "Installer" \
  338. --msgbox "\nNo remote ${RED}retropie${NORMAL} found.\nPlease try again." 20 50 \
  339. 2>&1 > /dev/tty
  340. 1dCreateRCLONEremote
  341. else
  342. printf "$(date +%FT%T%:z):\t1dCreateRCLONEremote\tFOUND\n" >> "${logfile}"
  343. return 0
  344. fi
  345. }
  346. function 2PNGVIEW ()
  347. {
  348. # 2a. Testing for PNGVIEW binary
  349. updateStep "2a" "in progress" 20
  350. 2aTestPNGVIEW
  351. if [[ $? -eq 0 ]]
  352. then
  353. updateStep "2a" "found" 25
  354. updateStep "2b" "skipped" 30
  355. updateStep "2c" "skipped" 35
  356. else
  357. updateStep "2a" "not found" 25
  358. # 2b. Getting PNGVIEW source
  359. updateStep "2b" "in progress" 25
  360. 2bGetPNGVIEWsource
  361. if [[ $? -eq 0 ]]
  362. then
  363. updateStep "2b" "done" 30
  364. # 2c. Compiling PNGVIEW
  365. updateStep "2c" "in progress" 30
  366. 2cCompilePNGVIEW
  367. if [[ $? -eq 0 ]]
  368. then
  369. updateStep "2c" "done" 35
  370. else
  371. updateStep "2c" "failed" 30
  372. exit
  373. fi
  374. else
  375. updateStep "2b" "failed" 25
  376. exit
  377. fi
  378. fi
  379. }
  380. # Checks if PNGVIEW is installed
  381. # RETURN
  382. # 0 > PNGVIEW is installed
  383. # 1 > PNGVIEW is not installed
  384. function 2aTestPNGVIEW ()
  385. {
  386. printf "$(date +%FT%T%:z):\t2aTestPNGVIEW\tSTART\n" >> "${logfile}"
  387. if [ -f /usr/bin/pngview ]
  388. then
  389. printf "$(date +%FT%T%:z):\t2aTestPNGVIEW\tFOUND\n" >> "${logfile}"
  390. return 0
  391. else
  392. printf "$(date +%FT%T%:z):\t2aTestPNGVIEW\tNOT FOUND\n" >> "${logfile}"
  393. return 1
  394. fi
  395. }
  396. # Gets PNGVIEW source
  397. # RETURN
  398. # 0 > source downloaded and unzipped
  399. # 1 > no source downloaded, removed temp files
  400. function 2bGetPNGVIEWsource ()
  401. {
  402. printf "$(date +%FT%T%:z):\t2bGetPNGVIEWsource\tSTART\n" >> "${logfile}"
  403. { #try
  404. wget -P ~ https://github.com/AndrewFromMelbourne/raspidmx/archive/master.zip --append-output="${logfile}" &&
  405. unzip ~/master.zip -d ~ >> "${logfile}" &&
  406. printf "$(date +%FT%T%:z):\t2bGetPNGVIEWsource\tDONE\n" >> "${logfile}" &&
  407. return 0
  408. } || { #catch
  409. printf "$(date +%FT%T%:z):\t2bGetPNGVIEWsource\tERROR\n" >> "${logfile}" &&
  410. rm ~/master.zip >> "${logfile}" &&
  411. sudo rm -r ~/raspidmx-master >> "${logfile}" &&
  412. return 1
  413. }
  414. }
  415. # Compiles PNGVIEW source, moves binaries
  416. # RETURN
  417. # 0 > compiled without errors, moved binaries, removed temp files
  418. # 1 > errors while compiling, removed temp files
  419. function 2cCompilePNGVIEW ()
  420. {
  421. printf "$(date +%FT%T%:z):\t2cCompilePNGVIEW\tSTART\n" >> "${logfile}"
  422. { #try
  423. # compile
  424. # cd ~/raspidmx-master &&
  425. make --directory=~/raspidmx-master >> "${logfile}" &&
  426. # move binary files
  427. sudo mv ~/raspidmx-master/pngview/pngview /usr/bin >> "${logfile}" &&
  428. sudo mv ~/raspidmx-master/lib/libraspidmx.so.1 /usr/lib >> "${logfile}" &&
  429. sudo chown root:root /usr/bin/pngview >> "${logfile}" &&
  430. sudo chmod 755 /usr/bin/pngview >> "${logfile}" &&
  431. # remove temp files
  432. rm ~/master.zip >> "${logfile}" &&
  433. sudo rm -r ~/raspidmx-master >> "${logfile}" &&
  434. printf "$(date +%FT%T%:z):\t2cCompilePNGVIEW\tDONE\n" >> "${logfile}" &&
  435. return 0
  436. } || { #catch
  437. printf "$(date +%FT%T%:z):\t2cCompilePNGVIEW\tERROR\n" >> "${logfile}" &&
  438. # remove temp files
  439. rm ~/master.zip >> "${logfile}" &&
  440. sudo rm -r ~/raspidmx-master >> "${logfile}" &&
  441. return 1
  442. }
  443. }
  444. function 3IMAGEMAGICK ()
  445. {
  446. # 3a. Testing for IMAGEMAGICK
  447. updateStep "3a" "in progress" 35
  448. 3aTestIMAGEMAGICK
  449. if [[ $? -eq 0 ]]
  450. then
  451. updateStep "3a" "found" 40
  452. updateStep "3b" "skipped" 45
  453. else
  454. updateStep "3a" "not found" 40
  455. # 3b. Getting IMAGEMAGICK
  456. updateStep "3b" "in progress" 40
  457. 3bInstallIMAGEMAGICK
  458. if [[ $? -eq 0 ]]
  459. then
  460. updateStep "3b" "done" 45
  461. else
  462. updateStep "3b" "failed" 40
  463. fi
  464. fi
  465. }
  466. # Checks is IMAGEMAGICK is installed
  467. # RETURN
  468. # 0 > IMAGEMAGICK is installed
  469. # 1 > IMAGEMAGICK is not installed
  470. function 3aTestIMAGEMAGICK ()
  471. {
  472. printf "$(date +%FT%T%:z):\t3aTestIMAGEMAGICK\tSTART\n" >> "${logfile}"
  473. if [ -f /usr/bin/convert ]
  474. then
  475. printf "$(date +%FT%T%:z):\t3aTestIMAGEMAGICK\tFOUND\n" >> "${logfile}"
  476. return 0
  477. else
  478. printf "$(date +%FT%T%:z):\t3aTestIMAGEMAGICK\tNOT FOUND\n" >> "${logfile}"
  479. return 1
  480. fi
  481. }
  482. # Installs IMAGEMAGICK via APT-GET
  483. # RETURN
  484. # 0 > IMAGEMAGICK has been installed
  485. # 1 > Error while installing IMAGEMAGICK
  486. function 3bInstallIMAGEMAGICK ()
  487. {
  488. printf "$(date +%FT%T%:z):\t3bInstallIMAGEMAGICK\tSTART\n" >> "${logfile}"
  489. sudo apt-get update >> "${logfile}"
  490. sudo apt-get --yes install imagemagick >> "${logfile}"
  491. if [[ $? -eq 0 ]]
  492. then
  493. printf "$(date +%FT%T%:z):\t3bInstallIMAGEMAGICK\tDONE\n" >> "${logfile}"
  494. return 0
  495. else
  496. printf "$(date +%FT%T%:z):\t3bInstallIMAGEMAGICK\tERROR\n" >> "${logfile}"
  497. return 1
  498. fi
  499. }
  500. function 4RCLONE_SCRIPT ()
  501. {
  502. # 4a. Getting RCLONE_SCRIPT
  503. updateStep "4a" "in progress" 45
  504. 4aGetRCLONE_SCRIPT
  505. if [[ $? -eq 0 ]]
  506. then
  507. updateStep "4a" "done" 50
  508. else
  509. updateStep "4a" "failed" 45
  510. exit
  511. fi
  512. # 4b. Creating RCLONE_SCRIPT menu item
  513. updateStep "4b" "in progress" 50
  514. 4bCreateRCLONE_SCRIPTMenuItem
  515. if [[ $? -eq 0 ]]
  516. then
  517. updateStep "4b" "done" 55
  518. else
  519. updateStep "4b" "failed" 50
  520. exit
  521. fi
  522. # 4c. Configure RCLONE_SCRIPT
  523. updateStep "4c" "in progress" 55
  524. 4cConfigureRCLONE_SCRIPT
  525. updateStep "4c" "done" 60
  526. }
  527. # Gets RCLONE_SCRIPT
  528. # RETURN
  529. # 0 > downloaded successfully
  530. # 1 > errors while downloading
  531. function 4aGetRCLONE_SCRIPT ()
  532. {
  533. printf "$(date +%FT%T%:z):\t4aGetRCLONE_SCRIPT\tSTART\n" >> "${logfile}"
  534. # create directory if necessary
  535. if [ ! -d ~/scripts/rclone_script ]
  536. then
  537. mkdir ~/scripts/rclone_script >> "${logfile}"
  538. fi
  539. { #try
  540. # get script files
  541. wget -N -P ~/scripts/rclone_script ${url}/${branch}/rclone_script.sh --append-output="${logfile}" &&
  542. wget -N -P ~/scripts/rclone_script ${url}/${branch}/rclone_script-menu.sh --append-output="${logfile}" &&
  543. wget -N -P ~/scripts/rclone_script ${url}/${branch}/rclone_script-uninstall.sh --append-output="${logfile}" &&
  544. # change mod
  545. chmod +x ~/scripts/rclone_script/rclone_script.sh >> "${logfile}" &&
  546. chmod +x ~/scripts/rclone_script/rclone_script-menu.sh >> "${logfile}" &&
  547. chmod +x ~/scripts/rclone_script/rclone_script-uninstall.sh >> "${logfile}" &&
  548. printf "$(date +%FT%T%:z):\t4aGetRCLONE_SCRIPT\tDONE\n" >> "${logfile}" &&
  549. return 0
  550. } || { # catch
  551. printf "$(date +%FT%T%:z):\t4aGetRCLONE_SCRIPT\tERROR\n" >> "${logfile}" &&
  552. return 1
  553. }
  554. }
  555. # Creates a menu item for RCLONE_SCRIPT in RetroPie menu
  556. # RETURN
  557. # 0 > menu item has been found or created
  558. # 1 > error while creating menu item
  559. function 4bCreateRCLONE_SCRIPTMenuItem ()
  560. {
  561. printf "$(date +%FT%T%:z):\t4bCreateRCLONE_SCRIPTMenuItem\tSTART\n" >> "${logfile}"
  562. # create redirect script
  563. printf "#!/bin/bash\n~/scripts/rclone_script/rclone_script-menu.sh" > ~/RetroPie/retropiemenu/rclone_script-redirect.sh
  564. chmod +x ~/RetroPie/retropiemenu/rclone_script-redirect.sh
  565. # check if menu item exists
  566. if [[ $(xmlstarlet sel -t -v "count(/gameList/game[path='./rclone_script-redirect.sh'])" ~/.emulationstation/gamelists/retropie/gamelist.xml) -eq 0 ]]
  567. then
  568. printf "$(date +%FT%T%:z):\t4bCreateRCLONE_SCRIPTMenuItem\tNOT FOUND\n" >> "${logfile}"
  569. xmlstarlet ed \
  570. --inplace \
  571. --subnode "/gameList" --type elem -n game -v "" \
  572. --subnode "/gameList/game[last()]" --type elem -n path -v "./rclone_script-redirect.sh" \
  573. --subnode "/gameList/game[last()]" --type elem -n name -v "RCLONE_SCRIPT menu" \
  574. --subnode "/gameList/game[last()]" --type elem -n desc -v "Launches a menu allowing you to start a full sync, configure RCLONE_SCRIPT or even uninstall it" \
  575. ~/.emulationstation/gamelists/retropie/gamelist.xml
  576. if [[ $? -eq 0 ]]
  577. then
  578. printf "$(date +%FT%T%:z):\t4bCreateRCLONE_SCRIPTMenuItem\tCREATED\n" >> "${logfile}"
  579. return 0
  580. else
  581. printf "$(date +%FT%T%:z):\t4bCreateRCLONE_SCRIPTMenuItem\tERROR\n" >> "${logfile}"
  582. return 1
  583. fi
  584. else
  585. printf "$(date +%FT%T%:z):\t4bCreateRCLONE_SCRIPTMenuItem\tFOUND\n" >> "${logfile}"
  586. return 0
  587. fi
  588. }
  589. # Gets user input to configure RCLONE_SCRIPT
  590. function 4cConfigureRCLONE_SCRIPT ()
  591. {
  592. printf "$(date +%FT%T%:z):\t4cConfigureRCLONE_SCRIPT\tSTART\n" >> "${logfile}"
  593. remotebasedir=$(dialog \
  594. --stdout \
  595. --colors \
  596. --no-collapse \
  597. --cr-wrap \
  598. --backtitle "${backtitle}" \
  599. --title "Remote base directory" \
  600. --inputbox "\nPlease name the directory which will be used as your ${YELLOW}remote base directory${NORMAL}. If necessary, this directory will be created.\n\nExamples:\n* RetroArch\n* mySaves/RetroArch\n\n" 18 40 "RetroArch"
  601. )
  602. dialog \
  603. --stdout \
  604. --colors \
  605. --no-collapse \
  606. --cr-wrap \
  607. --backtitle "${backtitle}" \
  608. --title "Notifications" \
  609. --yesno "\nDo you wish to see ${YELLOW}notifications${NORMAL} whenever RCLONE_SCRIPT is synchronizing?" 18 40
  610. case $? in
  611. 0) shownotifications="TRUE" ;;
  612. 1) shownotifications="FALSE" ;;
  613. *) shownotifications="FALSE" ;;
  614. esac
  615. printf "$(date +%FT%T%:z):\t4cConfigureRCLONE_SCRIPT\tDONE\n" >> "${logfile}"
  616. }
  617. function 5RUNCOMMAND ()
  618. {
  619. # 5a. RUNCOMMAND-ONSTART
  620. updateStep "5a" "in progress" 60
  621. 5aRUNCOMMAND-ONSTART
  622. case $? in
  623. 0) updateStep "5a" "found" 65 ;;
  624. 1) updateStep "5a" "created" 65 ;;
  625. esac
  626. # 5b. RUNCOMMAND-ONEND
  627. updateStep "5b" "in progress" 65
  628. 5aRUNCOMMAND-ONEND
  629. case $? in
  630. 0) updateStep "5b" "found" 70 ;;
  631. 1) updateStep "5b" "created" 70 ;;
  632. esac
  633. }
  634. # Checks call of RCLONE_SCRIPT by RUNCOMMAND-ONSTART
  635. # RETURNS
  636. # 0 > call found
  637. # 1 > call created
  638. function 5aRUNCOMMAND-ONSTART ()
  639. {
  640. printf "$(date +%FT%T%:z):\t5aRUNCOMMAND-ONSTART\tSTART\n" >> "${logfile}"
  641. # check if RUNCOMMAND-ONSTART.sh exists
  642. if [ -f /opt/retropie/configs/all/runcommand-onstart.sh ]
  643. then
  644. printf "$(date +%FT%T%:z):\t5aRUNCOMMAND-ONSTART\tFILE FOUND\n" >> "${logfile}"
  645. # check if there's a call to RCLONE_SCRIPT
  646. if grep -Fq "~/scripts/rclone_script/rclone_script.sh" /opt/retropie/configs/all/runcommand-onstart.sh
  647. then
  648. printf "$(date +%FT%T%:z):\t5aRUNCOMMAND-ONSTART\tCALL FOUND\n" >> "${logfile}"
  649. return 0
  650. else
  651. printf "$(date +%FT%T%:z):\t5aRUNCOMMAND-ONSTART\tCALL NOT FOUND\n" >> "${logfile}"
  652. # add call
  653. echo "~/scripts/rclone_script/rclone_script.sh \"down\" \"\$1\" \"\$2\" \"\$3\" \"\$4\"" >> /opt/retropie/configs/all/runcommand-onstart.sh
  654. printf "$(date +%FT%T%:z):\t5aRUNCOMMAND-ONSTART\tCALL CREATED\n" >> "${logfile}"
  655. return 1
  656. fi
  657. else
  658. printf "$(date +%FT%T%:z):\t5aRUNCOMMAND-ONSTART\tFILE NOT FOUND\n" >> "${logfile}"
  659. echo "#!/bin/bash" > /opt/retropie/configs/all/runcommand-onstart.sh
  660. echo "~/scripts/rclone_script/rclone_script.sh \"down\" \"\$1\" \"\$2\" \"\$3\" \"\$4\"" >> /opt/retropie/configs/all/runcommand-onstart.sh
  661. printf "$(date +%FT%T%:z):\t5aRUNCOMMAND-ONSTART\tFILE CREATED\n" >> "${logfile}"
  662. return 1
  663. fi
  664. }
  665. # Checks call of RCLONE_SCRIPT by RUNCOMMAND-ONEND
  666. # RETURNS
  667. # 0 > call found
  668. # 1 > call created
  669. function 5aRUNCOMMAND-ONEND ()
  670. {
  671. printf "$(date +%FT%T%:z):\t5aRUNCOMMAND-ONEND\tSTART\n" >> "${logfile}"
  672. # check if RUNCOMMAND-ONEND.sh exists
  673. if [ -f /opt/retropie/configs/all/runcommand-onend.sh ]
  674. then
  675. printf "$(date +%FT%T%:z):\t5aRUNCOMMAND-ONEND\tFILE FOUND\n" >> "${logfile}"
  676. # check if there's a call to RCLONE_SCRIPT
  677. if grep -Fq "~/scripts/rclone_script/rclone_script.sh" /opt/retropie/configs/all/runcommand-onend.sh
  678. then
  679. printf "$(date +%FT%T%:z):\t5aRUNCOMMAND-ONEND\tCALL FOUND\n" >> "${logfile}"
  680. return 0
  681. else
  682. printf "$(date +%FT%T%:z):\t5aRUNCOMMAND-ONEND\tCALL NOT FOUND\n" >> "${logfile}"
  683. # add call
  684. echo "~/scripts/rclone_script/rclone_script.sh \"up\" \"\$1\" \"\$2\" \"\$3\" \"\$4\"" >> /opt/retropie/configs/all/runcommand-onend.sh
  685. printf "$(date +%FT%T%:z):\t5aRUNCOMMAND-ONEND\tCALL CREATED\n" >> "${logfile}"
  686. return 1
  687. fi
  688. else
  689. printf "$(date +%FT%T%:z):\t5aRUNCOMMAND-ONEND\tFILE NOT FOUND\n" >> "${logfile}"
  690. echo "#!/bin/bash" > /opt/retropie/configs/all/runcommand-onend.sh
  691. echo "~/scripts/rclone_script/rclone_script.sh \"up\" \"\$1\" \"\$2\" \"\$3\" \"\$4\"" >> /opt/retropie/configs/all/runcommand-onend.sh
  692. printf "$(date +%FT%T%:z):\t5aRUNCOMMAND-ONEND\tFILE CREATED\n" >> "${logfile}"
  693. return 1
  694. fi
  695. }
  696. function 6LocalSAVEFILEDirectory ()
  697. {
  698. # 6a. Test for local SAVEFILE directory
  699. updateStep "6a" "in progress" 70
  700. 6aCheckLocalBaseDirectory
  701. case $? in
  702. 0) updateStep "6a" "found" 75 ;;
  703. 1) updateStep "6a" "created" 75 ;;
  704. esac
  705. # 6b. Check local <SYSTEM> directories
  706. updateStep "6b" "in progress" 75
  707. 6bCheckLocalSystemDirectories
  708. case $? in
  709. 0) updateStep "6b" "found" 80 ;;
  710. 1) updateStep "6b" "created" 80 ;;
  711. esac
  712. }
  713. # Checks if the local base SAVEFILE directory exists
  714. # RETURN
  715. # 0 > directory exists
  716. # 1 > directory has been created
  717. function 6aCheckLocalBaseDirectory ()
  718. {
  719. printf "$(date +%FT%T%:z):\t6aCheckLocalBaseDirectory\tSTART\n" >> "${logfile}"
  720. # check if local base dir exists
  721. if [ -d ~/RetroPie/saves ]
  722. then
  723. printf "$(date +%FT%T%:z):\t6aCheckLocalBaseDirectory\tFOUND\n" >> "${logfile}"
  724. return 0
  725. else
  726. printf "$(date +%FT%T%:z):\t6aCheckLocalBaseDirectory\tNOT FOUND\n" >> "${logfile}"
  727. mkdir ~/RetroPie/saves
  728. printf "$(date +%FT%T%:z):\t6aCheckLocalBaseDirectory\tCREATED directory\n" >> "${logfile}"
  729. # share that new directory on the network
  730. if [[ $(grep -c "\[saves\]" /etc/samba/smb.conf) -eq 0 ]]
  731. then
  732. # add new share to SAMBA
  733. printf "[saves]\ncomment = saves\npath = \"/home/pi/RetroPie/saves\"\nwritable = yes\nguest ok = yes\ncreate mask = 0644\ndirectory mask = 0755\nforce user = pi\n" | sudo tee --append /etc/samba/smb.conf | cat > /dev/null
  734. # restart SAMBA
  735. sudo service smbd restart
  736. printf "$(date +%FT%T%:z):\t6aCheckLocalBaseDirectory\tCREATED network share\n" >> "${logfile}"
  737. fi
  738. return 1
  739. fi
  740. }
  741. # Checks if the local system specific directories exists
  742. # RETURN
  743. # 0 > all found
  744. # 1 > created at least one
  745. function 6bCheckLocalSystemDirectories ()
  746. {
  747. printf "$(date +%FT%T%:z):\t6bCheckLocalSystemDirectories\tSTART\n" >> "${logfile}"
  748. local retval=0
  749. # for each directory in ROMS directory...
  750. for directory in ~/RetroPie/roms/*
  751. do
  752. system="${directory##*/}"
  753. # check if ROMS directory is a real directory and not a SymLink
  754. if [ ! -L ~/RetroPie/roms/${system} ]
  755. then
  756. # check if same directory exists in SAVES, create if necessary
  757. if [ -d ~/RetroPie/saves/${system} ]
  758. then
  759. printf "$(date +%FT%T%:z):\t6bCheckLocalSystemDirectories\tFOUND directory ${system}\n" >> "${logfile}"
  760. else
  761. mkdir ~/RetroPie/saves/${system}
  762. printf "$(date +%FT%T%:z):\t6bCheckLocalSystemDirectories\tCREATED directory ${system}\n" >> "${logfile}"
  763. retval=1
  764. fi
  765. else
  766. # check if same SymLink exists in SAVES, create if necessary
  767. if [ -L ~/RetroPie/saves/${system} ]
  768. then
  769. printf "$(date +%FT%T%:z):\t6bCheckLocalSystemDirectories\tFOUND symlink ${system}\n" >> "${logfile}"
  770. else
  771. ln -s $(readlink ~/RetroPie/roms/${system}) ~/RetroPie/saves/${system}
  772. printf "$(date +%FT%T%:z):\t6bCheckLocalSystemDirectories\tCREATED symlink ${system}\n" >> "${logfile}"
  773. retval=1
  774. fi
  775. fi
  776. done
  777. return ${retval}
  778. }
  779. function 7RemoteSAVEFILEDirectory ()
  780. {
  781. # 7a. Check remote base directory
  782. updateStep "7a" "in progress" 80
  783. 7aCheckRemoteBaseDirectory
  784. case $? in
  785. 0) updateStep "7a" "found" 85 ;;
  786. 1) updateStep "7a" "created" 85 ;;
  787. 255) updateStep "7a" "failed" 80 ;;
  788. esac
  789. # 7b. Check remote <system> directories
  790. updateStep "7b" "in progress" 85
  791. 7bCheckRemoteSystemDirectories
  792. case $? in
  793. 0) updateStep "7b" "found" 90 ;;
  794. 1) updateStep "7b" "created" 90 ;;
  795. 255) updateStep "7b" "failed" 85 ;;
  796. esac
  797. }
  798. # Checks if the remote base SAVEFILE directory exists
  799. # RETURN
  800. # 0 > directory exists
  801. # 1 > directory has been created
  802. # 255 > error while creating directory
  803. function 7aCheckRemoteBaseDirectory ()
  804. {
  805. printf "$(date +%FT%T%:z):\t7aCheckRemoteBaseDirectory\tSTART\n" >> "${logfile}"
  806. # list all directories from remote
  807. remoteDirs=$(rclone lsf --dirs-only -R retropie:)
  808. # for each line...
  809. while read path
  810. do
  811. if [ "${path}" == "${remotebasedir}/" ]
  812. then
  813. printf "$(date +%FT%T%:z):\t7aCheckRemoteBaseDirectory\tFOUND\n" >> "${logfile}"
  814. return 0
  815. fi
  816. done <<< "${remoteDirs}"
  817. # if there has been no match...
  818. printf "$(date +%FT%T%:z):\t7aCheckRemoteBaseDirectory\tNOT FOUND\n" >> "${logfile}"
  819. rclone mkdir retropie:"${remotebasedir}" >> "${logfile}"
  820. case $? in
  821. 0) printf "$(date +%FT%T%:z):\t7aCheckRemoteBaseDirectory\tCREATED\n" >> "${logfile}"; return 1 ;;
  822. *) printf "$(date +%FT%T%:z):\t7aCheckRemoteBaseDirectory\tERROR\n" >> "${logfile}"; return 255 ;;
  823. esac
  824. }
  825. # Checks if the remote system specific directories exist
  826. # RETURN
  827. # 0 > all found
  828. # 1 > created at least one
  829. # 255 > error while creating directory
  830. function 7bCheckRemoteSystemDirectories ()
  831. {
  832. printf "$(date +%FT%T%:z):\t7bCheckRemoteSystemDirectories\tSTART\n" >> "${logfile}"
  833. local retval=0
  834. local output
  835. # list all directories in $REMOTEBASEDIR from remote
  836. remoteDirs=$(rclone lsf --dirs-only -R retropie:"${remotebasedir}")
  837. # for each directory in ROMS directory...
  838. for directory in ~/RetroPie/roms/*
  839. do
  840. system="${directory##*/}"
  841. # use grep to search $SYSTEM in $DIRECTORIES
  842. output=$(grep "${system}/" -nx <<< "${remoteDirs}")
  843. if [ "${output}" = "" ]
  844. then
  845. # create system dir
  846. rclone mkdir retropie:"${remotebasedir}/${system}"
  847. if [[ $? -eq 0 ]]
  848. then
  849. printf "$(date +%FT%T%:z):\t7bCheckRemoteSystemDirectories\tCREATED ${system}\n" >> "${logfile}"
  850. # put note if local directory is a symlink
  851. if [ -L ~/RetroPie/saves/${system} ]
  852. then
  853. printf "ATTENTION\r\n\r\nThis directory will not be used! This is just a symlink.\r\nPlace your savefiles in\r\n\r\n$(readlink ~/RetroPie/roms/${system})\r\n\r\ninstead." > ~/scripts/rclone_script/readme.txt
  854. rclone copy ~/scripts/rclone_script/readme.txt retropie:"${remotebasedir}/${system}/"
  855. rm ~/scripts/rclone_script/readme.txt
  856. fi
  857. retval=1
  858. else
  859. printf "$(date +%FT%T%:z):\t7bCheckRemoteSystemDirectories\tERROR\n" >> "${logfile}"
  860. return 255
  861. fi
  862. else
  863. printf "$(date +%FT%T%:z):\t7bCheckRemoteSystemDirectories\tFOUND ${system}\n" >> "${logfile}"
  864. fi
  865. done
  866. return ${retval}
  867. }
  868. function 8ConfigureRETROARCH ()
  869. {
  870. # 8a. Setting local SAVEFILE directory
  871. updateStep "8a" "in progress" 90
  872. 8aSetLocalSAVEFILEDirectory
  873. updateStep "8a" "done" 95
  874. }
  875. # Sets parameters in all system specific configuration files
  876. function 8aSetLocalSAVEFILEDirectory ()
  877. {
  878. printf "$(date +%FT%T%:z):\t8aSetLocalSAVEFILEDirectory\tSTART\n" >> "${logfile}"
  879. local retval
  880. # for each directory...
  881. for directory in /opt/retropie/configs/*
  882. do
  883. system="${directory##*/}"
  884. # skip directory ALL
  885. if [ "${system}" = "all" ]
  886. then
  887. continue
  888. fi
  889. # test if there's a RETROARCH.CFG
  890. if [ -f "${directory}/retroarch.cfg" ]
  891. then
  892. printf "$(date +%FT%T%:z):\t8aSetLocalSAVEFILEDirectory\tFOUND retroarch.cfg FOR ${system}\n" >> "${logfile}"
  893. # test file for SAVEFILE_DIRECTORY
  894. retval=$(grep -i "^savefile_directory = " ${directory}/retroarch.cfg)
  895. if [ ! "${retval}" = "" ]
  896. then
  897. printf "$(date +%FT%T%:z):\t8aSetLocalSAVEFILEDirectory\tREPLACED savefile_directory\n" >> "${logfile}"
  898. # replace existing parameter
  899. sed -i "/^savefile_directory = /c\savefile_directory = \"~/RetroPie/saves/${system}\"" ${directory}/retroarch.cfg
  900. else
  901. printf "$(date +%FT%T%:z):\t8aSetLocalSAVEFILEDirectory\tADDED savefile_directory\n" >> "${logfile}"
  902. # create new parameter above "#include..."
  903. sed -i "/^#include \"\/opt\/retropie\/configs\/all\/retroarch.cfg\"/c\savefile_directory = \"~\/RetroPie\/saves\/${system}\"\n#include \"\/opt\/retropie\/configs\/all\/retroarch.cfg\"" ${directory}/retroarch.cfg
  904. fi
  905. # test file for SAVESTATE_DIRECTORY
  906. retval=$(grep -i "^savestate_directory = " ${directory}/retroarch.cfg)
  907. if [ ! "${retval}" = "" ]
  908. then
  909. printf "$(date +%FT%T%:z):\t8aSetLocalSAVEFILEDirectory\tREPLACED savestate_directory\n" >> "${logfile}"
  910. # replace existing parameter
  911. sed -i "/^savestate_directory = /c\savestate_directory = \"~/RetroPie/saves/${system}\"" ${directory}/retroarch.cfg
  912. else
  913. printf "$(date +%FT%T%:z):\t8aSetLocalSAVEFILEDirectory\tADDED savestate_directory\n" >> "${logfile}"
  914. # create new parameter above "#include..."
  915. sed -i "/^#include \"\/opt\/retropie\/configs\/all\/retroarch.cfg\"/c\savestate_directory = \"~\/RetroPie\/saves\/${system}\"\n#include \"\/opt\/retropie\/configs\/all\/retroarch.cfg\"" ${directory}/retroarch.cfg
  916. fi
  917. fi
  918. done
  919. printf "$(date +%FT%T%:z):\t8aSetLocalSAVEFILEDirectory\tDONE\n" >> "${logfile}"
  920. }
  921. function 9Finalize ()
  922. {
  923. # 9a. Saving configuration
  924. updateStep "9a" "in progress" 95
  925. 9aSaveConfiguration
  926. updateStep "9a" "done" 100
  927. }
  928. # Saves the configuration of RCLONE_SCRIPT
  929. function 9aSaveConfiguration ()
  930. {
  931. printf "$(date +%FT%T%:z):\t9aSaveConfiguration\tSTART\n" >> "${logfile}"
  932. echo "remotebasedir=${remotebasedir}" > ~/scripts/rclone_script/rclone_script.ini
  933. echo "showNotifications=${shownotifications}" >> ~/scripts/rclone_script/rclone_script.ini
  934. echo "syncOnStartStop=\"TRUE\"" >> ~/scripts/rclone_script/rclone_script.ini
  935. echo "logfile=~/scripts/rclone_script/rclone_script.log" >> ~/scripts/rclone_script/rclone_script.ini
  936. echo "debug=0" >> ~/scripts/rclone_script/rclone_script.ini
  937. printf "$(date +%FT%T%:z):\t9aSaveConfiguration\tDONE\n" >> "${logfile}"
  938. }
  939. ########
  940. # MAIN #
  941. ########
  942. if [ "${branch}" == "beta" ]
  943. then
  944. dialogBetaWarning
  945. fi
  946. installer