#!/bin/bash
# Ubu's Engine-X Script
set -x
# set -x should cause the script to run verbosely. May be useful for tracking
# down bugs, but can also be commented out for cleaner output.
# The following variables define the file locations. Change them however you
# wish, though you might not want to change the NGINX variable.
PODCAST=/etc/nginx/podcast.conf
GAMESTREAM=/etc/nginx/game.conf
# And here's the meat and potatoes. This symlinks the desired profile, starts
# the server, waits for you to press enter (which you would do after a stream),
# and then kills the server, and deletes the symlink. This causes nginx to fail
# to launch on it's own, so no streaming can be done with the wrong profile.
get_root()
# Elevates script to root privilges, as many of the functions
# require such. This function was lifted from the Crashplan
# installer script for Linux.
# To do: How is the recall managed? Check the source script.
# May not be needed if script is run separately, as opposed to
# as a function in a larger script.
( if [ "${USERNAME}" != "root" ]
then
echo "\n\t This script must be run as root."
echo -n "\n\t Would you like to switch users and run as\
root? (y/n) [y] "
read YN
if [ "x${YN}" == "x" ]
then
YN=y
fi
if [ "${YN}" == "y" ]
then
echo " switching to root"
sudo ${0} recall
exit 0
else
echo "\n\t Cannot continue, exiting..."
exit 1
fi
else
echo "\n\t detected root permissions"
fi )
main_func()
( echo " Engine-X should now be running, executing ps aux|grep nginx to confirm:"
ps aux|grep nginx
echo "\n\n Press Enter at any time to kill the nginx process"
read enterKey
/usr/local/nginx/sbin/nginx -s stop
echo "\n\n Verifying that nginx is stopped, output should be empty"
ps aux|grep nginx
echo "\n End of output."
)
get_root
if [ $1 = podcast ]
then
/usr/local/nginx/sbin/nginx -c $PODCAST
main_func
else
/usr/local/nginx/sbin/nginx -c $GAMESTREAM
main_func
fi
Comments