Advertisement
vbownswow

Untitled

Jan 5th, 2017
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.74 KB | None | 0 0
  1. #!/bin/bash
  2. #date 04-01-2017
  3. #version: 1.0
  4. #author [REDACTED]
  5. #Comment: This script automates the whitelisting and notifying of a minecraft player.
  6. playername="${1}"
  7. email="${2}"
  8. admins="[REDACTED]"
  9. file=/home/minecraft/whitelist.json
  10.  
  11.  
  12. UUID_URL=https://api.mojang.com/users/profiles/minecraft/$1
  13.  
  14. status_code=$(curl -o /dev/null --silent --head --write-out '%{http_code}\n' $UUID_URL)
  15.  
  16. #WHEN PROFILE DOESNT EXCIST EMAIL ADMINS
  17. if [ $status_code = "204" ];
  18. then echo "Error adding player "$1" to the whitelist, player not premium or wrong username?" | mail -s "Whitelisting failed" $admins
  19.  
  20. else
  21. #GET UUID AND CONVERT IT
  22. mojang_output="`wget -qO- $UUID_URL`"
  23. rawUUID=${mojang_output:7:32}
  24. UUID=${rawUUID:0:8}-${rawUUID:8:4}-${rawUUID:12:4}-${rawUUID:16:4}-${rawUUID:20:12}
  25.  
  26. #CHECK IF ALREADY ON THE WHITELIST
  27. if grep -w -q "$UUID" "$file";
  28. then
  29. echo "Error adding player "$1" to the whitelist, player already whitelisted!" | mail -s "Whitelisting failed" $admins
  30. exit;
  31. fi
  32. #ELSE ADD PLAYER TO WHITELIST
  33. sed -i '$ d' "$file"
  34.  
  35. cat <<EOT >> "$file"
  36.   {
  37.     "uuid": "$UUID",
  38.     "name": "$1"
  39.   },
  40. ]
  41. EOT
  42.  
  43. #MAIL USER +´ADMINS THE PLAYER HAS BEEN WHITELISTED
  44.  
  45.        echo -e "Hello! \n  You have been whitelisted at [REDACTED] Because of the automated systems we use it may take up to 10 minutes for the changes to apply. \n  The server-IP is: [REDACTED]. \n  See you ingame! \n  /the admins of[REDACTED] \n \n \n This is an automated email. If you reply to it your responses won't be read. \n Want to contact us? Use our discord server or the feedback form on our website. " |mail -s "welcome to [REDACTED]" $admins $2
  46.        echo "The following player has been whitelisted: $playername " | mail -s "$playername is now whitelisted" $admins
  47. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement