Browse Source

Initial commit

master
Jessica James 3 years ago
commit
7259fdc58b
  1. 76
      .s3cfg-gcloud
  2. 130
      clean_builds.sh
  3. 34
      game_mirrors
  4. 112
      map_builds.sh
  5. 145
      set_game_branch.sh
  6. 13
      sync.sh
  7. 20
      update_mirrors.sh

76
.s3cfg-gcloud

@ -0,0 +1,76 @@
[default]
access_key = GOOG2F4PQLDENFN2QHXH
access_token =
add_encoding_exts =
add_headers =
bucket_location = US
ca_certs_file =
cache_file =
check_ssl_certificate = True
check_ssl_hostname = True
cloudfront_host = cloudfront.amazonaws.com
default_mime_type = binary/octet-stream
delay_updates = False
delete_after = False
delete_after_fetch = False
delete_removed = False
dry_run = False
enable_multipart = True
encrypt = False
expiry_date =
expiry_days =
expiry_prefix =
follow_symlinks = False
force = False
get_continue = False
gpg_command = /usr/bin/gpg
gpg_decrypt = %(gpg_command)s -d --verbose --no-use-agent --batch --yes --passphrase-fd %(passphrase_fd)s -o %(output_file)s %(input_file)s
gpg_encrypt = %(gpg_command)s -c --verbose --no-use-agent --batch --yes --passphrase-fd %(passphrase_fd)s -o %(output_file)s %(input_file)s
gpg_passphrase =
guess_mime_type = True
host_base = storage.googleapis.com
host_bucket = %(bucket).storage.googleapis.com
human_readable_sizes = False
invalidate_default_index_on_cf = False
invalidate_default_index_root_on_cf = True
invalidate_on_cf = False
kms_key =
limit = -1
limitrate = 0
list_md5 = False
log_target_prefix =
long_listing = False
max_delete = -1
mime_type =
multipart_chunk_size_mb = 15
multipart_max_chunks = 10000
preserve_attrs = True
progress_meter = True
proxy_host =
proxy_port = 0
put_continue = False
recursive = False
recv_chunk = 65536
reduced_redundancy = False
requester_pays = False
restore_days = 1
restore_priority = Standard
secret_key = P2wrxwJmDO0qEyA/99NUeQPGHd4C0yx6kiDTBjFI
send_chunk = 65536
server_side_encryption = False
signature_v2 = False
signurl_use_https = False
simpledb_host = sdb.amazonaws.com
skip_existing = False
socket_timeout = 300
stats = False
stop_on_error = False
storage_class =
urlencoding_mode = normal
use_http_expect = False
use_https = True
use_mime_magic = True
verbosity = WARNING
website_endpoint = http://%(bucket)s.s3-website-%(location)s.amazonaws.com/
website_error =
website_index = index.html

130
clean_builds.sh

