Function to move and symlink Steam save games

This commit is contained in:
Jeremy Gardais 2019-10-05 20:54:04 +02:00
parent 69dc3912a5
commit 54d820edd3
1 changed files with 23 additions and 1 deletions

View File

@ -18,6 +18,27 @@ remote_steam_userdata="${remote_dir}/${steam_userdata}"
local_steam_userdata="${HOME}/${steam_userdata}"
# }}}
# Functions {{{
# Move one Steam save game dir {{{
move_steam_game_dir() {
local game_id="${1}"
local local_game_path="${local_steam_userdata}/${game_id}"
local remote_game_path="${remote_steam_userdata}/${game_id}"
## If a remote directory doesn't already exists for this game
if [ ! -d "${remote_game_path}" ]; then
mv -- "${local_game_path}" "${remote_game_path}"
[ "${debug}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "Move Steam game The data of ${game_id} ${local_game_path} moved to remote storage."
ln -s -- "${remote_game_path}" "${local_game_path}"
[ "${debug}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "Move Steam game Symlink remote to data of ${game_id} to local storage."
else
printf '\e[1;35m%-6s\e[m\n' "Move Steam game ${game_id} already have data on remote storage: ${remote_game_path}. Abort to avoid to delete data."
exit 5
fi
}
# }}}
# }}}
# Tests {{{
## Ensure remote dir exist {{{
@ -41,7 +62,7 @@ fi
# }}}
# Manage steam game
# Manage Steam save game {{{
for game_id in ${steam_games}; do
local_game_path="${local_steam_userdata}/${game_id}"
local_game_path_type="$(file ${local_steam_userdata}/${game_id} | cut -d' ' -f2)"
@ -65,5 +86,6 @@ for game_id in ${steam_games}; do
exit 3
;;
esac
# }}}
done