rclone_script-install-dialog.sh

* Added note to reboot to summary
rclone_script-uninstall-dialog.sh
* Finished the script
This commit is contained in:
Jandalf81
2018-08-14 12:24:16 +02:00
parent 74915b1a7d
commit 5f29977ba0
2 changed files with 183 additions and 27 deletions

View File

@@ -127,7 +127,7 @@ function dialogShowSummary ()
--no-collapse \ --no-collapse \
--cr-wrap \ --cr-wrap \
--yesno \ --yesno \
"\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 system 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! 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\n${RED}Reboot RetroPie now?${NORMAL}" 25 90 "\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 system 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! 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}" 25 90
case $? in case $? in
0) sudo shutdown -r now ;; 0) sudo shutdown -r now ;;

View File

@@ -19,6 +19,9 @@ UNDERLINE="\Zu"
backtitle="RCLONE_SCRIPT uninstaller" backtitle="RCLONE_SCRIPT uninstaller"
logfile=~/scripts/rclone_script/rclone_script-uninstall.log logfile=~/scripts/rclone_script/rclone_script-uninstall.log
source ~/scripts/rclone_script/rclone_script.ini
oldRemote=""
################## ##################
# WELCOME DIALOG # # WELCOME DIALOG #
@@ -111,12 +114,10 @@ function initSteps ()
steps[14]="6. Local SAVEFILE directory" steps[14]="6. Local SAVEFILE directory"
steps[15]=" 6a. Move savefiles to default [ waiting... ]" steps[15]=" 6a. Move savefiles to default [ waiting... ]"
steps[16]=" 6b. Remove local SAVEFILE directory [ waiting... ]" steps[16]=" 6b. Remove local SAVEFILE directory [ waiting... ]"
steps[17]="7. Remote SAVEFILE directory" steps[17]="7. Configure RETROARCH"
steps[18]=" 7a. Remove remote SAVEFILE directory [ waiting... ]" steps[18]=" 7a. Reset local SAVEFILE directories [ waiting... ]"
steps[19]="8. Configure RETROARCH" steps[19]="8 Finalizing"
steps[20]=" 8a. Reset local SAVEFILE directories [ waiting... ]" steps[20]=" 8a. Remove UNINSTALL script [ waiting... ]"
steps[21]="9 Finalizing"
steps[22]=" 9a. Remove UNINSTALL script [ waiting... ]"
} }
# Update item of $STEPS() and show updated progress dialog # Update item of $STEPS() and show updated progress dialog
@@ -167,6 +168,23 @@ function updateStep ()
dialogShowProgress ${percent} dialogShowProgress ${percent}
} }
# Show summary dialog
function dialogShowSummary ()
{
dialog \
--backtitle "${backtitle}" \
--title "Summary" \
--ascii-lines \
--colors \
--no-collapse \
--cr-wrap \
--yesno \
"\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
case $? in
0) sudo shutdown -r now ;;
esac
}
######################### #########################
# UNINSTALLER FUNCTIONS # # UNINSTALLER FUNCTIONS #
@@ -178,12 +196,32 @@ function uninstaller ()
initSteps initSteps
dialogShowProgress 0 dialogShowProgress 0
saveRemote
1RCLONE 1RCLONE
2PNGVIEW 2PNGVIEW
3IMAGEMAGICK 3IMAGEMAGICK
4RCLONE_SCRIPT 4RCLONE_SCRIPT
5RUNCOMMAND 5RUNCOMMAND
6LocalSAVEFILEDirectory 6LocalSAVEFILEDirectory
7RetroArch
8Finalize
dialogShowSummary
}
function saveRemote ()
{
# list all remotes and their type
remotes=$(rclone listremotes -l)
# get line with RETROPIE remote
retval=$(grep -i "^retropie:" <<< ${remotes})
remoteType="${retval#*:}"
remoteType=$(echo ${remoteType} | xargs)
oldRemote="retropie:${remotebasedir} (${remoteType})"
} }
function 1RCLONE () function 1RCLONE ()
@@ -416,30 +454,148 @@ function 6LocalSAVEFILEDirectory ()
# echo "." > ~/RetroPie/saves/gba/datei_${counter}.srm # echo "." > ~/RetroPie/saves/gba/datei_${counter}.srm
# ((counter++)) # ((counter++))
#done #done
if [ -d ~/RetroPie/saves ]
# start copy task in background, pipe numbered output into COPY.TXT and to LOGFILE then
$(cp -v -r ~/RetroPie/saves/* ~/RetroPie/roms | cat -n | tee copy.txt | cat >> "${logfile}") & # start copy task in background, pipe numbered output into COPY.TXT and to LOGFILE
$(cp -v -r ~/RetroPie/saves/* ~/RetroPie/roms | cat -n | tee copy.txt | cat >> "${logfile}") &
# show content of COPY.TXT
dialog \
--backtitle "${backtitle}" \
--title "Move savefiles to default" \
--ascii-lines \
--colors \
--no-collapse \
--cr-wrap \
--tailbox copy.txt 40 120
wait # show content of COPY.TXT
dialog \
rm copy.txt --backtitle "${backtitle}" \
--title "Copying savefiles to default..." \
#rm ~/RetroPie/saves/gba/datei* --ascii-lines \
#rm ~/RetroPie/roms/gba/datei* --colors \
--no-collapse \
--cr-wrap \
--tailbox copy.txt 40 120
wait
rm copy.txt
#rm ~/RetroPie/saves/gba/datei*
#rm ~/RetroPie/roms/gba/datei*
updateStep "6a" "done" 72 updateStep "6a" "done" 72
else
printf "$(date +%FT%T%:z):\t6a moveFilesToDefault\tNOT FOUND\n" >> "${logfile}"
updateStep "6a" "not found" 72
fi
# 6b. Remove local SAVEFILE directory # 6b. Remove local SAVEFILE directory
printf "$(date +%FT%T%:z):\t6b removeLocalSAVEFILEbasedir\tSTART\n" >> "${logfile}"
updateStep "6b" "in progress" 72
if [ -d ~/RetroPie/saves ]
then
# start remove task in background, pipe numbered output into DELETE.TXT and to LOGFILE
$(sudo rm --recursive --force --verbose ~/RetroPie/saves | cat -n | tee delete.txt | cat >> "${logfile}") &
# show content of REMOVE.TXT
dialog \
--backtitle "${backtitle}" \
--title "Removing savefiles from local base dir..." \
--ascii-lines \
--colors \
--no-collapse \
--cr-wrap \
--tailbox delete.txt 40 120
wait
rm delete.txt
printf "$(date +%FT%T%:z):\t6b removeLocalSAVEFILEbasedir\tDONE\n" >> "${logfile}"
updateStep "6b" "done" 80
else
printf "$(date +%FT%T%:z):\t6b removeLocalSAVEFILEbasedir\tNOT FOUND\n" >> "${logfile}"
updateStep "6b" "skipped" 80
fi
printf "$(date +%FT%T%:z):\t6LocalSAVEFILEDirectory\tDONE\n" >> "${logfile}"
}
function 7RetroArch ()
{
printf "$(date +%FT%T%:z):\t7RetroArch\tSTART\n" >> "${logfile}"
# 7a. Reset local SAVEFILE directories
printf "$(date +%FT%T%:z):\t7a resetSAVEFILEdirectories\tSTART\n" >> "${logfile}"
updateStep "7a" "in progress" 80
local found=0
# for each directory...
for directory in /opt/retropie/configs/*
do
system="${directory##*/}"
# skip system "all"
if [ "${system}" == "all" ]
then
continue
fi
# check if there'a system specific RETROARCH.CFG
if [ -f "${directory}/retroarch.cfg" ]
then
printf "$(date +%FT%T%:z):\t7a resetSAVEFILEdirectories\tFOUND retroarch.cfg for ${system}\n" >> "${logfile}"
# check if RETROARCH.CFG contains SAVEFILE pointing to ~/RetroPie/saves/<SYSTEM>
if [[ $(grep -c "^savefile_directory = \"~/RetroPie/saves/${system}\"" ${directory}/retroarch.cfg) -gt 0 ]]
then
printf "$(date +%FT%T%:z):\t7a resetSAVEFILEdirectories\tFOUND savefile_directory\n" >> "${logfile}"
found=$(($found + 1))
# replace parameter
sed -i "/^savefile_directory = \"~\/RetroPie\/saves\/${system}\"/c\savefile_directory = \"default\"" ${directory}/retroarch.cfg
printf "$(date +%FT%T%:z):\t7a resetSAVEFILEdirectories\tREPLACED savefile_directory\n" >> "${logfile}"
else
printf "$(date +%FT%T%:z):\t7a resetSAVEFILEdirectories\tNOT FOUND savefile_directory\n" >> "${logfile}"
fi
# check if RETROARCH.CFG contains SAVESTATE pointing to ~/RetroPie/saves/<SYSTEM>
if [[ $(grep -c "^savestate_directory = \"~/RetroPie/saves/${system}\"" ${directory}/retroarch.cfg) -gt 0 ]]
then
printf "$(date +%FT%T%:z):\t7a resetSAVESTATEdirectories\tFOUND savestate_directory\n" >> "${logfile}"
found=$(($found + 1))
# replace parameter
sed -i "/^savestate_directory = \"~\/RetroPie\/saves\/${system}\"/c\savestate_directory = \"default\"" ${directory}/retroarch.cfg
printf "$(date +%FT%T%:z):\t7a resetSAVESTATEdirectories\tREPLACED savestate_directory\n" >> "${logfile}"
else
printf "$(date +%FT%T%:z):\t7a resetSAVESTATEdirectories\tNOT FOUND savestate_directory\n" >> "${logfile}"
fi
fi
done
printf "$(date +%FT%T%:z):\t7a resetSAVEFILEdirectories\tDINE\n" >> "${logfile}"
if [[ $found -eq 0 ]]
then
updateStep "7a" "not found" 88
else
updateStep "7a" "done" 88
fi
printf "$(date +%FT%T%:z):\t7RetroArch\tDONE\n" >> "${logfile}"
}
function 8Finalize ()
{
printf "$(date +%FT%T%:z):\t8Finalize\tSTART\n" >> "${logfile}"
# 8a. Remove UNINSTALL script
printf "$(date +%FT%T%:z):\t8a removeUNINSTALLscript\tSTART\n" >> "${logfile}"
updateStep "8a" "in progress" 88
printf "$(date +%FT%T%:z):\t8a removeUNINSTALLscript\tDONE\n" >> "${logfile}"
updateStep "8a" "done" 100
printf "$(date +%FT%T%:z):\t8Finalize\tDONE\n" >> "${logfile}"
# move LOGFILE to HOME
mv ~/scripts/rclone_script/rclone_script-uninstall.log ~
# remove RCLONE_SCRIPT directory
rm -rf ~/scripts/rclone_script
} }