Explorar o código

changed to tabs and messages updates

we use tabs here not spaces.
updated post messages.
requires more error checking
Daniel Gibbs %!s(int64=9) %!d(string=hai) anos
pai
achega
d3c4eef230
Modificáronse 1 ficheiros con 58 adicións e 51 borrados
  1. 58 51
      lgsm/functions/command_postdetails.sh

+ 58 - 51
lgsm/functions/command_postdetails.sh

@@ -31,7 +31,7 @@ postdetails=yes
 # to post to pastebin, or
 #  rustserver@gamerig:~$ posttarget= ./rustserver pd
 # to leave the output on the filesystem.
-posttarget=${posttarget="http://hastebin.com"}
+posttarget=${posttarget="http://pastebin.com"}
 
 # For pastebin, you can set the expiration period.
 # use 1 week as the default, other options are '24h' for a day, etc.
@@ -45,19 +45,19 @@ postexpire="${postexpire="1W"}"
 # for the variable "postdetails" to be defined. -CedarLUG
 
 # source all of the functions defined in the details command
-. "${functionsdir}"/command_details.sh
+command_details.sh
+
+# redefine as command_details.sh changes them
+local commandname="postdetails"
+local commandaction="Postdetails"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 
 fn_bad_tmpfile() {
-	echo "There was a problem creating a temporary file ${tmpfile}."
-	core_exit.sh
+  echo "There was a problem creating a temporary file ${tmpfile}."
+  core_exit.sh
 }
 
 # Rather than a one-pass sed parser, default to using a temporary directory
-
-# Not all game servers possess a tmp directory.  So create it if
-# it doesn't already exist
-mkdir -p "${tmpdir}" 2>&1 >/dev/null
-
 tmpfile="${tmpdir}/postdetails-$(date +"%Y-%d-%m_%H-%M-%S").tmp"
 
 touch "${tmpfile}" || fn_bad_tmpfile
@@ -72,28 +72,28 @@ touch "${tmpfile}" || fn_bad_tmpfile
 # (This was originally a sed one-liner.) -CedarLUG
 
 fn_display_details | sed -e 's/password="[^"]*/password="--stripped--/' |
-                sed -e 's/password "[^"]*/password "--stripped--/' |
-                sed -e 's/password: .*/password: --stripped--/' |
-                sed -e 's/gslt="[^"]*/gslt="--stripped--/' |
-                sed -e 's/gslt "[^"]*/gslt "--stripped--/' |
-                sed -e 's/pushbullettoken="[^"]*/pushbullettoken="--stripped--/' |
-                sed -e 's/pushbullettoken "[^"]*/pushbullettoken "--stripped--/' |
-                sed -e 's/authkey="[^"]*/authkey="--stripped--/' |
-                sed -e 's/authkey "[^"]*/authkey "--stripped--/' |
-                sed -e 's/authkey [A-Za-z0-9]\+/authkey --stripped--/' |
-                sed -e 's/rcts_strAdminPassword="[^"]*/rcts_strAdminPassword="--stripped--/' |
-                sed -e 's/rcts_strAdminPassword "[^"]*/rcts_strAdminPassword "--stripped--/' |
-                sed -e 's/sv_setsteamaccount [A-Za-z0-9]\+/sv_setsteamaccount --stripped--/' |
-                sed -e 's/sv_password="[^"]*/sv_password="--stripped--/' |
-                sed -e 's/sv_password "[^"]*/sv_password "--stripped--/' |
-                sed -e 's/zmq_stats_password="[^"]*/zmq_stats_password="--stripped--/' |
-                sed -e 's/zmq_stats_password "[^"]*/zmq_stats_password "--stripped--/' |
-                sed -e 's/zmq_rcon_password="[^"]*/zmq_rcon_password="--stripped--/' |
-                sed -e 's/zmq_rcon_password "[^"]*/zmq_rcon_password "--stripped--/' |
-                sed -e 's/pass="[^"]*/pass="--stripped--/' |
-                sed -e 's/pass "[^"]*/pass "--stripped--/' |
-                sed -e 's/rconServerPassword="[^"]*/rconServerPassword="--stripped--/' |
-                sed -e 's/rconServerPassword "[^"]*/rconServerPassword "--stripped--/' > "${tmpfile}"
+                  sed -e 's/password "[^"]*/password "--stripped--/' |
+                  sed -e 's/password: .*/password: --stripped--/' |
+                  sed -e 's/gslt="[^"]*/gslt="--stripped--/' |
+                  sed -e 's/gslt "[^"]*/gslt "--stripped--/' |
+                  sed -e 's/pushbullettoken="[^"]*/pushbullettoken="--stripped--/' |
+                  sed -e 's/pushbullettoken "[^"]*/pushbullettoken "--stripped--/' |
+                  sed -e 's/authkey="[^"]*/authkey="--stripped--/' |
+                  sed -e 's/authkey "[^"]*/authkey "--stripped--/' |
+                  sed -e 's/authkey [A-Za-z0-9]\+/authkey --stripped--/' |
+                  sed -e 's/rcts_strAdminPassword="[^"]*/rcts_strAdminPassword="--stripped--/' |
+                  sed -e 's/rcts_strAdminPassword "[^"]*/rcts_strAdminPassword "--stripped--/' |
+                  sed -e 's/sv_setsteamaccount [A-Za-z0-9]\+/sv_setsteamaccount --stripped--/' |
+                  sed -e 's/sv_password="[^"]*/sv_password="--stripped--/' |
+                  sed -e 's/sv_password "[^"]*/sv_password "--stripped--/' |
+                  sed -e 's/zmq_stats_password="[^"]*/zmq_stats_password="--stripped--/' |
+                  sed -e 's/zmq_stats_password "[^"]*/zmq_stats_password "--stripped--/' |
+                  sed -e 's/zmq_rcon_password="[^"]*/zmq_rcon_password="--stripped--/' |
+                  sed -e 's/zmq_rcon_password "[^"]*/zmq_rcon_password "--stripped--/' |
+                  sed -e 's/pass="[^"]*/pass="--stripped--/' |
+                  sed -e 's/pass "[^"]*/pass "--stripped--/' |
+                  sed -e 's/rconServerPassword="[^"]*/rconServerPassword="--stripped--/' |
+                  sed -e 's/rconServerPassword "[^"]*/rconServerPassword "--stripped--/' > "${tmpfile}"
 
 # strip off all console escape codes (colorization)
 sed -i -r "s/[\x1B,\x0B]\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g" "${tmpfile}"
