Instantly share code, notes, and snippets.

Embed
What would you like to do?
Jetty On-demand - bash bootstrap
#!/usr/bin/env bash
#
# Invoke this bootstrap copying following command to the command line:
#
# bash < <(curl -s -L https://raw.github.com/gist/4174871/jetty-ondemand.sh)
#
# (this should be run as root)
#
# move to working dir.
cd /tmp
echo "Installing EPEL"
if [ ! -e /usr/local/src/epel-release-6-7.noarch.rpm ]; then
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-7.noarch.rpm
mv -n epel-release-6-7.noarch.rpm //usr/local/src
rpm -ivh /usr/local/src/epel-release-6-7.noarch.rpm
fi
echo "Installing dependencies"
yum -y install java-1.7.0-oracle-devel.x86_64 # dependency
echo "Jetty"
wget http://eclipse.ialto.com/jetty/8.1.8.v20121106/dist/jetty-distribution-8.1.8.v20121106.tar.gz
tar -xzvf jetty-distribution-8.1.8.v20121106.tar.gz
mv jetty-distribution-8.1.8.v20121106 /opt/jetty8
# Jetty comes with a bash script, but we'll fix and overwrite.
cat > /opt/jetty8/bin/jetty-xinetd.sh << EOL
#!/bin/bash
cd $JETTY_HOME
#exec /usr/bin/java -Djetty.port=8080 -jar start.jar --pre=etc/jetty-logging.xml --pre=etc/jetty-xinetd.xml > /tmp/jetty-xinetd.log
exec /usr/bin/java -Djetty.port=8080 -jar start.jar --pre=etc/jetty-logging.xml --pre=etc/jetty-xinetd.xml
EOL
chmod +x /opt/jetty8/bin/jetty-xinetd.sh
# set JETTY_HOME
echo "export JETTY_HOME=/opt/jetty8" >> ~/.bash_profile
cat > /etc/xinetd.d/jetty << EOL
service jetty
{
flags = IPv4
disable = no
id = jetty
type = UNLISTED
wait = yes
socket_type = stream
user = root
group = root
port = 18080
server = /opt/jetty8/bin/jetty-xinetd.sh
}
EOL
# restart xinetd to activate config.
service xinetd restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment