TheAtomicAss

Engine-X script for multi-streaming

Dec 16th, 2014
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.06 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Ubu's Engine-X Script
  4. set -x
  5. # set -x should cause the script to run verbosely.  May be useful for tracking
  6. # down bugs, but can also be commented out for cleaner output.
  7.  
  8. # The following variables define the file locations.  Change them however you
  9. # wish, though you might not want to change the NGINX variable.
  10.  
  11. PODCAST=/etc/nginx/podcast.conf
  12. GAMESTREAM=/etc/nginx/game.conf
  13.  
  14. # And here's the meat and potatoes.  This symlinks the desired profile, starts
  15. # the server, waits for you to press enter (which you would do after a stream),
  16. # and then kills the server, and deletes the symlink.  This causes nginx to fail
  17. # to launch on it's own, so no streaming can be done with the wrong profile.
  18.  
  19. get_root()
  20.     # Elevates script to root privilges, as many of the functions
  21.     # require such.  This function was lifted from the Crashplan
  22.     # installer script for Linux.
  23.  
  24.     # To do: How is the recall managed?  Check the source script.
  25.     # May not be needed if script is run separately, as opposed to
  26.     # as a function in a larger script.
  27.  
  28.     ( if [ "${USERNAME}" != "root" ]
  29.         then
  30.             echo "\n\t This script must be run as root."
  31.             echo -n "\n\t Would you like to switch users and run as\
  32.             root? (y/n) [y] "
  33.             read YN
  34.             if [ "x${YN}" == "x" ]
  35.                 then
  36.                     YN=y
  37.             fi
  38.  
  39.             if [ "${YN}" == "y" ]
  40.                 then
  41.                     echo "  switching to root"
  42.                     sudo ${0} recall
  43.                     exit 0
  44.                 else
  45.                     echo "\n\t Cannot continue, exiting..."
  46.                     exit 1
  47.                 fi
  48.         else
  49.             echo "\n\t detected root permissions"
  50.         fi )
  51.  
  52. main_func()
  53.   ( echo " Engine-X should now be running, executing ps aux|grep nginx to confirm:"
  54.     ps aux|grep nginx
  55.     echo "\n\n Press Enter at any time to kill the nginx process"
  56.     read enterKey
  57.     /usr/local/nginx/sbin/nginx -s stop
  58.     echo "\n\n Verifying that nginx is stopped, output should be empty"
  59.     ps aux|grep nginx
  60.     echo "\n End of output."
  61.   )
  62. get_root
  63. if [ $1 = podcast ]
  64.   then
  65.     /usr/local/nginx/sbin/nginx -c $PODCAST
  66.     main_func
  67.   else
  68.     /usr/local/nginx/sbin/nginx -c $GAMESTREAM
  69.     main_func
  70. fi
Add Comment
Please, Sign In to add comment