Manage compatdata saves only for installed games

This commit is contained in:
Jeremy Gardais 2019-10-09 16:50:18 +02:00
parent c6d7579469
commit 4ad2db6a54
1 changed files with 45 additions and 39 deletions

View File

@ -43,6 +43,9 @@ steam_compatdata=".steam/steam/steamapps/compatdata"
### 359840 Shift Happens https://pcgamingwiki.com/wiki/Shift_Happens ### 359840 Shift Happens https://pcgamingwiki.com/wiki/Shift_Happens
steam_userdata_games="760 35700 35720 55230 204360 206420 218820 247080 255870 312530 359840" steam_userdata_games="760 35700 35720 55230 204360 206420 218820 247080 255870 312530 359840"
## }}} ## }}}
## Pattern of Steam saves in common to backup {{{
### 274190 Broforce https://pcgamingwiki.com/wiki/Broforce
# }}}
## Pattern of Steam saves in compatdata to backup {{{ ## Pattern of Steam saves in compatdata to backup {{{
### Compatdata contains directories for games using Steam play so it's too big ### Compatdata contains directories for games using Steam play so it's too big
### to be fully moved to a remote storage. ### to be fully moved to a remote storage.
@ -55,9 +58,6 @@ steam_userdata_games="760 35700 35720 55230 204360 206420 218820 247080 255870 3
### 686200 Door Kickers: Action Squad https://pcgamingwiki.com/wiki/Door_Kickers:_Action_Squad ### 686200 Door Kickers: Action Squad https://pcgamingwiki.com/wiki/Door_Kickers:_Action_Squad
steam_compatdata_games_pattern="213670/save 312610/UserDefault.xml 686200/userdata.bin" steam_compatdata_games_pattern="213670/save 312610/UserDefault.xml 686200/userdata.bin"
# }}} # }}}
## List of Steam saves in steamapps to backup {{{
### 274190 Broforce https://pcgamingwiki.com/wiki/Broforce
# }}}
## Ids without backups in userdata {{{ ## Ids without backups in userdata {{{
### 7 Unknown ### 7 Unknown
### 620 Portal 2 https://pcgamingwiki.com/wiki/Portal_2 ### 620 Portal 2 https://pcgamingwiki.com/wiki/Portal_2
@ -183,44 +183,50 @@ for game_pattern in ${steam_compatdata_games_pattern}; do
game_id="$(echo ${game_pattern} | cut -d"/" -f1)" game_id="$(echo ${game_pattern} | cut -d"/" -f1)"
save_pattern="$(echo ${game_pattern} | cut -d"/" -f2)" save_pattern="$(echo ${game_pattern} | cut -d"/" -f2)"
### Follow symbolic links but avoid links to dosdevices and keep only one result ## If the game is installed
temp_local_save_path="$(find -L "${HOME}/${steam_compatdata}/${game_id}" -ipath "*dosdevices*" -prune -o -iname "${save_pattern}" | grep -v "dosdevices" | head -n 1)" if [ -d "${HOME}/${steam_compatdata}/${game_id}" ]; then
local_save_path="$(dirname "${temp_local_save_path}")"
local_save_path_type="$(ls -ld "${local_save_path}" | sed 's/\(^.\).*/\1/')"
## Path independent from local or remote base directory
steam_dir="$(printf "%s" "${local_save_path}" | sed -e "s;${HOME}/;;")"
## Print vars {{{ ### Follow symbolic links but avoid links to dosdevices and keep only one result
#if [ "${debug}" -eq "0" ]; then temp_local_save_path="$(find -L "${HOME}/${steam_compatdata}/${game_id}" -ipath "*dosdevices*" -prune -o -iname "${save_pattern}" | grep -v "dosdevices" | head -n 1)"
#printf '\e[1;35m%-6s\e[m\n' "DEBUG: game ID: ${game_id}" local_save_path="$(dirname "${temp_local_save_path}")"
#printf '\e[1;35m%-6s\e[m\n' "DEBUG: save pattern: ${save_pattern}" local_save_path_type="$(ls -ld "${local_save_path}" | sed 's/\(^.\).*/\1/')"
#printf '\e[1;35m%-6s\e[m\n' "DEBUG: temp local save path: ${temp_local_save_path}" ## Path independent from local or remote base directory
#printf '\e[1;35m%-6s\e[m\n' "DEBUG: local save path: ${local_save_path}" steam_dir="$(printf "%s" "${local_save_path}" | sed -e "s;${HOME}/;;")"
#printf '\e[1;35m%-6s\e[m\n' "DEBUG: local save type: ${local_save_path_type}"
#printf '\e[1;35m%-6s\e[m\n' "DEBUG: steam dir: ${steam_dir}"
#fi
## }}}
case ${local_save_path_type} in ## Print vars {{{
## Data is already a symlink #if [ "${debug}" -eq "0" ]; then
"symbolic"|"symboliclink"|"l") #printf '\e[1;35m%-6s\e[m\n' "DEBUG: game ID: ${game_id}"
[ "${debug}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG: Steam compatdata for loop — The data of ${game_id} are already symlinked to .... Skip." #printf '\e[1;35m%-6s\e[m\n' "DEBUG: save pattern: ${save_pattern}"
;; #printf '\e[1;35m%-6s\e[m\n' "DEBUG: temp local save path: ${temp_local_save_path}"
## Data is still a directory, try to move it #printf '\e[1;35m%-6s\e[m\n' "DEBUG: local save path: ${local_save_path}"
"directory"|"d") #printf '\e[1;35m%-6s\e[m\n' "DEBUG: local save type: ${local_save_path_type}"
move_steam_game_dir "$(basename "${steam_dir}")" "$(dirname "${steam_dir}")" #printf '\e[1;35m%-6s\e[m\n' "DEBUG: steam dir: ${steam_dir}"
;; #fi
## Data doesn't exist ## }}}
"cannot")
[ "${debug}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG: Steam compatdata for loop — The data of ${game_id} ${local_save_path} doesn't exist. Skip." case ${local_save_path_type} in
### TODO: Try to symlink ## Data is already a symlink
;; "symbolic"|"symboliclink"|"l")
## Data can't be managed [ "${debug}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG: Steam compatdata for loop — The data of ${game_id} are already symlinked to .... Skip."
*) ;;
printf '\e[1;35m%-6s\e[m\n' "Data of ${game_id} (compatdata) ${local_save_path} are not managed. Type: ${local_save_path_type}. Abort." ## Data is still a directory, try to move it
exit 3 "directory"|"d")
;; move_steam_game_dir "$(basename "${steam_dir}")" "$(dirname "${steam_dir}")"
esac ;;
## Data doesn't exist
"cannot")
[ "${debug}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG: Steam compatdata for loop — The data of ${game_id} ${local_save_path} doesn't exist. Skip."
### TODO: Try to symlink
;;
## Data can't be managed
*)
printf '\e[1;35m%-6s\e[m\n' "Data of ${game_id} (compatdata) ${local_save_path} are not managed. Type: ${local_save_path_type}. Abort."
exit 3
;;
esac
else ## The game is not present on the system
[ "${debug}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG: Steam compatdata for loop — ${game_id} doesn't seems to be installed on the system. Skip."
fi
done done
# }}} # }}}