added support for steam on native linux
authorChris Koeritz <fred@gruntose.com>
Wed, 23 Jan 2019 05:05:22 +0000 (00:05 -0500)
committerChris Koeritz <fred@gruntose.com>
Wed, 23 Jan 2019 05:05:22 +0000 (00:05 -0500)
scripts/customize/fred/scripts/games/gamesaver.sh

index 9a8399d3ee1c0808a1693cc9acf22d08e49c8da1..f90514f6fa3edaf2dc4cb254d30ebe3a86431d69 100644 (file)
@@ -5,24 +5,6 @@
 
 source "$FEISTY_MEOW_SCRIPTS/core/launch_feisty_meow.sh"
 
-WINE_GOODS_DIR="$HOME/wine_goods"
-if [ ! -d "$WINE_GOODS_DIR" ]; then
-  WINE_GOODS_DIR="/cygdrive/c/users/fred/My Documents"
-fi
-
-WINE_GAMES_DIR="$WINE_GOODS_DIR/My Games"
-SPOOLING_OUTPUT_DIR="$HOME/data/spooling_saves"
-
-if [ ! -d "$WINE_GAMES_DIR" ]; then
-  echo "Failing to find the game save directories."
-  exit 1
-fi
-
-if [ ! -d "$SPOOLING_OUTPUT_DIR" ]; then
-  mkdir -p "$SPOOLING_OUTPUT_DIR"
-  exit_on_error Creating spooling output directory.
-fi
-
 # copies the files for a particular game out to a spooling folder.
 function copyem()
 {
@@ -43,21 +25,62 @@ function copyem()
 
 ##############
 
-# now run through and copy our save files from the potentially weird locations
-# they reside in.
+# run through and copy our save files from the potentially weird locations they reside in.
+# this requires a single argument, which is the top-level directory of the game storage.
+function copy_all_save_games()
+{
+  local WINE_GOODS_DIR="$1"
+
+  local WINE_GAMES_DIR="$WINE_GOODS_DIR/My Games"
+  local SPOOLING_OUTPUT_DIR="$HOME/data/spooling_saves"
+
+  if [ ! -d "$WINE_GAMES_DIR" ]; then
+    echo "Failing to find the game save directories."
+    exit 1
+  fi
+
+  if [ ! -d "$SPOOLING_OUTPUT_DIR" ]; then
+    mkdir -p "$SPOOLING_OUTPUT_DIR"
+    exit_on_error Creating spooling output directory.
+  fi
+
+  sep 28
+
+  copyem "skyrim" "$WINE_GAMES_DIR/Skyrim/Saves" "$SPOOLING_OUTPUT_DIR/skyrim"
 
-sep 28
+  copyem "fallout new vegas" "$WINE_GAMES_DIR/FalloutNV/Saves" "$SPOOLING_OUTPUT_DIR/fallout_new_vegas"
 
-copyem "skyrim" "$WINE_GAMES_DIR/Skyrim/Saves" "$SPOOLING_OUTPUT_DIR/skyrim"
+  copyem "fallout 3" "$WINE_GAMES_DIR/Fallout3/Saves" "$SPOOLING_OUTPUT_DIR/fallout_3"
 
-copyem "fallout new vegas" "$WINE_GAMES_DIR/FalloutNV/Saves" "$SPOOLING_OUTPUT_DIR/fallout_new_vegas"
+  copyem "oblivion" "$WINE_GAMES_DIR/Oblivion/Saves" "$SPOOLING_OUTPUT_DIR/oblivion/"
 
-copyem "fallout 3" "$WINE_GAMES_DIR/Fallout3/Saves" "$SPOOLING_OUTPUT_DIR/fallout_3"
+  copyem "fallout 4" "$WINE_GAMES_DIR/Fallout4/Saves" "$SPOOLING_OUTPUT_DIR/fallout_4"
 
-copyem "oblivion" "$WINE_GAMES_DIR/Oblivion/Saves" "$SPOOLING_OUTPUT_DIR/oblivion/"
+  copyem "witcher 3" "$WINE_GOODS_DIR/The Witcher 3/gamesaves" "$SPOOLING_OUTPUT_DIR/witcher_3"
+}
 
-copyem "fallout 4" "$WINE_GAMES_DIR/Fallout4/Saves" "$SPOOLING_OUTPUT_DIR/fallout_4"
+# mainline of script tries out a few locations to back up.
 
-copyem "witcher 3" "$WINE_GOODS_DIR/The Witcher 3/gamesaves" "$SPOOLING_OUTPUT_DIR/witcher_3"
+# first try our play on linux storage.  very individualized for fred.
+wine_goods_dir="$HOME/wine_goods"
+if [ ! -d "$wine_goods_dir" ]; then
+  wine_goods_dir="/cygdrive/c/users/fred/My Documents"
+fi
+if [ ! -d "$wine_goods_dir" ]; then
+  echo "not trying to back up any wine goods; could not find an appropriate folder."
+else
+  copy_all_save_games "$wine_goods_dir"
+fi
+
+# now try the main linux steam save game storage area, which is also fred specific.
+# this uses a link in the home directory called steam_goods which is connected to
+# "$HOME/.steam/steam/SteamApps/compatdata/MYNUM/pfx/drive_c/users/steamuser/My Documents"
+# where MYNUM is replaced with one's steam ID number.
+wine_goods_dir="$HOME/steam_goods"
+if [ ! -d "$wine_goods_dir" ]; then
+  echo "not trying to back up any wine goods; could not find an appropriate folder."
+else
+  copy_all_save_games "$wine_goods_dir"
+fi