Manage save in Steam common directory
This commit is contained in:
parent
4ad2db6a54
commit
2067c237f4
|
@ -28,6 +28,7 @@ debug=0
|
||||||
steam_id="112595584"
|
steam_id="112595584"
|
||||||
steam_userdata=".steam/steam/userdata/${steam_id}"
|
steam_userdata=".steam/steam/userdata/${steam_id}"
|
||||||
steam_compatdata=".steam/steam/steamapps/compatdata"
|
steam_compatdata=".steam/steam/steamapps/compatdata"
|
||||||
|
steam_common=".steam/steam/steamapps/common"
|
||||||
|
|
||||||
## List of Steam saves in userdata to backup {{{
|
## List of Steam saves in userdata to backup {{{
|
||||||
### 760 − Steam Screenshots − https://steamdb.info/app/760/
|
### 760 − Steam Screenshots − https://steamdb.info/app/760/
|
||||||
|
@ -44,7 +45,11 @@ steam_compatdata=".steam/steam/steamapps/compatdata"
|
||||||
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 {{{
|
## Pattern of Steam saves in common to backup {{{
|
||||||
|
### Add the directory name of the game and the directory|file name to backup
|
||||||
|
### separated by a slash.
|
||||||
|
### eg. GAME_NAME/data.save
|
||||||
### 274190 − Broforce − https://pcgamingwiki.com/wiki/Broforce
|
### 274190 − Broforce − https://pcgamingwiki.com/wiki/Broforce
|
||||||
|
steam_common_games_pattern="Broforce/*.sav"
|
||||||
# }}}
|
# }}}
|
||||||
## 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
|
||||||
|
@ -132,7 +137,7 @@ if [ ! -d "${remote_dir}" ]; then
|
||||||
fi
|
fi
|
||||||
## }}}
|
## }}}
|
||||||
## Ensure Steam directories exist {{{
|
## Ensure Steam directories exist {{{
|
||||||
for steam_dir in "${steam_userdata}" "${steam_compatdata}"; do
|
for steam_dir in "${steam_userdata}" "${steam_common}" "${steam_compatdata}"; do
|
||||||
local_steam_path="${HOME}/${steam_dir}"
|
local_steam_path="${HOME}/${steam_dir}"
|
||||||
if [ ! -d "${local_steam_path}" ]; then
|
if [ ! -d "${local_steam_path}" ]; then
|
||||||
printf '\e[1;35m%-6s\e[m\n' "The Steam directory − ${steam_dir} for your ID (${steam_id}) doesn't exists yet… Should it must be create (for restoration,…) [Y/n] ?"
|
printf '\e[1;35m%-6s\e[m\n' "The Steam directory − ${steam_dir} for your ID (${steam_id}) doesn't exists yet… Should it must be create (for restoration,…) [Y/n] ?"
|
||||||
|
@ -157,7 +162,7 @@ for game_id in ${steam_userdata_games}; do
|
||||||
case ${local_game_path_type} in
|
case ${local_game_path_type} in
|
||||||
## Data is already a symlink
|
## Data is already a symlink
|
||||||
"symbolic")
|
"symbolic")
|
||||||
[ "${debug}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : Steam for loop — The data of ${game_id} are already symlinked to .... Skip."
|
[ "${debug}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : Steam userdata for loop — The data of ${game_id} are already symlinked to .... Skip."
|
||||||
;;
|
;;
|
||||||
## Data is still a directory
|
## Data is still a directory
|
||||||
"directory")
|
"directory")
|
||||||
|
@ -165,7 +170,7 @@ for game_id in ${steam_userdata_games}; do
|
||||||
;;
|
;;
|
||||||
## Data doesn't exist
|
## Data doesn't exist
|
||||||
"cannot")
|
"cannot")
|
||||||
[ "${debug}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : Steam for loop — The data of ${game_id} − ${local_game_path} doesn't exist. Skip."
|
[ "${debug}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : Steam userdata for loop — The data of ${game_id} − ${local_game_path} doesn't exist. Skip."
|
||||||
symlink_steam_game_dir "${game_id}" "${steam_userdata}"
|
symlink_steam_game_dir "${game_id}" "${steam_userdata}"
|
||||||
;;
|
;;
|
||||||
## Data can't be managed
|
## Data can't be managed
|
||||||
|
@ -177,7 +182,60 @@ for game_id in ${steam_userdata_games}; do
|
||||||
|
|
||||||
done
|
done
|
||||||
# }}}
|
# }}}
|
||||||
# Manage Steam compadata save game {{{
|
# Manage Steam common save game {{{
|
||||||
|
for game_pattern in ${steam_common_games_pattern}; do
|
||||||
|
## Separate the game_name and the directory|file to backup|symlink
|
||||||
|
game_name="$(echo ${game_pattern} | cut -d"/" -f1)"
|
||||||
|
save_pattern="$(echo ${game_pattern} | cut -d"/" -f2)"
|
||||||
|
|
||||||
|
## If the game is installed
|
||||||
|
if [ -d "${HOME}/${steam_common}/${game_name}" ]; then
|
||||||
|
|
||||||
|
### Follow symbolic links but avoid links to dosdevices and keep only one result
|
||||||
|
temp_local_save_path="$(find -L "${HOME}/${steam_common}/${game_name}" -iname "${save_pattern}" -print -quit)"
|
||||||
|
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 {{{
|
||||||
|
#if [ "${debug}" -eq "0" ]; then
|
||||||
|
#printf '\e[1;35m%-6s\e[m\n' "DEBUG : game name : ${game_name}"
|
||||||
|
#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}"
|
||||||
|
#printf '\e[1;35m%-6s\e[m\n' "DEBUG : local save path : ${local_save_path}"
|
||||||
|
#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
|
||||||
|
## Data is already a symlink
|
||||||
|
"symbolic"|"symboliclink"|"l")
|
||||||
|
[ "${debug}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : Steam common for loop — The data of ${game_name} are already symlinked to .... Skip."
|
||||||
|
;;
|
||||||
|
## Data is still a directory, try to move it
|
||||||
|
"directory"|"d")
|
||||||
|
move_steam_game_dir "$(basename "${steam_dir}")" "$(dirname "${steam_dir}")"
|
||||||
|
;;
|
||||||
|
## Data doesn't exist
|
||||||
|
"cannot")
|
||||||
|
[ "${debug}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : Steam common for loop — The data of ${game_name} − ${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_name} (common) − ${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 common for loop — ${game_name} doesn't seems to be installed on the system, check the path : ${HOME}/${steam_common}/${game_name} . Skip."
|
||||||
|
fi
|
||||||
|
|
||||||
|
done
|
||||||
|
# }}}
|
||||||
|
# Manage Steam compatdata save game {{{
|
||||||
for game_pattern in ${steam_compatdata_games_pattern}; do
|
for game_pattern in ${steam_compatdata_games_pattern}; do
|
||||||
## Separate the game_id and the directory|file to backup|symlink
|
## Separate the game_id and the directory|file to backup|symlink
|
||||||
game_id="$(echo ${game_pattern} | cut -d"/" -f1)"
|
game_id="$(echo ${game_pattern} | cut -d"/" -f1)"
|
||||||
|
|
Loading…
Reference in New Issue