Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Change this to the user you want to run steam as
- runAsUser="sdtd";
- # Change this to the location of steamcmd
- steamCMDshLocation="/home/sdtd/steamcmd/steamcmd.sh";
- # You will need to know the location of appinfo.vdf this file in order to delete it, or steam will not get an updated info, it will use cached
- # Refer to the current set location to know where it may be (./Steam/appcache/appinfo.vdf)
- steamAPPINFOvdfLocation="/home/sdtd/Steam/appcache/appinfo.vdf";
- rm ${steamAPPINFOvdfLocation};
- # Get the app info from steam
- infoOutput=$(sudo -H -u ${runAsUser} bash -c "${steamCMDshLocation} +login anonymous +app_info_print 294420 +quit");
- # get the total lines
- tl=$(echo "${infoOutput}" | wc -l | cut -d " " -f 1);
- # Find the line that starts with "294420"
- sl=$(echo "${infoOutput}" | grep -n -m 1 \"294420\" | cut -d ":" -f 1);
- # Move only those lines to the variable we need to use
- sJSON=$(echo "${infoOutput}" | sed -n "${sl},${tl}p");
- # <UPDATE>
- # We need to make some sort of error checking...
- # </UPDATE>
- # Create an array that we need to use to affect lines
- b=();
- # Set the IFS so we can do this by line
- IFS=$'\n';
- # Add all the lines to the Array
- for c in $sJSON; do
- b+=("$c");
- done;
- # Get the total number of lines
- al=${#b[@]};
- # Set the number of the last line in the array
- let ll=$al-1;
- # Work through the array
- for (( i=0; i<${#b[@]}; i++ )); do
- # <UPDATE>
- #
- # Make sure it is not the last line ( Last line will be } anyway and we don't need to do anything with it )
- # Although I did have some extra data at the end before, I need to make sure to clear that out, so before all this even starts, we need to check for the last } and cut out everything before it
- #
- # </UPDATE>
- if [ "$i" != "$ll" ]; then
- # Check for }
- checkReg=`echo ${b[i]} | grep "[\}]"`;
- if [ "$checkReg" ]; then
- # Check if the next line starts with "
- checkReg=`echo ${b[i+1]} | grep "\""`;
- if [ "$checkReg" ]; then
- # Add , if the next line starts with ,
- b[$i]="${b[i]},";
- fi;
- # We are done with this line, move to next line
- continue;
- fi;
- # If we did not pass the last check, then start another check
- # Here we are checking to see if the line has "<something>" in it
- checkReg=`echo ${b[i]} | grep -E "\"[a-zA-Z0-9\s\t \_\-\(\)\.]+\""`;
- if [ "$checkReg" ]; then
- # Find out if there is " space(s)/tabs "
- checkReg=`echo ${b[i]} | grep -E "\"[[:space:]]+\""`;
- if [ "$checkReg" ]; then
- # If We did find the above check then we need to remove the space and add : in that space
- b[$i]=`echo "${b[i]}" | sed -E "s/\"[\s\t ]+\"/\":\"/"`;
- # Now check if the next line has }
- checkReg=`echo ${b[i+1]} | grep -E "[\}]"`;
- if [ ! "$checkReg" ]; then
- # If the next line was not } then we need to add a , at the end
- b[$i]="${b[i]},";
- fi;
- else
- # If there was not a space, then we need to
- b[$i]="${b[i]}:";
- fi;
- fi;
- fi;
- done;
- sJSON="";
- sJSON+="{";
- for (( i=0; i<${#b[@]}; i++ )); do
- sJSON+="${b[i]}";
- done;
- sJSON+="}";
- # Output the compiled JSON file / you can display it using jq for clean display or you could keep the output be sJSON variable if you really wanted to not have to use jq
- echo "${sJSON}"
- # OR YOU CAN USE jq to return a pretty version of this / Just comment the above line and uncomment the below line, this would require you to have jq installed
- #echo "${sJSON}" | jq ".";
- # Example Usage: ( All these Examples do require you to have jq install Ubuntu/Debian: sudo apt-get install jq )
- # getBranches.sh is the name of the script file I have set, just change this to what you name the script file as.
- # 1. This will build a JSON that will seperate each version with build id, time updated, and description
- #sudo ./getBranches.sh | jq ".[].depots.branches | to_entries[] | {"version": .key, "id": .value.buildid, "updated": .value.timeupdated, "desc": .value.description}";
- # 2. This Example shows how you can iterate over all the branches and display the info for them.
- #vout=$(sudo ./getBranches.sh); V=$(echo "${vout}" | jq -r ".[].depots.branches | to_entries[].key"); for a in $V; do echo "Key: $a"; echo "${vout}" | jq -r ".[].depots.branches.\"$a\""; done
- # 3. Get a specific branch you know the name of and return the buildid
- #sudo ./getBranches.sh | jq ".[].depots.branches.\"alpha18.0\".buildid";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement