70 lines
2.0 KiB
Bash
Executable File
70 lines
2.0 KiB
Bash
Executable File
#!/bin/sh
|
||
|
||
# Vars {{{
|
||
debug=0
|
||
|
||
## Steam {{{
|
||
steam_id="112595584"
|
||
steam_userdata=".steam/steam/userdata/${steam_id}"
|
||
|
||
## List of Steam games to backup
|
||
### 204360 − Castle Crashers − https://pcgamingwiki.com/wiki/Castle_Crashers
|
||
steam_games="1 204360 17"
|
||
## }}}
|
||
|
||
remote_dir="${HOME}/Nextcloud/games/linux.sgl.script"
|
||
remote_steam_userdata="${remote_dir}/${steam_userdata}"
|
||
|
||
local_steam_userdata="${HOME}/${steam_userdata}"
|
||
# }}}
|
||
|
||
# Tests {{{
|
||
|
||
## Ensure remote dir exist {{{
|
||
if [ ! -d "${remote_dir}" ]; then
|
||
printf '\e[1;35m%-6s\e[m\n' "The directory for save game doesn't exists : ${remote_dir}"
|
||
exit 1
|
||
fi
|
||
## }}}
|
||
## Ensure Steam dir exist {{{
|
||
if [ ! -d "${local_steam_userdata}" ]; then
|
||
printf '\e[1;35m%-6s\e[m\n' "The Steam directory for your ID (${steam_id}) doesn't exists yet… Should it must be create (for restoration,…) [Y/n] ?"
|
||
read -r create_local_steam_userdata
|
||
if [ "${create_local_steam_userdata}" = "" ] || [ "${create_local_steam_userdata}" = "Y" ] || [ "${create_local_steam_userdata}" = "y" ]; then
|
||
mkdir -p -- "${local_steam_userdata}"
|
||
else
|
||
printf '\e[1;35m%-6s\e[m\n' "Steam directory doesn't exists, abort script."
|
||
exit 2
|
||
fi
|
||
fi
|
||
## }}}
|
||
|
||
# }}}
|
||
|
||
# Manage steam 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)"
|
||
|
||
|
||
case ${local_game_path_type} in
|
||
## Data is already a symlink
|
||
"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."
|
||
;;
|
||
## Data is still a directory
|
||
"directory")
|
||
move_steam_game_dir "${game_id}"
|
||
;;
|
||
## Data can't be managed
|
||
"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."
|
||
;;
|
||
*)
|
||
printf '\e[1;35m%-6s\e[m\n' "Data of ${game_id} − ${local_game_path} are not managed. Type: ${local_game_path_type}. Abort"
|
||
exit 3
|
||
;;
|
||
esac
|
||
|
||
done
|