@@ -101,34 +101,41 @@ sed -i -r "s/[\x1B,\x0B]\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g" "${tmpfile}"
 # If the gameserver uses anonymous steam credentials, leave them displayed
 # in the output.  Otherwise, strip these out as well.
 if ! grep -q "^steampass[= ]\"\"" "${tmpfile}" ; then
-	sed -i -e 's/steampass[= ]"[^"]*/steampass "--stripped--/' "${tmpfile}"
+  sed -i -e 's/steampass[= ]"[^"]*/steampass "--stripped--/' "${tmpfile}"
 fi
 if ! grep -q "^steamuser[= ]\"anonymous\"" "${tmpfile}" ; then
-	sed -i -e 's/steamuser[= ]"[^"]*/steamuser "--stripped--/' "${tmpfile}"
+  sed -i -e 's/steamuser[= ]"[^"]*/steamuser "--stripped--/' "${tmpfile}"
 fi
 
+
 if [ "${posttarget}" == "http://pastebin.com" ] ; then
-   # grab the return from 'value' from an initial visit to pastebin.
-   csrftoken=$(curl -s "${posttarget}" |
-           sed -n 's/^.*input type="hidden" name="csrf_token_post" value="\(.*\)".*$/\1/p')
-   #
-   # Use the csrftoken to then post the content.
-   #
-   link=$(curl -s "${posttarget}/post.php" -D - -F "submit_hidden=submit_hidden" \
-	       -F "post_key=${csrftoken}" -F "paste_expire_date=${postexpire}" \
-	       -F "paste_name=${gamename} Debug Info" \
-               -F "paste_format=8" -F "paste_private=0" \
-               -F "paste_type=bash" -F "paste_code=<${tmpfile}" |
-	       awk '/^location: / { print $2 }' | sed "s/\n//g")
+  fn_print_dots "Posting details to pastbin.com for ${postexpire}"
+  sleep 1
+  # grab the return from 'value' from an initial visit to pastebin.
+  csrftoken=$(curl -s "${posttarget}" |
+          sed -n 's/^.*input type="hidden" name="csrf_token_post" value="\(.*\)".*$/\1/p')
+  #
+  # Use the csrftoken to then post the content.
+  #
+  link=$(curl -s "${posttarget}/post.php" -D - -F "submit_hidden=submit_hidden" \
+        -F "post_key=${csrftoken}" -F "paste_expire_date=${postexpire}" \
+        -F "paste_name=${gamename} Debug Info" \
+        -F "paste_format=8" -F "paste_private=0" \
+        -F "paste_type=bash" -F "paste_code=<${tmpfile}" |
+        awk '/^location: / { print $2 }' | sed "s/\n//g")
 
    # Output the resulting link.
-   fn_print_warn_nl "Visit (and verify) the content posted at ${posttarget}${link}"
+  fn_print_ok_nl "Posting details to pastbin.com for ${postexpire}"
+  echo "  * url: ${posttarget}/${link}"
 elif [ "${posttarget}" == "http://hastebin.com" ] ; then
-   # hastebin is a bit simpler.  If successful, the returned result
-   # should look like: {"something":"key"}, putting the reference that
-   # we need in "key".  TODO - error handling. -CedarLUG
-   link=$(curl -s -d "$(<${tmpfile})" "${posttarget}/documents" | cut -d\" -f4)
-   fn_print_warn_nl "Visit (and verify) the content posted at ${posttarget}/${link}"
+  fn_print_dots "Posting details to hastbin.com for ${postexpire}"
+  sleep 1
+  # hastebin is a bit simpler.  If successful, the returned result
+  # should look like: {"something":"key"}, putting the reference that
+  # we need in "key".  TODO - error handling. -CedarLUG
+  link=$(curl -s -d "$(<${tmpfile})" "${posttarget}/documents" | cut -d\" -f4)
+  fn_print_ok_nl "Posting details to hastbin.com for ${postexpire}"
+  echo "  * url: ${posttarget}/${link}"
 else
    fn_print_warn_nl Review the output in "${tmpfile}"
    core_exit.sh