@ -0,0 +1,130 @@
# Setup static paths
version_path="${version_data_path}"
patches_path="${patches_data_path}"
# Parse arguments
echo_output=false
verbose=false
function print_help() {
echo "Cleans up unreferenced builds."
echo "Options:"
echo " --help, -h | Displays this help message"
echo " --echo, -e, --dry-run | Suppresses deleting the unreferenced builds"
echo " --verbose, -v | Enables verbose output, useful for debugging"
echo " --version-path <path> | Explicitly override version data directory path with specified"
echo " --patches-path <path> | Explicitly override patch data path with specified"
echo ""
echo "Example usage: ./clean_builds --echo"
exit 0
}
for arg in "$@"
do
case $arg in
--help|-h)
print_help
;;
--echo|--dry-run|-e)
echo_output=true
shift
;;
--verbose|-v)
verbose=true
shift
;;
--version-path)
version_path="$2"
shift
shift
;;
--patches-path)
patches_path="$2"
shift
shift
;;
esac
done
if $verbose
then
echo "Values:"
echo " echo_output: $echo_output"
echo " patches_path: $patches_path"
echo " version_path: $version_path"
echo ""
fi
# Scans for unreferenced builds, and deletes them if necessary
#
# @param version_file Path to version files containing build information
# @param patches_path Path to the root patches directory on this filesystem
function clean_builds() {
version_path="$1"
patches_path="$2"
# Read in list of builds
builds=()
for item in $patches_path/*; do
if [ -f "$item/instructions.json" ]; then
builds+=("$item")
#echo "$item"
fi
done
if $verbose; then
echo "Builds available:"
for build in "${builds[@]}"; do
echo "$build"
done
echo ""
fi
# Read in referenced builds
referenced_builds=()
for version_file in $version_path/*; do
version_data=$(cat "$version_file")
build=$(echo "$version_data" | jq -r ".game.patch_path")
build_path="$patches_path/$build"
if [[ ! "${referenced_builds[@]}" =~ "$build_path" ]]; then
referenced_builds+=("$build_path")
fi
done
if $verbose; then
echo "Referenced builds:"
for build in "${referenced_builds[@]}"; do
echo $build
done
echo ""
fi
# Build list of unreferenced builds
unreferenced_builds=()
for build in "${builds[@]}"; do
if [[ ! "${referenced_builds[@]}" =~ "$build" ]]; then
unreferenced_builds+=("$build")
fi
done
if $verbose; then
echo "Unreferenced builds:"
for build in "${unreferenced_builds[@]}"; do
echo $build
done
echo ""
fi
# Delete unreferenced builds
for build in "${unreferenced_builds[@]}"; do
echo "Removing $build..."
if $echo_output; then
echo rm -rf "$build"
else
rm -rf "$build"
fi
done
}
clean_builds "${version_path}" "${patches_path}"

34
game_mirrors

@ -0,0 +1,34 @@
[
{
"name": "Constructive Tyranny (Germany)",
"url": "http://rxmirror.ctgamehosts.uk/"
},
{
"name": "Constructive Tyranny US (Vint Hill, Virginia, USA)",
"url": "http://mirror.us.tyrant.gg/"
},
{
"name": "Constructive Tyranny US (Piscataway, New Jersey, USA)",
"url": "http://mirror.usa.tyrant.gg/"
},
{
"name": "iTweek (Germany)",
"url": "http://rxp-de1.ts3-server.ch/"
},
{
"name": "CnCFPS.com (Los Angeles, CA, USA)",
"url": "http://rxp-lax2.cncfps.com"
},
{
"name": "TotemArts (Las Vegas, Nevada, USA)",
"url": "http://us-lv.buyvm.renegade-x.com/"
},
{
"name": "TotemArts (New York, New York, USA)",
"url": "http://us-ny.buyvm.renegade-x.com/"
},
{
"name": "TotemArts (Roost, Luxembourg, EU)",
"url": "http://eu-lux.buyvm.renegade-x.com/"
}
]

112
map_builds.sh

@ -0,0 +1,112 @@
# Setup static paths
version_path="${version_data_path}"
patches_path="${patches_data_path}"
# Parse arguments
verbose=false
function print_help() {
echo "Prints out a mapping of the current versions/builds."
echo "Options:"
echo " --help, -h | Displays this help message"
echo " --verbose, -v | Enables verbose output, useful for debugging"
echo " --version-path <path> | Explicitly override version data directory path with specified"
echo " --patches-path <path> | Explicitly override patch data path with specified"
echo ""
echo "Example usage: ./map_builds --echo"
exit 0
}
for arg in "$@"
do
case $arg in
--help|-h)
print_help
;;
--verbose|-v)
verbose=true
shift
;;
--version-path)
version_path="$2"
shift
shift
;;
--patches-path)
patches_path="$2"
shift
shift
;;
esac
done
if $verbose
then
echo "Values:"
echo " patches_path: $patches_path"
echo " version_path: $version_path"
echo ""
fi
# Scans for unreferenced builds, and deletes them if necessary
#
# @param version_file Path to version files containing build information
# @param patches_path Path to the root patches directory on this filesystem
function map_builds() {
version_path="$1"
patches_path="$2"
# Read in list of builds
builds=()
for item in $patches_path/*; do
if [ -f "$item/instructions.json" ]; then
builds+=("$item")
fi
done
if $verbose; then
echo "Builds available:"
for build in "${builds[@]}"; do
echo "$build"
done
echo ""
fi
# Read in referenced builds
referenced_builds=()
for version_file in $version_path/*; do
version_data=$(cat "$version_file")
build=$(echo "$version_data" | jq -r ".game.patch_path")
build_path="$patches_path/$build"
if [[ ! "${referenced_builds[@]}" =~ "$build_path" ]]; then
referenced_builds+=("$build_path")
fi
echo "$(basename $version_file) -> $build"
done
if $verbose; then
echo "Referenced builds:"
for build in "${referenced_builds[@]}"; do
echo $build
done
echo ""
fi
# Build list of unreferenced builds
unreferenced_builds=()
for build in "${builds[@]}"; do
if [[ ! "${referenced_builds[@]}" =~ "$build" ]]; then
unreferenced_builds+=("$build")
fi
done
# Print out unreferenced builds
echo "Unreferenced builds:"
for build in "${unreferenced_builds[@]}"; do
echo $build
done
}
map_builds "${version_path}" "${patches_path}"

145
set_game_branch.sh

@ -0,0 +1,145 @@
# Setup static paths
version_path="${version_data_path}"
patches_path="${patches_data_path}"
# Parse arguments
echo_output=false
minify=false
verbose=false
function print_help() {
echo "Sets the patch path for a given branch."
echo "Options:"
echo " --help, -h | Displays this help message"
echo " --echo, -e, --dry-run | Prints the output to the console, instead of overwriting the file"
echo " --minify, -m | Minifies the JSON result"
echo " --verbose, -v | Enables verbose output, useful for debugging"
echo " --version-path <path> | Explicitly override version data directory path with specified"
echo " --patches-path <path> | Explicitly override patch data path with specified"
echo ""
echo "Example usage: ./set_game_branch --echo release PATCH5464C"
exit 0
}
for arg in "$@"
do
case $arg in
--help|-h)
print_help
;;
--echo|--dry-run|-e)
echo_output=true
shift
;;
--minify|-m)
minify=true
shift
;;
--verbose|-v)
verbose=true
shift
;;
--version-path)
version_path="$2"
shift
shift
;;
--patches-path)
patches_path="$2"
shift
shift
;;
esac
done
# Sanity check parameter count
if [ "$#" -ne 2 ]
then
echo "ERROR: insufficient parameters"
print_help
fi
version_file="${version_path%/}/${1%.json}.json"
patch_path="${2%/}"
if $verbose
then
echo "Values:"
echo " echo_output: $echo_output"
echo " minify: $minify"
echo " patches_path: $patches_path"
echo " version_path: $version_path"
echo " patch_path: $patch_path"
echo " version_file: $version_file"
echo ""
fi
# Sets a Renegade X launcher version branch to point to a Renegade X game patch data package
#
# @param version_file Launcher version file to target/modify
# @param patch_path Relative path from patches_path to target game patch data
# @param patches_path Path to the root patches directory on this filesystem
function set_branch() {
version_file="$1"
patch_path="$2"
patches_path="$3"
metadata_file="${patches_path}/${patch_path}/metadata.json"
# Verify version branch exists
if ! [ -f "$version_file" ]
then
echo "ERROR: version file does not exist: $version_file"
return 1
fi
# Verify patch data exists
if ! [ -f "$metadata_file" ]
then
echo "ERROR: metadata file does not exist: $metadata_file"
return 1
fi
# Get metadata hash
patch_metadata=$(cat "${metadata_file}")
metadata_hash=$(sha256sum ${metadata_file} | awk '{ print toupper($1) }')
# Validate instructions_hash
instructions_real_hash=$(sha256sum "${patches_path}/${patch_path}/instructions.json"| awk '{ print toupper($1) }')
instructions_expected_hash=$(echo "$patch_metadata" | jq -r ".instructions_hash")
if [ "$instructions_expected_hash" != "$instructions_real_hash" ]
then
echo "ERROR: Metadata hash does not match real instructions.json hash. Corrupt upload?"
return 1
fi
# TODO: Verify contents of patch by parsing through instructions.json to check file hashes
# Read in initial version data
version_data=$(cat "${version_file}")
# Set the patch_path
version_data=$(echo "${version_data}" | jq ".game.patch_path = \"${patch_path}\"")
# Set the metadata hash; this is unused for now
version_data=$(echo "${version_data}" | jq ".game.metadata_hash = \"${metadata_hash}\"")
# Merge in metadata into game
game_version_data=$(echo "${version_data}" | jq ".game * ${patch_metadata}")
version_data=$(echo "${version_data}" | jq ".game = ${game_version_data}")
# Minify final JSON if specified
if $minify
then
version_data=$(echo "${version_data}" | jq -c .)
fi
# Write version_data to destination
if $echo_output
then
echo "${version_data}"
else
echo "${version_data}" > ${version_file}
fi
}
set_branch "${version_file}" "${patch_path}" "${patches_path}"

13
sync.sh

@ -0,0 +1,13 @@
#!/bin/bash
lockfile=/home/renx/static.renegade-x.com/sync.lock
{
if ! flock -n 9
then
exit 1
fi
echo Synching...
s3cmd sync --acl-public --add-header="Cache-Control:max-age=0" --config=/home/renx/static.renegade-x.com/.s3cfg-gcloud /home/renx/static.renegade-x.com/data/ s3://static.renegade-x.com/
# "--delete-removed" was removed due to a 400 InvalidArgument error; that functionality needs to be re-added somehow
} 9>"$lockfile"

20
update_mirrors.sh

@ -0,0 +1,20 @@
game_mirrors_file=game_mirrors
static_path="/home/renx/static.renegade-x.com/"
version_path="${static_path}/data/launcher_data/version"
update_mirrors() {
game_mirrors=$(cat "${game_mirrors_file}")
version_file=${version_path}/$1
jq ".game.mirrors = ${game_mirrors}" "${version_file}" > "$version_file.tmp" && mv "${version_file}.tmp" "${version_file}"
}
# Release branches
update_mirrors release.json
update_mirrors server.json
# Staging branches
update_mirrors beta.json
# Temporary / Alpha testing branches
update_mirrors alpha.json
update_mirrors launcher.json
Loading…
Cancel
Save