Guest User

Untitled

a guest
Apr 13th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # Ramdisk populator
  4. RAM_DISK_SIZE=1300m
  5. MOUNT_POINT=/home/monstercraft/Ramdisk_reg
  6. SOURCE_DIR=/olddrive/WORLD_BACKUPS/Minecraft_folder_ram
  7.  
  8. # Does the mount point exist
  9. mkdir -p $MOUNT_POINT;
  10.  
  11. # Create the tmpfs on mount point
  12. mount -o size=$RAM_DISK_SIZE -t tmpfs tmpfs $MOUNT_POINT
  13.  
  14. # Copy the source files to the mounted tmpfs
  15. cp -rp $SOURCE_DIR/* $MOUNT_POINT
  16.  
  17. #######################################################
  18. # +++++++++++ Now Im going to check MySQL +++++++++++ #
  19. # +++++++ because Server will start without it ++++++ #
  20. # +++++++ and throw 40000MB a second of errors ++++++ #
  21. #######################################################
  22.  
  23. USER=derpina
  24. PASS=derpaherp
  25.  
  26. #######################################################
  27. # +++++++++++++++ Important stuff +++++++++++++++++++ #
  28. #######################################################
  29.  
  30. #Invokes the McMyAdmin startup script in a detached screen.
  31. function StartServer {
  32. su monstercraft -c 'cd /home/monstercraft/Monstercraft && screen -dmS Mine ./start.sh'
  33. }
  34.  
  35. # Check if the MySQL server is alive
  36. function CheckServer {
  37. $CMD -u $USER -p$PASS ping | grep -c 'alive'
  38. }
  39.  
  40. CMD=/usr/bin/mysqladmin
  41. START="/etc/init.d/mysqld start"
  42. TRIES=10
  43.  
  44. if [ "$(CheckServer)" != "1" ]; then
  45.  
  46. # Try and start MySQL 10 times
  47. until [ $TRIES -eq 0 ]; do
  48. # Start MySQL
  49. $START
  50. sleep 30
  51.  
  52. # $START will return once MySQL has started, or failed to start
  53. # Did it start?
  54. if [ '$(CheckServer)' == "1" ]; then
  55. # Yippee, start the MC server and exit
  56. StartServer
  57. exit
  58. fi
  59.  
  60. let TRIES=$(( $TRIES -1))
  61. done
  62.  
  63. else
  64. StartServer
  65. fi
Add Comment
Please, Sign In to add comment