-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
server dir + create_backup + create_sample_csv for #8
- 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
1 parent
9cebbc7
commit 2bc9800
Showing
5 changed files
with
72 additions
and
5 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |