Skip to content

Commit

Permalink
server dir + create_backup + create_sample_csv for #8
Browse files Browse the repository at this point in the history
- Added the server directory to keep track of config files and scripts (31/01/2023 - 12:10:35)
- Added the script that I use to start steamcmd to the server/local/ dir (31/01/2023 - 12:10:55)
- Moved the create_backup.sh and create_sample_csv.sh scripts to the server/tools dir (31/01/2023 - 12:11:34)
- Updated the create_backup and create_sample_csv scripts to use the root of the git repository as a reference for where the config.json exists (31/01/2023 - 12:32:49)
  • Loading branch information
andygello555 committed Jan 31, 2023
1 parent 9cebbc7 commit 2bc9800
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 5 deletions.
2 changes: 0 additions & 2 deletions create_backup.sh

This file was deleted.

3 changes: 0 additions & 3 deletions create_sample_csv.sh

This file was deleted.

51 changes: 51 additions & 0 deletions server/local/steamcmd_linux
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env bash

STEAMROOT="/home/$USER/.local/share/Steam/steamcmd"
STEAMCMD="steamcmd"

UNAME=`uname`
if [ "$UNAME" == "Linux" ]; then
STEAMEXE="${STEAMROOT}/linux32/${STEAMCMD}"
PLATFORM="linux32"
export LD_LIBRARY_PATH="$STEAMROOT/$PLATFORM:$LD_LIBRARY_PATH"
else # if [ "$UNAME" == "Darwin" ]; then
STEAMEXE="${STEAMROOT}/${STEAMCMD}"
if [ ! -x ${STEAMEXE} ]; then
STEAMEXE="${STEAMROOT}/Steam.AppBundle/Steam/Contents/MacOS/${STEAMCMD}"
fi
export DYLD_LIBRARY_PATH="$STEAMROOT:$DYLD_LIBRARY_PATH"
export DYLD_FRAMEWORK_PATH="$STEAMROOT:$DYLD_FRAMEWORK_PATH"
fi

ulimit -n 2048

MAGIC_RESTART_EXITCODE=42

echo "debugger = $DEBUGGER: $DEBUGGER $STEAMEXE $@"
if [ "$DEBUGGER" == "gdb" ] || [ "$DEBUGGER" == "cgdb" ]; then
ARGSFILE=$(mktemp $USER.steam.gdb.XXXX)

# Set the LD_PRELOAD varname in the debugger, and unset the global version.
if [ "$LD_PRELOAD" ]; then
echo set env LD_PRELOAD=$LD_PRELOAD >> "$ARGSFILE"
echo show env LD_PRELOAD >> "$ARGSFILE"
unset LD_PRELOAD
fi

: "${DEBUGGER_ARGS=}"
$DEBUGGER -x "$ARGSFILE" $DEBUGGER_ARGS --args "$STEAMEXE" "$@"
rm "$ARGSFILE"
elif [ "$DEBUGGER" == "" ]; then
exec "$STEAMEXE" "$@"
else
$DEBUGGER "$STEAMEXE" "$@"
fi

STATUS=$?

if [ $STATUS -eq $MAGIC_RESTART_EXITCODE ]; then
echo "exec: $0 $@"
exec "$0" "$@"
fi
echo "exit: $STATUS"
exit $STATUS
9 changes: 9 additions & 0 deletions server/tools/create_backup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ROOT="$(git rev-parse --show-toplevel)"
DB=$(python3 -c "import json; print(json.loads(open('$ROOT/config.json').read().encode().decode('utf-8-sig'))['db']['name'])")
FILENAME="game_scout_db-$(date +%F).sql"
UNAME="$(uname)"
if [ "$UNAME" == "Linux" ]; then
sudo -u postgres pg_dump $DB > "$FILENAME"
elif [ "$UNAME" == "Darwin" ]; then
pg_dump $DB > "$FILENAME"
fi
12 changes: 12 additions & 0 deletions server/tools/create_sample_csv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
ROOT="$(git rev-parse --show-toplevel)"
DB=$(python3 -c "import json; print(json.loads(open('$ROOT/config.json').read().encode().decode('utf-8-sig'))['db']['name'])")
UNAME="$(uname)"
COMMAND1="\copy (select * from developers inner join developer_snapshots on developer_snapshots.developer_id = developers.id left join games on developers.username = ANY(games.developers) where not developers.disabled) to '$(pwd)/$(date +%F)_sample.csv' (FORMAT CSV, HEADER TRUE, DELIMITER ',', ENCODING 'UTF8');"
COMMAND2="\copy (select * from steam_apps where not bare and weighted_score is not null) to '$(pwd)/$(date +%F)_steamapps.csv' (FORMAT CSV, HEADER TRUE, DELIMITER ',', ENCODING 'UTF8');"
if [ "$UNAME" == "Linux" ]; then
sudo -u postgres psql $DB -c "$COMMAND1"
sudo -u postgres psql $DB -c "$COMMAND2"
elif [ "$UNAME" == "Darwin" ]; then
psql $DB -c "$COMMAND1"
psql $DB -c "$COMMAND2"
fi

0 comments on commit 2bc9800

Please sign in to comment.