rclone_script.sh

* changed some of the log messages

rclone_script-install.sh
* added creation of network share to step 6a

rclone_script-uninstall.sh
* removed debug code
* added removal of network share to step 6b
This commit is contained in:
Jandalf81
2018-08-17 02:23:14 +02:00
parent fe2e252a9f
commit 2a3f1dc0cb
3 changed files with 42 additions and 22 deletions

View File

@@ -38,8 +38,8 @@ dialog \
--no-collapse \
--cr-wrap \
--yesno \
"\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. The 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.\n\nAre you sure you wish to continue?" \
25 90 2>&1 > /dev/tty \
"\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. The 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?" \
26 90 2>&1 > /dev/tty \
|| exit
@@ -876,8 +876,19 @@ function 6aCheckLocalBaseDirectory ()
printf "$(date +%FT%T%:z):\t6aCheckLocalBaseDirectory\tNOT FOUND\n" >> "${logfile}"
mkdir ~/RetroPie/saves
printf "$(date +%FT%T%:z):\t6aCheckLocalBaseDirectory\tCREATED directory\n" >> "${logfile}"
printf "$(date +%FT%T%:z):\t6aCheckLocalBaseDirectory\tCREATED\n" >> "${logfile}"
# share that new directory on the network
if [[ $(grep -c "\[saves\]" /etc/samba/smb.conf) -eq 0 ]]
then
# add new share to SAMBA
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
# restart SAMBA
sudo service smbd restart
printf "$(date +%FT%T%:z):\t6aCheckLocalBaseDirectory\tCREATED network share\n" >> "${logfile}"
fi
return 1
fi

View File

@@ -446,12 +446,6 @@ function 6LocalSAVEFILEDirectory ()
printf "$(date +%FT%T%:z):\t6a moveFilesToDefault\tSTART\n" >> "${logfile}"
updateStep "6a" "in progress" 64
#counter=1
#while [ $counter -le 10000 ]
#do
# echo "." > ~/RetroPie/saves/gba/datei_${counter}.srm
# ((counter++))
#done
if [ -d ~/RetroPie/saves ]
then
# start copy task in background, pipe numbered output into COPY.TXT and to LOGFILE
@@ -470,9 +464,6 @@ function 6LocalSAVEFILEDirectory ()
rm copy.txt
#rm ~/RetroPie/saves/gba/datei*
#rm ~/RetroPie/roms/gba/datei*
updateStep "6a" "done" 72
else
printf "$(date +%FT%T%:z):\t6a moveFilesToDefault\tNOT FOUND\n" >> "${logfile}"
@@ -501,6 +492,24 @@ function 6LocalSAVEFILEDirectory ()
rm delete.txt
# check if that directory is shared
local retval=$(grep -n "\[saves\]" /etc/samba/smb.conf)
if [ "${retval}" != "" ]
then
# extract line numbers
local lnStart="${retval%%:*}"
local lnEnd=$(( $lnStart + 7 ))
# remove network share
sudo sed -i -e "${lnStart},${lnEnd}d" /etc/samba/smb.conf
# restart SAMBA service
sudo service smbd restart
printf "$(date +%FT%T%:z):\t6b removeLocalSAVEFILEbasedir\tREMOVED network share\n" >> "${logfile}"
fi
printf "$(date +%FT%T%:z):\t6b removeLocalSAVEFILEbasedir\tDONE\n" >> "${logfile}"
updateStep "6b" "done" 80
else

View File

@@ -151,8 +151,8 @@ function downloadSaves ()
return
fi
log "INFO" "Started ${romfilename} (${system})"
log "INFO" "Downloading saves and states from ${remoteType}..."
log "INFO" "Started ${system}/${romfilename} "
log "INFO" "Downloading saves and states for ${system}/${romfilename} from ${remoteType}..."
showNotification "Downloading saves and states from ${remoteType}..."
# test for remote files
@@ -165,7 +165,7 @@ function downloadSaves ()
if [ "${remotefiles}" = "" ]
then # no remote files found
log "INFO" "No remote files found"
showNotification "Downloading saves and states from ${remoteType}... No remote saves found"
showNotification "Downloading saves and states from ${remoteType}... No remote files found"
else # remote files found
log "INFO" "Found remote files"
@@ -178,12 +178,12 @@ function downloadSaves ()
log "INFO" "Done"
showNotification "Downloading saves and states from ${remoteType}... Done" "green"
else
log "ERROR" "Saves could not be downloaded"
log "ERROR" "Saves and states could not be downloaded"
showNotification "Downloading saves and states from ${remoteType}... ERROR" "red" "" "" "" "forced"
fi
fi
else # error with RCLONE
log "ERROR" "Saves could not be downloaded"
log "ERROR" "Saves and states could not be downloaded"
showNotification "Downloading saves and states from ${remoteType}... ERROR" "red" "" "" "" "forced"
fi
}
@@ -196,16 +196,16 @@ function uploadSaves ()
return
fi
log "INFO" "Stopped ${romfilename} (${system})"
log "INFO" "Uploading saves and states to ${remoteType}..."
log "INFO" "Stopped ${system}/${romfilename} "
log "INFO" "Uploading saves and states for ${system}/${romfilename} to ${remoteType}..."
showNotification "Uploading saves and states to ${remoteType}..."
localfiles=$(find ~/RetroPie/saves/${system} -type f -iname "${filter}.*")
if [ "${localfiles}" = "" ]
then # no local files found
log "INFO" "No local saves found"
showNotification "Uploading saves and states to ${remoteType}... No local saves found"
log "INFO" "No local saves and states found"
showNotification "Uploading saves and states to ${remoteType}... No local files found"
else # local files found
# upload saves and states to corresponding ROM
rclone copy ~/RetroPie/saves/${system} retropie:${remotebasedir}/${system} --include "${filter}.*" --update >> ${logfile}
@@ -216,7 +216,7 @@ function uploadSaves ()
log "INFO" "Done"
showNotification "Uploading saves and states to ${remoteType}... Done" "green"
else
log "ERROR" "Saves could not be uploaded"
log "ERROR" "saves and states could not be uploaded"
showNotification "Uploading saves and states to ${remoteType}... ERROR" "red" "" "" "" "forced"
fi
fi