Browse Source

user-data for AWS VertSys examples

master
Sebastian Rieger 7 years ago
parent
commit
e551c6d89d
  1. 33
      VerteilteSysteme-Examples/src/verteiltesysteme/aws/user-data.txt

33
VerteilteSysteme-Examples/src/verteiltesysteme/aws/user-data.txt

@ -1,19 +1,24 @@
#!/bin/bash #!/bin/bash
# Config
SCRIPT_ROOT_PATH="/tmp/init-script" SCRIPT_ROOT_PATH="/tmp/init-script"
VERTSYS_PATH="$SCRIPT_ROOT_PATH/verteilte-systeme-bsc-ai-examples/VerteilteSysteme-Examples/build/" VERTSYS_PATH="$SCRIPT_ROOT_PATH/verteilte-systeme-bsc-ai-examples/VerteilteSysteme-Examples/build/"
#JARS = "TCPServer.jar TCPServerMulti.jar UDPServer.jar UDPServerMulti.jar UDPTimeCounterServer.jar TCPPerfServer.jar" #JARS = "TCPServer.jar TCPServerMulti.jar UDPServer.jar UDPServerMulti.jar UDPTimeCounterServer.jar TCPPerfServer.jar"
JARS="TCPServer.jar TCPPerfServer.jar UDPServer.jar UDPTimeCounterServer.jar" JARS="TCPServer.jar TCPPerfServer.jar UDPServer.jar UDPTimeCounterServer.jar"
REPO="https://gogs.informatik.hs-fulda.de/srieger/verteilte-systeme-bsc-ai-examples.git" REPO="https://gogs.informatik.hs-fulda.de/srieger/verteilte-systeme-bsc-ai-examples.git"
# Create path to run the script and store the output
mkdir $SCRIPT_ROOT_PATH mkdir $SCRIPT_ROOT_PATH
cd $SCRIPT_ROOT_PATH cd $SCRIPT_ROOT_PATH
# fetch user-data (should be the content of this script itself ;)) to check and run it later again
wget http://169.254.169.254/latest/user-data wget http://169.254.169.254/latest/user-data
chmod +x user-data chmod +x user-data
wget http://169.254.169.254/latest/meta-data/placement/availability-zone wget http://169.254.169.254/latest/meta-data/placement/availability-zone
echo "PS1='[\u@\h@`cat /tmp/init-script/availability-zone` \W]$ '" >>/root/.bashrc
echo "PS1='[\u@\h@`cat /tmp/init-script/availability-zone` \W]$ '" >>/home/ec2-user/.bashrc
# setting console prompt to include location (availability zone and region in AWS)
echo "PS1='[\u@\h@\e[32m`cat /tmp/init-script/availability-zone`\e[32m \W]$ '" >>/root/.bashrc
echo "PS1='[\u@\h@\e[32m`cat /tmp/init-script/availability-zone`\e[39m \W]$ '" >>/home/ec2-user/.bashrc
# wait for internet connection, should not be necessary, but just in case ;)
while ! ping -c 1 -W 1 8.8.8.8; do while ! ping -c 1 -W 1 8.8.8.8; do
echo "Waiting for 8.8.8.8 - network interface might be down..." echo "Waiting for 8.8.8.8 - network interface might be down..."
sleep 1 sleep 1
@ -28,25 +33,27 @@ if [ ! -d $VERTSYS_PATH ]; then
git clone $REPO git clone $REPO
fi fi
# Example for path and contents:
#
# ./verteilte-systeme-bsc-ai-examples/VerteilteSysteme-Examples/build/
#
#build-server-jars.xml TCPServerMulti.jar
#RMIEchoServer.jar UDPServer.jar
#RMIMandelbrotCalculationsServer.jar UDPServerMulti.jar
#TCPPerfServer.jar UDPTimeCounterServer.jar
#TCPServer.jar
# killall running screens if script is run again
killall screen killall screen
# start all jars
echo "Starting JARS: ${JARS}..." echo "Starting JARS: ${JARS}..."
for JAR in $JARS; do for JAR in $JARS; do
echo "Starting ${JAR}..." echo "Starting ${JAR}..."
sudo screen -dmS $JAR -L java -jar $VERTSYS_PATH/$JAR sudo screen -dmS $JAR -L java -jar $VERTSYS_PATH/$JAR
done done
sleep 5
sleep 1
echo "Status:" echo "Status:"
sudo netstat -taupen | grep 36[0,1][0-9][0-9] sudo netstat -taupen | grep 36[0,1][0-9][0-9]
sudo ps aux | grep java sudo ps aux | grep java
# Example for path and contents:
#
# ./verteilte-systeme-bsc-ai-examples/VerteilteSysteme-Examples/build/
#
#build-server-jars.xml TCPServerMulti.jar
#RMIEchoServer.jar UDPServer.jar
#RMIMandelbrotCalculationsServer.jar UDPServerMulti.jar
#TCPPerfServer.jar UDPTimeCounterServer.jar
#TCPServer.jar
Loading…
Cancel
Save