From f4be3620b63780dfc6c8652bdca9c071754fafde Mon Sep 17 00:00:00 2001 From: Kyle Warwick-Mathieu Date: Tue, 24 Feb 2015 03:04:39 -0500 Subject: [PATCH 01/30] Create server-setup.sh With this script you could run this on a fresh system and all the work will be done for you Feel free to contribute --- server-setup.sh | 120 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 server-setup.sh diff --git a/server-setup.sh b/server-setup.sh new file mode 100644 index 0000000..a2558db --- /dev/null +++ b/server-setup.sh @@ -0,0 +1,120 @@ +#!/bin/bash +ROOT_UID="0" +#Please put this script into your home folder +#Check if run as root +if [ "$UID" -ne "$ROOT_UID" ] ; then + echo "You must be root to do that!" + exit 1 +fi + +echo "Hello and welcome to my installation script. I assume you're running this as root?" +echo "Okay! Gotta love when a plan comes together!" +echo "Let me install a few upgrade and packages on your system for you...." +echo "If you already have a package installed, I'll simply skip over it or upgrade it" +clear +apt-get update -y >/dev/null +echo "Updated repo lists...." +echo "Installing package upgrades... go kill some time as this may take a few minutes..." +apt-get upgrade -y >/dev/null +clear +echo "Upgrades complete!" +echo "Now installing required packages..." +apt-get install apache python 2.7 python-twisted git -y >/dev/null +echo "Installing Apache, Python 2.7, Python Twisted and GitHub....." +clear +echo "Where is your Apache config directory?" +echo "For example: /etc/apache2 +read -e APACHEDIR +echo "The path your provided is: $APACHEDIR" +echo "Now I will clone the github repo to the directory of where this script is" +git clone https://github.com/BeanJr/dwc_network_server_emulator +echo "Now that that's out of the way, let's do some apache stuff" +cd $APACHEDIR +echo "I've changed directory to $APACHEDIR" +echo "Creating sites to sites-available for virtual hosting of the server" +echo "changing directory to sites-available" +cd $APACHEDIR/sites-available/ +cat > gamestats2.gs.nintendowifi.net < + ServerAdmin webmaster@localhost + ServerName gamestats2.gs.nintendowifi.net + ServerAlias "gamestats2.gs.nintendowifi.net, gamestats2.gs.nintendowifi.net" + + ProxyPreserveHost On + + ProxyPass / http://127.0.0.1:9002/ + ProxyPassReverse / http://127.0.0.1:9002/ + +EOF + +cat > gamestats.gs.nintendowifi.net < + ServerAdmin webmaster@localhost + ServerName gamestats.gs.nintendowifi.net + ServerAlias "gamestats.gs.nintendowifi.net, gamestats.gs.nintendowifi.net" + ProxyPreserveHost On + ProxyPass / http://127.0.0.1:9002/ + ProxyPassReverse / http://127.0.0.1:9002/ + +EOF + +cat > nas-naswii-dls1-conntest.nintendowifi.net < + ServerAdmin webmaster@localhost + ServerName naswii.nintendowifi.net + ServerAlias "naswii.nintendowifi.net, naswii.nintendowifi.net" + ServerAlias "nas.nintendowifi.net" + ServerAlias "nas.nintendowifi.net, nas.nintendowifi.net" + ServerAlias "dls1.nintendowifi.net" + ServerAlias "dls1.nintendowifi.net, dls1.nintendowifi.net" + ServerAlias "conntest.nintendowifi.net" + ServerAlias "conntest.nintendowifi.net, conntest.nintendowifi.net" + ProxyPreserveHost On + ProxyPass / http://127.0.0.1:9000/ + ProxyPassReverse / http://127.0.0.1:9000/ + +EOF + +cat > sake.gs.nintendowifi.net < + ServerAdmin webmaster@localhost + ServerName sake.gs.nintendowifi.net + ServerAlias sake.gs.nintendowifi.net *.sake.gs.nintendowifi.net + ServerAlias secure.sake.gs.nintendowifi.net + ServerAlias secure.sake.gs.nintendowifi.net *.secure.sake.gs.nintendowifi.net + + ProxyPass / http://127.0.0.1:8000/ + + CustomLog ${APACHE_LOG_DIR}/access.log combined + +EOF + +clear +echo "Okay! Let's hope nothing broke during this process..." +echo "Now let's enable the sites so Apache can use them" +a2ensite gamestats2.gs.nintendowifi.net gamestats.gs.nintendowifi.net nas-naswii-dls1-conntest.nintendowifi.net sake.gs.nintendowifi.net +echo "Now let's enable some modules so we can make all of this work..." +a2enmod proxy.conf proxy_http.load proxy.load +echo "Great! Everything appears to be set up as far as Apache" +service apache2 restart +service apache2 reload +echo "If any errors occour (besides the hostname/server name error) please look into this yourself as my bash scripting knowledge is very limited" +echo "Let's go back to the home directory where all this began" +cd +clear +cd dwc_network_server_emulator +echo "Now, let's set up the admin page login info...." +echo "Please type your user name: " +read -p USR +echo "Please enter the password you want to use: " +read -p PASS +cat > adminpageconf.json < Date: Tue, 24 Feb 2015 05:48:52 -0500 Subject: [PATCH 02/30] Fixed a typo --- server-setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server-setup.sh b/server-setup.sh index a2558db..506313a 100644 --- a/server-setup.sh +++ b/server-setup.sh @@ -19,7 +19,7 @@ apt-get upgrade -y >/dev/null clear echo "Upgrades complete!" echo "Now installing required packages..." -apt-get install apache python 2.7 python-twisted git -y >/dev/null +apt-get install apache python2.7 python-twisted git -y >/dev/null echo "Installing Apache, Python 2.7, Python Twisted and GitHub....." clear echo "Where is your Apache config directory?" From 25c139661a672570a6ccb0cd795c63abc2fa710b Mon Sep 17 00:00:00 2001 From: Kyle Warwick-Mathieu Date: Tue, 24 Feb 2015 15:59:15 -0500 Subject: [PATCH 03/30] Fixed a few more errors and added DNSMasq step and sleep timers --- server-setup.sh | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/server-setup.sh b/server-setup.sh index 506313a..d731bc5 100644 --- a/server-setup.sh +++ b/server-setup.sh @@ -8,10 +8,10 @@ if [ "$UID" -ne "$ROOT_UID" ] ; then fi echo "Hello and welcome to my installation script. I assume you're running this as root?" +sleep 5s echo "Okay! Gotta love when a plan comes together!" echo "Let me install a few upgrade and packages on your system for you...." echo "If you already have a package installed, I'll simply skip over it or upgrade it" -clear apt-get update -y >/dev/null echo "Updated repo lists...." echo "Installing package upgrades... go kill some time as this may take a few minutes..." @@ -19,12 +19,12 @@ apt-get upgrade -y >/dev/null clear echo "Upgrades complete!" echo "Now installing required packages..." -apt-get install apache python2.7 python-twisted git -y >/dev/null -echo "Installing Apache, Python 2.7, Python Twisted and GitHub....." +apt-get install apache2 python2.7 python-twisted git dnsmasq -y >/dev/null +echo "Installing Apache, Python 2.7, Python Twisted, GitHub and DNSMasq....." clear echo "Where is your Apache config directory?" echo "For example: /etc/apache2 -read -e APACHEDIR +read -p APACHEDIR echo "The path your provided is: $APACHEDIR" echo "Now I will clone the github repo to the directory of where this script is" git clone https://github.com/BeanJr/dwc_network_server_emulator @@ -91,6 +91,7 @@ EOF clear echo "Okay! Let's hope nothing broke during this process..." +sleep 5s echo "Now let's enable the sites so Apache can use them" a2ensite gamestats2.gs.nintendowifi.net gamestats.gs.nintendowifi.net nas-naswii-dls1-conntest.nintendowifi.net sake.gs.nintendowifi.net echo "Now let's enable some modules so we can make all of this work..." @@ -98,20 +99,31 @@ a2enmod proxy.conf proxy_http.load proxy.load echo "Great! Everything appears to be set up as far as Apache" service apache2 restart service apache2 reload -echo "If any errors occour (besides the hostname/server name error) please look into this yourself as my bash scripting knowledge is very limited" +echo "If any errors occour besides the hostname or server name error please look into this yourself as my bash scripting knowledge is very limited" +sleep 5s +echo "----------Lets configure DNSMASQ now----------" +sleep 3s +echo "What is your EXTERNAL IP?" +read -p IP +cat >>/etc/dnsmasq.conf < adminpageconf.json < Date: Tue, 24 Feb 2015 16:02:41 -0500 Subject: [PATCH 04/30] fixed a minor error at the ending of the file --- server-setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server-setup.sh b/server-setup.sh index d731bc5..9851d02 100644 --- a/server-setup.sh +++ b/server-setup.sh @@ -127,6 +127,6 @@ echo "Username and password configured!" echo "NOTE: To get to the admin page type in the IP of your server :9009/banhammer" clear echo "Now, I BELIEVE everything should be in working order. If not, you might have to do some troubleshooting" -echo "Assuming my coding hasn't gotten the best of me, you should be in the directory with all the python script along with a new .json file for the admin page info" +echo "Assuming my coding hasnt gotten the best of me, you should be in the directory with all the python script along with a new .json file for the admin page info" echo "I will now exit...." exit 1 From 2cc0f69bb13c5c94d7fce766320b513206d246b2 Mon Sep 17 00:00:00 2001 From: Kyle Warwick-Mathieu Date: Tue, 24 Feb 2015 16:12:56 -0500 Subject: [PATCH 05/30] fixed more errors.... PHEW! --- server-setup.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/server-setup.sh b/server-setup.sh index 9851d02..a34cd5b 100644 --- a/server-setup.sh +++ b/server-setup.sh @@ -23,17 +23,17 @@ apt-get install apache2 python2.7 python-twisted git dnsmasq -y >/dev/null echo "Installing Apache, Python 2.7, Python Twisted, GitHub and DNSMasq....." clear echo "Where is your Apache config directory?" -echo "For example: /etc/apache2 +echo "For example: /etc/apache2" read -p APACHEDIR echo "The path your provided is: $APACHEDIR" echo "Now I will clone the github repo to the directory of where this script is" git clone https://github.com/BeanJr/dwc_network_server_emulator echo "Now that that's out of the way, let's do some apache stuff" -cd $APACHEDIR +cd "$APACHEDIR" echo "I've changed directory to $APACHEDIR" echo "Creating sites to sites-available for virtual hosting of the server" echo "changing directory to sites-available" -cd $APACHEDIR/sites-available/ +cd "$APACHEDIR/sites-available/" cat > gamestats2.gs.nintendowifi.net < ServerAdmin webmaster@localhost @@ -90,11 +90,11 @@ cat > sake.gs.nintendowifi.net < Date: Tue, 24 Feb 2015 16:19:45 -0500 Subject: [PATCH 06/30] Update server-setup.sh --- server-setup.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/server-setup.sh b/server-setup.sh index a34cd5b..a6d066c 100644 --- a/server-setup.sh +++ b/server-setup.sh @@ -34,7 +34,7 @@ echo "I've changed directory to $APACHEDIR" echo "Creating sites to sites-available for virtual hosting of the server" echo "changing directory to sites-available" cd "$APACHEDIR/sites-available/" -cat > gamestats2.gs.nintendowifi.net < /$APACHDRIR/gamestats2.gs.nintendowifi.net < ServerAdmin webmaster@localhost ServerName gamestats2.gs.nintendowifi.net @@ -47,7 +47,7 @@ cat > gamestats2.gs.nintendowifi.net < EOF -cat > gamestats.gs.nintendowifi.net < /$APACHDRIR/gamestats.gs.nintendowifi.net < ServerAdmin webmaster@localhost ServerName gamestats.gs.nintendowifi.net @@ -58,7 +58,7 @@ cat > gamestats.gs.nintendowifi.net < EOF -cat > nas-naswii-dls1-conntest.nintendowifi.net < /$APACHDRIR/nas-naswii-dls1-conntest.nintendowifi.net < ServerAdmin webmaster@localhost ServerName naswii.nintendowifi.net @@ -75,7 +75,7 @@ cat > nas-naswii-dls1-conntest.nintendowifi.net < EOF -cat > sake.gs.nintendowifi.net < /$APACHDRIR/sake.gs.nintendowifi.net < ServerAdmin webmaster@localhost ServerName sake.gs.nintendowifi.net @@ -113,7 +113,7 @@ echo "DNSMasq setup completed!" echo "Let's go back to the home directory where all this began" cd clear -cd dwc_network_server_emulator +cd "dwc_network_server_emulator" echo "Now, let's set up the admin page login info...." sleep 3s echo "Please type your user name: " From ce1b1e9feecf29a82e8304dac80e6c741f4b241c Mon Sep 17 00:00:00 2001 From: Kyle Warwick-Mathieu Date: Tue, 24 Feb 2015 16:23:22 -0500 Subject: [PATCH 07/30] and more fixed..... when will it end?? --- server-setup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server-setup.sh b/server-setup.sh index a6d066c..8eab2a2 100644 --- a/server-setup.sh +++ b/server-setup.sh @@ -24,7 +24,7 @@ echo "Installing Apache, Python 2.7, Python Twisted, GitHub and DNSMasq....." clear echo "Where is your Apache config directory?" echo "For example: /etc/apache2" -read -p APACHEDIR +read -e APACHEDIR echo "The path your provided is: $APACHEDIR" echo "Now I will clone the github repo to the directory of where this script is" git clone https://github.com/BeanJr/dwc_network_server_emulator @@ -104,7 +104,7 @@ sleep 5s echo "----------Lets configure DNSMASQ now----------" sleep 3s echo "What is your EXTERNAL IP?" -read -p IP +read -e IP cat >>/etc/dnsmasq.conf < Date: Tue, 24 Feb 2015 16:27:18 -0500 Subject: [PATCH 08/30] Did some more double-quoting on variables --- server-setup.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server-setup.sh b/server-setup.sh index 8eab2a2..07953e9 100644 --- a/server-setup.sh +++ b/server-setup.sh @@ -34,7 +34,7 @@ echo "I've changed directory to $APACHEDIR" echo "Creating sites to sites-available for virtual hosting of the server" echo "changing directory to sites-available" cd "$APACHEDIR/sites-available/" -cat > /$APACHDRIR/gamestats2.gs.nintendowifi.net < /"$APACHDRIR/gamestats2.gs.nintendowifi.net" < ServerAdmin webmaster@localhost ServerName gamestats2.gs.nintendowifi.net @@ -47,7 +47,7 @@ cat > /$APACHDRIR/gamestats2.gs.nintendowifi.net < EOF -cat > /$APACHDRIR/gamestats.gs.nintendowifi.net < /"$APACHDRIR/gamestats.gs.nintendowifi.net" < ServerAdmin webmaster@localhost ServerName gamestats.gs.nintendowifi.net @@ -58,7 +58,7 @@ cat > /$APACHDRIR/gamestats.gs.nintendowifi.net < EOF -cat > /$APACHDRIR/nas-naswii-dls1-conntest.nintendowifi.net < /"$APACHDRIR/nas-naswii-dls1-conntest.nintendowifi.net" < ServerAdmin webmaster@localhost ServerName naswii.nintendowifi.net @@ -75,7 +75,7 @@ cat > /$APACHDRIR/nas-naswii-dls1-conntest.nintendowifi.net < EOF -cat > /$APACHDRIR/sake.gs.nintendowifi.net < /"$APACHDRIR/sake.gs.nintendowifi.net" < ServerAdmin webmaster@localhost ServerName sake.gs.nintendowifi.net From 860ad6c1efc9e6b2e4af7d74f52eae428ef3fb01 Mon Sep 17 00:00:00 2001 From: Kyle Warwick-Mathieu Date: Mon, 2 Mar 2015 18:18:49 -0500 Subject: [PATCH 09/30] Update server-setup.sh --- server-setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server-setup.sh b/server-setup.sh index 07953e9..a23e432 100644 --- a/server-setup.sh +++ b/server-setup.sh @@ -117,7 +117,7 @@ cd "dwc_network_server_emulator" echo "Now, let's set up the admin page login info...." sleep 3s echo "Please type your user name: " -read -p USR +read -e USR echo "Please enter the password you want to use: " read -s PASS cat > adminpageconf.json < Date: Fri, 6 Mar 2015 01:59:43 -0500 Subject: [PATCH 10/30] added some git fixes for SSL errors --- server-setup.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/server-setup.sh b/server-setup.sh index a23e432..3feb3ef 100644 --- a/server-setup.sh +++ b/server-setup.sh @@ -27,6 +27,7 @@ echo "For example: /etc/apache2" read -e APACHEDIR echo "The path your provided is: $APACHEDIR" echo "Now I will clone the github repo to the directory of where this script is" +git config --global http.sslVerify false git clone https://github.com/BeanJr/dwc_network_server_emulator echo "Now that that's out of the way, let's do some apache stuff" cd "$APACHEDIR" From 17c28898715c1ef7cb00615f5588e6630223a6f0 Mon Sep 17 00:00:00 2001 From: Kyle Warwick-Mathieu Date: Mon, 9 Mar 2015 19:38:11 -0400 Subject: [PATCH 11/30] Updated git clone link --- server-setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server-setup.sh b/server-setup.sh index 3feb3ef..cf3734a 100644 --- a/server-setup.sh +++ b/server-setup.sh @@ -28,7 +28,7 @@ read -e APACHEDIR echo "The path your provided is: $APACHEDIR" echo "Now I will clone the github repo to the directory of where this script is" git config --global http.sslVerify false -git clone https://github.com/BeanJr/dwc_network_server_emulator +git clone https://github.com/kyle95wm/dwc_network_server_emulator echo "Now that that's out of the way, let's do some apache stuff" cd "$APACHEDIR" echo "I've changed directory to $APACHEDIR" From 8773d9b0453b7cb5617dd609fdb115b1113e0cfc Mon Sep 17 00:00:00 2001 From: Kyle Warwick-Mathieu Date: Tue, 24 Mar 2015 00:12:47 -0400 Subject: [PATCH 12/30] Created the uninstaller script This script is highly experimental. Please test. I've also copied/pasted many things and twisted some things from the initial install script --- server-uninstall.sh | 55 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 server-uninstall.sh diff --git a/server-uninstall.sh b/server-uninstall.sh new file mode 100644 index 0000000..ccb153c --- /dev/null +++ b/server-uninstall.sh @@ -0,0 +1,55 @@ +#!/bin/bash +ROOT_UID="0" +#This script is highly experimental and MAY NOT REMOVE EVERYTHING +#Please test! +#Please put this script into your home folder +#Save all your work before running this script as it will do a final reboot +#Check if run as root +#This script will leave the git cloned folder in your home folder +#Feel free to remove it when you're all done +if [ "$UID" -ne "$ROOT_UID" ] ; then + echo "You must be root to do that!" + exit 1 +fi + +echo "Hello and welcome to my uninstall script. I assume you're running this as root?" +sleep 3s +echo "Okay! Gotta love when a plan comes together!" +echo "Where is your Apache config directory?" +echo "For example: /etc/apache2" +echo "No trailing / please as this will break things" +read -e APACHEDIR +echo "The path your provided is: $APACHEDIR/" +cd "$APACHEDIR" +echo "I've changed directory to $APACHEDIR/" +echo "Removing sites in sites-available for virtual hosting of the server" +echo "changing directory to sites-available" +cd "$APACHEDIR/sites-available/" +rm -r -f $APACHEDIR/sites-available/gamestats2.gs.nintendowifi.net +rm -r -f $APACHEDIR/sites-available/gamestats.gs.nintendowifi.net +rm -r -f $APACHEDIR/sites-available/nas-naswii-dls1-conntest.nintendowifi.net +rm -r -f $APACHEDIR/sites-available/sake.gs.nintendowifi.net +clear +echo "Okay! Lets hope nothing broke during this process..." +sleep 5s +echo "Now lets disable the sites...." +a2dissite gamestats2.gs.nintendowifi.net gamestats.gs.nintendowifi.net nas-naswii-dls1-conntest.nintendowifi.net sake.gs.nintendowifi.net +echo "Now lets disable some modules..." +a2dismod proxy.conf proxy_http.load proxy.load +echo "Great! Everything appears to be remove as far as Apache" +service apache2 restart +service apache2 reload +clear +echo "Let me remove some packages from your system...." +echo "If you already have a package remove, I'll simply skip over it" +apt-get remove apache2 python2.7 python-twisted git dnsmasq -y --purge >/dev/null +echo "Removing and purging configurations for Apache, Python, Python Twisted, GitHub and DNSMASQ" +clear +echo "Now, I BELIEVE everything should be in working order. If not, you might have to do some troubleshooting" +echo "Assuming my coding hasnt gotten the best of me, you should be in the directory with all the python script along with a new .json file for the admin page info" +echo "I will now reboot...." +echo "NOTE: I've left the git clone in your home folder. Do whatever you want with it +echo "Rebooting in 15 seconds...." +sleep 15s +reboot +exit 1 From b5bb8e773a946ae5a1532c8d92a1b8042cfd189c Mon Sep 17 00:00:00 2001 From: Dennis Simpson Date: Tue, 24 Mar 2015 15:05:51 -0400 Subject: [PATCH 13/30] Update server-setup.sh Corrected variable name from APACHDRIR to APACHEDIR wherever found --- server-setup.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server-setup.sh b/server-setup.sh index cf3734a..d7cd6a8 100644 --- a/server-setup.sh +++ b/server-setup.sh @@ -35,7 +35,7 @@ echo "I've changed directory to $APACHEDIR" echo "Creating sites to sites-available for virtual hosting of the server" echo "changing directory to sites-available" cd "$APACHEDIR/sites-available/" -cat > /"$APACHDRIR/gamestats2.gs.nintendowifi.net" < /"$APACHEDIR/gamestats2.gs.nintendowifi.net" < ServerAdmin webmaster@localhost ServerName gamestats2.gs.nintendowifi.net @@ -48,7 +48,7 @@ cat > /"$APACHDRIR/gamestats2.gs.nintendowifi.net" < EOF -cat > /"$APACHDRIR/gamestats.gs.nintendowifi.net" < /"$APACHEDIR/gamestats.gs.nintendowifi.net" < ServerAdmin webmaster@localhost ServerName gamestats.gs.nintendowifi.net @@ -59,7 +59,7 @@ cat > /"$APACHDRIR/gamestats.gs.nintendowifi.net" < EOF -cat > /"$APACHDRIR/nas-naswii-dls1-conntest.nintendowifi.net" < /"$APACHEDIR/nas-naswii-dls1-conntest.nintendowifi.net" < ServerAdmin webmaster@localhost ServerName naswii.nintendowifi.net @@ -76,7 +76,7 @@ cat > /"$APACHDRIR/nas-naswii-dls1-conntest.nintendowifi.net" < EOF -cat > /"$APACHDRIR/sake.gs.nintendowifi.net" < /"$APACHEDIR/sake.gs.nintendowifi.net" < ServerAdmin webmaster@localhost ServerName sake.gs.nintendowifi.net From 6b99ad1c02a749c48c23926277114f783f6e01f7 Mon Sep 17 00:00:00 2001 From: Dennis Simpson Date: Tue, 24 Mar 2015 15:09:44 -0400 Subject: [PATCH 14/30] Update server-uninstall.sh Added missing closing quote at end of line 51 and removed superfluous exit at end of script. --- server-uninstall.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/server-uninstall.sh b/server-uninstall.sh index ccb153c..8c9eaf0 100644 --- a/server-uninstall.sh +++ b/server-uninstall.sh @@ -48,8 +48,7 @@ clear echo "Now, I BELIEVE everything should be in working order. If not, you might have to do some troubleshooting" echo "Assuming my coding hasnt gotten the best of me, you should be in the directory with all the python script along with a new .json file for the admin page info" echo "I will now reboot...." -echo "NOTE: I've left the git clone in your home folder. Do whatever you want with it +echo "NOTE: I've left the git clone in your home folder. Do whatever you want with it" echo "Rebooting in 15 seconds...." sleep 15s reboot -exit 1 From 9a75d8fd6607c82e1de040e2d1d5161b912e08d5 Mon Sep 17 00:00:00 2001 From: Kyle Warwick-Mathieu Date: Tue, 24 Mar 2015 21:01:38 -0400 Subject: [PATCH 15/30] Removed prompt for APACHEDIR variable and fixed some path problems --- server-setup.sh | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/server-setup.sh b/server-setup.sh index d7cd6a8..db8a9b7 100644 --- a/server-setup.sh +++ b/server-setup.sh @@ -1,5 +1,6 @@ #!/bin/bash ROOT_UID="0" +APACHEDIR=/etc/apache2 #Please put this script into your home folder #Check if run as root if [ "$UID" -ne "$ROOT_UID" ] ; then @@ -22,20 +23,13 @@ echo "Now installing required packages..." apt-get install apache2 python2.7 python-twisted git dnsmasq -y >/dev/null echo "Installing Apache, Python 2.7, Python Twisted, GitHub and DNSMasq....." clear -echo "Where is your Apache config directory?" -echo "For example: /etc/apache2" -read -e APACHEDIR -echo "The path your provided is: $APACHEDIR" echo "Now I will clone the github repo to the directory of where this script is" git config --global http.sslVerify false git clone https://github.com/kyle95wm/dwc_network_server_emulator echo "Now that that's out of the way, let's do some apache stuff" -cd "$APACHEDIR" -echo "I've changed directory to $APACHEDIR" echo "Creating sites to sites-available for virtual hosting of the server" echo "changing directory to sites-available" -cd "$APACHEDIR/sites-available/" -cat > /"$APACHEDIR/gamestats2.gs.nintendowifi.net" < "$APACHEDIR/sites-available/gamestats2.gs.nintendowifi.net" < ServerAdmin webmaster@localhost ServerName gamestats2.gs.nintendowifi.net @@ -48,7 +42,7 @@ cat > /"$APACHEDIR/gamestats2.gs.nintendowifi.net" < EOF -cat > /"$APACHEDIR/gamestats.gs.nintendowifi.net" < "$APACHEDIR/sites-available/gamestats.gs.nintendowifi.net" < ServerAdmin webmaster@localhost ServerName gamestats.gs.nintendowifi.net @@ -59,7 +53,7 @@ cat > /"$APACHEDIR/gamestats.gs.nintendowifi.net" < EOF -cat > /"$APACHEDIR/nas-naswii-dls1-conntest.nintendowifi.net" < "$APACHEDIR/sites-available/nas-naswii-dls1-conntest.nintendowifi.net" < ServerAdmin webmaster@localhost ServerName naswii.nintendowifi.net @@ -76,7 +70,7 @@ cat > /"$APACHEDIR/nas-naswii-dls1-conntest.nintendowifi.net" < EOF -cat > /"$APACHEDIR/sake.gs.nintendowifi.net" < "$APACHEDIR/sites-available/sake.gs.nintendowifi.net" < ServerAdmin webmaster@localhost ServerName sake.gs.nintendowifi.net From c90407b2de1e0b441b95ef2da9e72a17325ca21f Mon Sep 17 00:00:00 2001 From: Kyle Warwick-Mathieu Date: Thu, 26 Mar 2015 00:16:33 -0400 Subject: [PATCH 16/30] Delete server-uninstall.sh This caused my install of Ubuntu to become completely useless --- server-uninstall.sh | 54 --------------------------------------------- 1 file changed, 54 deletions(-) delete mode 100644 server-uninstall.sh diff --git a/server-uninstall.sh b/server-uninstall.sh deleted file mode 100644 index 8c9eaf0..0000000 --- a/server-uninstall.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/bash -ROOT_UID="0" -#This script is highly experimental and MAY NOT REMOVE EVERYTHING -#Please test! -#Please put this script into your home folder -#Save all your work before running this script as it will do a final reboot -#Check if run as root -#This script will leave the git cloned folder in your home folder -#Feel free to remove it when you're all done -if [ "$UID" -ne "$ROOT_UID" ] ; then - echo "You must be root to do that!" - exit 1 -fi - -echo "Hello and welcome to my uninstall script. I assume you're running this as root?" -sleep 3s -echo "Okay! Gotta love when a plan comes together!" -echo "Where is your Apache config directory?" -echo "For example: /etc/apache2" -echo "No trailing / please as this will break things" -read -e APACHEDIR -echo "The path your provided is: $APACHEDIR/" -cd "$APACHEDIR" -echo "I've changed directory to $APACHEDIR/" -echo "Removing sites in sites-available for virtual hosting of the server" -echo "changing directory to sites-available" -cd "$APACHEDIR/sites-available/" -rm -r -f $APACHEDIR/sites-available/gamestats2.gs.nintendowifi.net -rm -r -f $APACHEDIR/sites-available/gamestats.gs.nintendowifi.net -rm -r -f $APACHEDIR/sites-available/nas-naswii-dls1-conntest.nintendowifi.net -rm -r -f $APACHEDIR/sites-available/sake.gs.nintendowifi.net -clear -echo "Okay! Lets hope nothing broke during this process..." -sleep 5s -echo "Now lets disable the sites...." -a2dissite gamestats2.gs.nintendowifi.net gamestats.gs.nintendowifi.net nas-naswii-dls1-conntest.nintendowifi.net sake.gs.nintendowifi.net -echo "Now lets disable some modules..." -a2dismod proxy.conf proxy_http.load proxy.load -echo "Great! Everything appears to be remove as far as Apache" -service apache2 restart -service apache2 reload -clear -echo "Let me remove some packages from your system...." -echo "If you already have a package remove, I'll simply skip over it" -apt-get remove apache2 python2.7 python-twisted git dnsmasq -y --purge >/dev/null -echo "Removing and purging configurations for Apache, Python, Python Twisted, GitHub and DNSMASQ" -clear -echo "Now, I BELIEVE everything should be in working order. If not, you might have to do some troubleshooting" -echo "Assuming my coding hasnt gotten the best of me, you should be in the directory with all the python script along with a new .json file for the admin page info" -echo "I will now reboot...." -echo "NOTE: I've left the git clone in your home folder. Do whatever you want with it" -echo "Rebooting in 15 seconds...." -sleep 15s -reboot From edc9e9f33504beaa8cc1b763184a4ee2de9aee73 Mon Sep 17 00:00:00 2001 From: Kyle Warwick-Mathieu Date: Thu, 26 Mar 2015 00:19:22 -0400 Subject: [PATCH 17/30] Create gamestats2.gs.nintendowifi.net --- apache-hosts/gamestats2.gs.nintendowifi.net | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 apache-hosts/gamestats2.gs.nintendowifi.net diff --git a/apache-hosts/gamestats2.gs.nintendowifi.net b/apache-hosts/gamestats2.gs.nintendowifi.net new file mode 100644 index 0000000..3f79350 --- /dev/null +++ b/apache-hosts/gamestats2.gs.nintendowifi.net @@ -0,0 +1,10 @@ + + ServerAdmin webmaster@localhost + ServerName gamestats2.gs.nintendowifi.net + ServerAlias "gamestats2.gs.nintendowifi.net, gamestats2.gs.nintendowifi.net" + + ProxyPreserveHost On + + ProxyPass / http://127.0.0.1:9002/ + ProxyPassReverse / http://127.0.0.1:9002/ + From 0abc7fd347c2809bf19e099b3f03865a9ab37081 Mon Sep 17 00:00:00 2001 From: Kyle Warwick-Mathieu Date: Thu, 26 Mar 2015 00:20:11 -0400 Subject: [PATCH 18/30] Create gamestats.gs.nintendowifi.net --- apache-hosts/gamestats.gs.nintendowifi.net | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 apache-hosts/gamestats.gs.nintendowifi.net diff --git a/apache-hosts/gamestats.gs.nintendowifi.net b/apache-hosts/gamestats.gs.nintendowifi.net new file mode 100644 index 0000000..dc67950 --- /dev/null +++ b/apache-hosts/gamestats.gs.nintendowifi.net @@ -0,0 +1,8 @@ + + ServerAdmin webmaster@localhost + ServerName gamestats.gs.nintendowifi.net + ServerAlias "gamestats.gs.nintendowifi.net, gamestats.gs.nintendowifi.net" + ProxyPreserveHost On + ProxyPass / http://127.0.0.1:9002/ + ProxyPassReverse / http://127.0.0.1:9002/ + From 0a765e41d039d20d1be2e10267848f08e93d771d Mon Sep 17 00:00:00 2001 From: Kyle Warwick-Mathieu Date: Thu, 26 Mar 2015 00:20:47 -0400 Subject: [PATCH 19/30] Create nas-naswii-dls1-conntest.nintendowifi.net --- .../nas-naswii-dls1-conntest.nintendowifi.net | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 apache-hosts/nas-naswii-dls1-conntest.nintendowifi.net diff --git a/apache-hosts/nas-naswii-dls1-conntest.nintendowifi.net b/apache-hosts/nas-naswii-dls1-conntest.nintendowifi.net new file mode 100644 index 0000000..f7f5537 --- /dev/null +++ b/apache-hosts/nas-naswii-dls1-conntest.nintendowifi.net @@ -0,0 +1,14 @@ + + ServerAdmin webmaster@localhost + ServerName naswii.nintendowifi.net + ServerAlias "naswii.nintendowifi.net, naswii.nintendowifi.net" + ServerAlias "nas.nintendowifi.net" + ServerAlias "nas.nintendowifi.net, nas.nintendowifi.net" + ServerAlias "dls1.nintendowifi.net" + ServerAlias "dls1.nintendowifi.net, dls1.nintendowifi.net" + ServerAlias "conntest.nintendowifi.net" + ServerAlias "conntest.nintendowifi.net, conntest.nintendowifi.net" + ProxyPreserveHost On + ProxyPass / http://127.0.0.1:9000/ + ProxyPassReverse / http://127.0.0.1:9000/ + From 183776bd63ae6a0f595b7a61377bfb3973d2e6fe Mon Sep 17 00:00:00 2001 From: Kyle Warwick-Mathieu Date: Thu, 26 Mar 2015 00:21:16 -0400 Subject: [PATCH 20/30] Create sake.gs.nintendowifi.net --- apache-hosts/sake.gs.nintendowifi.net | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 apache-hosts/sake.gs.nintendowifi.net diff --git a/apache-hosts/sake.gs.nintendowifi.net b/apache-hosts/sake.gs.nintendowifi.net new file mode 100644 index 0000000..ab854a6 --- /dev/null +++ b/apache-hosts/sake.gs.nintendowifi.net @@ -0,0 +1,11 @@ + + ServerAdmin webmaster@localhost + ServerName sake.gs.nintendowifi.net + ServerAlias sake.gs.nintendowifi.net *.sake.gs.nintendowifi.net + ServerAlias secure.sake.gs.nintendowifi.net + ServerAlias secure.sake.gs.nintendowifi.net *.secure.sake.gs.nintendowifi.net + + ProxyPass / http://127.0.0.1:8000/ + + CustomLog ${APACHE_LOG_DIR}/access.log combined + From e359ad44fe2bc813b9648954ff38979fff077dec Mon Sep 17 00:00:00 2001 From: Kyle Warwick-Mathieu Date: Thu, 26 Mar 2015 00:39:13 -0400 Subject: [PATCH 21/30] Re-worked the script and cleaned it up a bit I'm hoping this is going to be my last commit for this project for a very long time. I removed the github package installation part and now this script must stay in this project folder since it uses absolute paths now --- server-setup.sh | 98 +++++++++++++------------------------------------ 1 file changed, 26 insertions(+), 72 deletions(-) diff --git a/server-setup.sh b/server-setup.sh index db8a9b7..3a21a20 100644 --- a/server-setup.sh +++ b/server-setup.sh @@ -1,7 +1,16 @@ #!/bin/bash +#Variables used by the script in various sections to pre-fill long commandds ROOT_UID="0" -APACHEDIR=/etc/apache2 -#Please put this script into your home folder +apache="/etc/apache2/sites-available" +vh="./apache-hosts" +vh1="gamestats2.gs.nintendowifi.net" +vh2="gamestats.gs.nintendowifi.net" +vh3="nas-naswii-dls1-conntest.nintendowifi.net" +vh4="sake.gs.nintendowifi.net" +mod1="proxy.conf" +mod2="proxy_http.load" +mod3="proxy.load" +#Don't forget to install the git package before running this script #Check if run as root if [ "$UID" -ne "$ROOT_UID" ] ; then echo "You must be root to do that!" @@ -20,82 +29,30 @@ apt-get upgrade -y >/dev/null clear echo "Upgrades complete!" echo "Now installing required packages..." -apt-get install apache2 python2.7 python-twisted git dnsmasq -y >/dev/null -echo "Installing Apache, Python 2.7, Python Twisted, GitHub and DNSMasq....." +apt-get install apache2 python2.7 python-twisted dnsmasq -y >/dev/null +echo "Installing Apache, Python 2.7, Python Twisted and DNSMasq....." clear -echo "Now I will clone the github repo to the directory of where this script is" -git config --global http.sslVerify false -git clone https://github.com/kyle95wm/dwc_network_server_emulator echo "Now that that's out of the way, let's do some apache stuff" -echo "Creating sites to sites-available for virtual hosting of the server" -echo "changing directory to sites-available" -cat > "$APACHEDIR/sites-available/gamestats2.gs.nintendowifi.net" < - ServerAdmin webmaster@localhost - ServerName gamestats2.gs.nintendowifi.net - ServerAlias "gamestats2.gs.nintendowifi.net, gamestats2.gs.nintendowifi.net" - - ProxyPreserveHost On - - ProxyPass / http://127.0.0.1:9002/ - ProxyPassReverse / http://127.0.0.1:9002/ - -EOF - -cat > "$APACHEDIR/sites-available/gamestats.gs.nintendowifi.net" < - ServerAdmin webmaster@localhost - ServerName gamestats.gs.nintendowifi.net - ServerAlias "gamestats.gs.nintendowifi.net, gamestats.gs.nintendowifi.net" - ProxyPreserveHost On - ProxyPass / http://127.0.0.1:9002/ - ProxyPassReverse / http://127.0.0.1:9002/ - -EOF - -cat > "$APACHEDIR/sites-available/nas-naswii-dls1-conntest.nintendowifi.net" < - ServerAdmin webmaster@localhost - ServerName naswii.nintendowifi.net - ServerAlias "naswii.nintendowifi.net, naswii.nintendowifi.net" - ServerAlias "nas.nintendowifi.net" - ServerAlias "nas.nintendowifi.net, nas.nintendowifi.net" - ServerAlias "dls1.nintendowifi.net" - ServerAlias "dls1.nintendowifi.net, dls1.nintendowifi.net" - ServerAlias "conntest.nintendowifi.net" - ServerAlias "conntest.nintendowifi.net, conntest.nintendowifi.net" - ProxyPreserveHost On - ProxyPass / http://127.0.0.1:9000/ - ProxyPassReverse / http://127.0.0.1:9000/ - -EOF - -cat > "$APACHEDIR/sites-available/sake.gs.nintendowifi.net" < - ServerAdmin webmaster@localhost - ServerName sake.gs.nintendowifi.net - ServerAlias sake.gs.nintendowifi.net *.sake.gs.nintendowifi.net - ServerAlias secure.sake.gs.nintendowifi.net - ServerAlias secure.sake.gs.nintendowifi.net *.secure.sake.gs.nintendowifi.net - - ProxyPass / http://127.0.0.1:8000/ - - CustomLog ${APACHE_LOG_DIR}/access.log combined - -EOF - +echo "Copying virtual hosts to sites-available for virtual hosting of the server" +cp ./$vh/$vh1 $apache/$vh1 +cp ./$vh/$vh2 $apache/$vh2 +cp ./$vh/$vh3 $apache/$vh3 +cp ./$vh/$vh4 $apache/$vh4 +sleep 5s clear echo "Okay! Lets hope nothing broke during this process..." sleep 5s echo "Now lets enable the sites so Apache can use them" -a2ensite gamestats2.gs.nintendowifi.net gamestats.gs.nintendowifi.net nas-naswii-dls1-conntest.nintendowifi.net sake.gs.nintendowifi.net +a2ensite $vh1 $vh2 $vh3 $vh4 echo "Now lets enable some modules so we can make all of this work..." -a2enmod proxy.conf proxy_http.load proxy.load +a2enmod $mod1 $mod2 $mod3 echo "Great! Everything appears to be set up as far as Apache" service apache2 restart service apache2 reload -echo "If any errors occour besides the hostname or server name error please look into this yourself as my bash scripting knowledge is very limited" +apachectl graceful +echo "If any errors occour besides the hostname or server name error please look into this yourself" sleep 5s +clear echo "----------Lets configure DNSMASQ now----------" sleep 3s echo "What is your EXTERNAL IP?" @@ -105,17 +62,14 @@ address=/nintendowifi.net/$IP EOF clear echo "DNSMasq setup completed!" -echo "Let's go back to the home directory where all this began" -cd clear -cd "dwc_network_server_emulator" echo "Now, let's set up the admin page login info...." sleep 3s echo "Please type your user name: " read -e USR echo "Please enter the password you want to use: " read -s PASS -cat > adminpageconf.json < ./adminpageconf.json < Date: Thu, 26 Mar 2015 00:56:04 -0400 Subject: [PATCH 22/30] Update server-setup.sh --- server-setup.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server-setup.sh b/server-setup.sh index 3a21a20..f82768e 100644 --- a/server-setup.sh +++ b/server-setup.sh @@ -22,14 +22,14 @@ sleep 5s echo "Okay! Gotta love when a plan comes together!" echo "Let me install a few upgrade and packages on your system for you...." echo "If you already have a package installed, I'll simply skip over it or upgrade it" -apt-get update -y >/dev/null +apt-get update -y --fix-missing echo "Updated repo lists...." echo "Installing package upgrades... go kill some time as this may take a few minutes..." -apt-get upgrade -y >/dev/null +apt-get upgrade -y clear echo "Upgrades complete!" echo "Now installing required packages..." -apt-get install apache2 python2.7 python-twisted dnsmasq -y >/dev/null +apt-get install apache2 python2.7 python-twisted dnsmasq -y echo "Installing Apache, Python 2.7, Python Twisted and DNSMasq....." clear echo "Now that that's out of the way, let's do some apache stuff" From 59a829e72317149f0fb08a3603cd4a967fb2fc40 Mon Sep 17 00:00:00 2001 From: Kyle Warwick-Mathieu Date: Thu, 26 Mar 2015 01:13:56 -0400 Subject: [PATCH 23/30] Added fourth Apache module as a fallback --- server-setup.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server-setup.sh b/server-setup.sh index f82768e..d79c501 100644 --- a/server-setup.sh +++ b/server-setup.sh @@ -10,6 +10,7 @@ vh4="sake.gs.nintendowifi.net" mod1="proxy.conf" mod2="proxy_http.load" mod3="proxy.load" +mod4="proxy" #This is a fallback module for use with OS's that don't support mod1, mod2 or mod3 #Don't forget to install the git package before running this script #Check if run as root if [ "$UID" -ne "$ROOT_UID" ] ; then @@ -45,7 +46,7 @@ sleep 5s echo "Now lets enable the sites so Apache can use them" a2ensite $vh1 $vh2 $vh3 $vh4 echo "Now lets enable some modules so we can make all of this work..." -a2enmod $mod1 $mod2 $mod3 +a2enmod $mod1 $mod2 $mod3 $mod4 echo "Great! Everything appears to be set up as far as Apache" service apache2 restart service apache2 reload From 72049044c233f89ec6ca580644ae805e3f92f9d0 Mon Sep 17 00:00:00 2001 From: Kyle Warwick-Mathieu Date: Thu, 26 Mar 2015 01:35:55 -0400 Subject: [PATCH 24/30] Added a restart to dnsmasq service --- server-setup.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/server-setup.sh b/server-setup.sh index d79c501..30ea0dc 100644 --- a/server-setup.sh +++ b/server-setup.sh @@ -64,6 +64,7 @@ EOF clear echo "DNSMasq setup completed!" clear +service dnsmasq restart echo "Now, let's set up the admin page login info...." sleep 3s echo "Please type your user name: " From fbabd13798dd00f28e3be1c35da34ff748750aa3 Mon Sep 17 00:00:00 2001 From: Kyle Warwick-Mathieu Date: Thu, 26 Mar 2015 19:34:18 -0400 Subject: [PATCH 25/30] Update server-setup.sh --- server-setup.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/server-setup.sh b/server-setup.sh index 30ea0dc..10b117f 100644 --- a/server-setup.sh +++ b/server-setup.sh @@ -11,6 +11,7 @@ mod1="proxy.conf" mod2="proxy_http.load" mod3="proxy.load" mod4="proxy" #This is a fallback module for use with OS's that don't support mod1, mod2 or mod3 +cp="/etc/apache2/sites-enabled" #Don't forget to install the git package before running this script #Check if run as root if [ "$UID" -ne "$ROOT_UID" ] ; then @@ -40,11 +41,15 @@ cp ./$vh/$vh2 $apache/$vh2 cp ./$vh/$vh3 $apache/$vh3 cp ./$vh/$vh4 $apache/$vh4 sleep 5s +echo "Copying virtual hosts to sites-enabled for virtual hosting of the server" +cp ./$vh/$vh1 $cp/$vh1 +cp ./$vh/$vh2 $cp/$vh2 +cp ./$vh/$vh3 $cp/$vh3 +cp ./$vh/$vh4 $cp/$vh4 +sleep 5s clear echo "Okay! Lets hope nothing broke during this process..." sleep 5s -echo "Now lets enable the sites so Apache can use them" -a2ensite $vh1 $vh2 $vh3 $vh4 echo "Now lets enable some modules so we can make all of this work..." a2enmod $mod1 $mod2 $mod3 $mod4 echo "Great! Everything appears to be set up as far as Apache" From a9c132eb4409cf1be3fd6be77197e8e76f49f0b4 Mon Sep 17 00:00:00 2001 From: Kyle Warwick-Mathieu Date: Thu, 9 Apr 2015 21:29:08 -0400 Subject: [PATCH 26/30] Added a real fallback to $mod4 (aka proxy mod) I decided to use an if statement (hasn't been tested) to enable mod4 only if the first 3 mods fail to enable --- server-setup.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/server-setup.sh b/server-setup.sh index 10b117f..92a80bd 100644 --- a/server-setup.sh +++ b/server-setup.sh @@ -52,6 +52,9 @@ echo "Okay! Lets hope nothing broke during this process..." sleep 5s echo "Now lets enable some modules so we can make all of this work..." a2enmod $mod1 $mod2 $mod3 $mod4 +if [ $? != "0"] then: + a2enmod $mod4 +fi echo "Great! Everything appears to be set up as far as Apache" service apache2 restart service apache2 reload From 78c0c0a436da1aa6aa7f2197251f8546b74383b5 Mon Sep 17 00:00:00 2001 From: Kyle Warwick-Mathieu Date: Thu, 9 Apr 2015 21:30:12 -0400 Subject: [PATCH 27/30] Removed mod4 from regular a2enmod line --- server-setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server-setup.sh b/server-setup.sh index 92a80bd..17f7b5e 100644 --- a/server-setup.sh +++ b/server-setup.sh @@ -51,7 +51,7 @@ clear echo "Okay! Lets hope nothing broke during this process..." sleep 5s echo "Now lets enable some modules so we can make all of this work..." -a2enmod $mod1 $mod2 $mod3 $mod4 +a2enmod $mod1 $mod2 $mod3 if [ $? != "0"] then: a2enmod $mod4 fi From 61b364d34efb34fa66fd8be92f645542a0874cae Mon Sep 17 00:00:00 2001 From: Kyle Warwick-Mathieu Date: Thu, 9 Apr 2015 21:31:37 -0400 Subject: [PATCH 28/30] Fixed if statement --- server-setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server-setup.sh b/server-setup.sh index 17f7b5e..09fd4bf 100644 --- a/server-setup.sh +++ b/server-setup.sh @@ -52,7 +52,7 @@ echo "Okay! Lets hope nothing broke during this process..." sleep 5s echo "Now lets enable some modules so we can make all of this work..." a2enmod $mod1 $mod2 $mod3 -if [ $? != "0"] then: +if [ $? != "0" ] ; then a2enmod $mod4 fi echo "Great! Everything appears to be set up as far as Apache" From d92013a9d69bd8d1a51e3ae3885ab8504b05d4e0 Mon Sep 17 00:00:00 2001 From: Kyle Warwick-Mathieu Date: Thu, 9 Apr 2015 21:38:33 -0400 Subject: [PATCH 29/30] Fixed Apache's FQDN error and added variable to top of file --- server-setup.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/server-setup.sh b/server-setup.sh index 09fd4bf..20b3034 100644 --- a/server-setup.sh +++ b/server-setup.sh @@ -12,6 +12,7 @@ mod2="proxy_http.load" mod3="proxy.load" mod4="proxy" #This is a fallback module for use with OS's that don't support mod1, mod2 or mod3 cp="/etc/apache2/sites-enabled" +fqdn="localhost" #Don't forget to install the git package before running this script #Check if run as root if [ "$UID" -ne "$ROOT_UID" ] ; then @@ -56,6 +57,10 @@ if [ $? != "0" ] ; then a2enmod $mod4 fi echo "Great! Everything appears to be set up as far as Apache" +echo "Fixing that nagging Apache FQDN error...." +cat >>/etc/apache2/apache2.conf < Date: Thu, 9 Apr 2015 22:18:26 -0400 Subject: [PATCH 30/30] Add comments to script to make it easier to understand for those not experienced enough with bash scripting --- server-setup.sh | 63 +++++++++++++++++++++++++------------------------ 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/server-setup.sh b/server-setup.sh index 20b3034..b97bd6f 100644 --- a/server-setup.sh +++ b/server-setup.sh @@ -1,43 +1,44 @@ #!/bin/bash #Variables used by the script in various sections to pre-fill long commandds ROOT_UID="0" -apache="/etc/apache2/sites-available" -vh="./apache-hosts" -vh1="gamestats2.gs.nintendowifi.net" -vh2="gamestats.gs.nintendowifi.net" -vh3="nas-naswii-dls1-conntest.nintendowifi.net" -vh4="sake.gs.nintendowifi.net" -mod1="proxy.conf" -mod2="proxy_http.load" -mod3="proxy.load" +apache="/etc/apache2/sites-available" #This is the directory where sites are kept in case they need to be disabled in Apache +vh="./apache-hosts" #This folder is in the root directory of this script and is required for it to copy the files over +vh1="gamestats2.gs.nintendowifi.net" #This is the first virtual host file +vh2="gamestats.gs.nintendowifi.net" #This is the second virtual host file +vh3="nas-naswii-dls1-conntest.nintendowifi.net" #This is the third virtual host file +vh4="sake.gs.nintendowifi.net" #This is the fourth virtual host file +mod1="proxy.conf" #This is a proxy mod that is dependent on the other 2 +mod2="proxy_http.load" #This is related to mod1 +mod3="proxy.load" #This is related to mod1 and mod2 mod4="proxy" #This is a fallback module for use with OS's that don't support mod1, mod2 or mod3 -cp="/etc/apache2/sites-enabled" -fqdn="localhost" +cp="/etc/apache2/sites-enabled" #This is the directory where sites are usually enabled using a2enmod +fqdn="localhost" #This variable fixes the fqdn error in Apache #Don't forget to install the git package before running this script #Check if run as root -if [ "$UID" -ne "$ROOT_UID" ] ; then - echo "You must be root to do that!" - exit 1 -fi +if [ "$UID" -ne "$ROOT_UID" ] ; then #if the user ID is not root... + echo "You must be root to do that!" #Tell the user they must be root + exit 1 #Exits with an error +fi #End of if statement echo "Hello and welcome to my installation script. I assume you're running this as root?" -sleep 5s +sleep 5s #Pauses for 5 seconds echo "Okay! Gotta love when a plan comes together!" echo "Let me install a few upgrade and packages on your system for you...." echo "If you already have a package installed, I'll simply skip over it or upgrade it" -apt-get update -y --fix-missing +apt-get update -y --fix-missing #Fixes missing apt-get repository errors on some Linux distributions echo "Updated repo lists...." echo "Installing package upgrades... go kill some time as this may take a few minutes..." -apt-get upgrade -y +apt-get upgrade -y #Upgrades all already installed packages on your system clear echo "Upgrades complete!" echo "Now installing required packages..." -apt-get install apache2 python2.7 python-twisted dnsmasq -y +apt-get install apache2 python2.7 python-twisted dnsmasq -y #Install required packages echo "Installing Apache, Python 2.7, Python Twisted and DNSMasq....." clear echo "Now that that's out of the way, let's do some apache stuff" echo "Copying virtual hosts to sites-available for virtual hosting of the server" -cp ./$vh/$vh1 $apache/$vh1 +#The next several lines will copy the Nintendo virtual host files to sites-available in Apache's directory +cp ./$vh/$vh1 $apache/$vh1 cp ./$vh/$vh2 $apache/$vh2 cp ./$vh/$vh3 $apache/$vh3 cp ./$vh/$vh4 $apache/$vh4 @@ -52,18 +53,18 @@ clear echo "Okay! Lets hope nothing broke during this process..." sleep 5s echo "Now lets enable some modules so we can make all of this work..." -a2enmod $mod1 $mod2 $mod3 -if [ $? != "0" ] ; then - a2enmod $mod4 +a2enmod $mod1 $mod2 $mod3 #Enables proxy modules +if [ $? != "0" ] ; then #If in the event these modules fail to activate.... + a2enmod $mod4 #Enable proxy fallback module fi echo "Great! Everything appears to be set up as far as Apache" echo "Fixing that nagging Apache FQDN error...." -cat >>/etc/apache2/apache2.conf <>/etc/apache2/apache2.conf <>/etc/dnsmasq.conf <>/etc/dnsmasq.conf < ./adminpageconf.json < ./adminpageconf.json <