Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Jetty debian package builder.It takes the jetty script as is and build a jetty server that runs at startup.It's quick & simple version. Improvements are welcome.
#!/bin/sh
# Newest Jetty 9 version (See http://download.eclipse.org/jetty/)
JETTY_VERSION=9.3.6.v20151106
# We reset everything
rm -Rf jetty-distribution-${JETTY_VERSION} jetty
# We prepare the dirs
mkdir -p jetty/opt jetty/etc/init.d jetty/etc/default jetty/DEBIAN
# We download the archive
wget -c http://download.eclipse.org/jetty/stable-9/dist/jetty-distribution-${JETTY_VERSION}.zip
unzip jetty-distribution-${JETTY_VERSION}.zip
# We copy the main files
mv jetty-distribution-${JETTY_VERSION} jetty/opt/jetty-${JETTY_VERSION}
ln -s jetty-${JETTY_VERSION} jetty/opt/jetty
# We remove the demo files
rm -Rf jetty/opt/jetty/webapps.demo
cp jetty/opt/jetty/bin/jetty.sh jetty/etc/init.d/jetty || return 1
# We prepare the default file
cat <<EOF > jetty/etc/default/jetty
JETTY_USER=jetty
JETTY_HOME=/opt/jetty
EOF
chmod +x jetty/etc/default/jetty
# We have all the files, we just have to prepare the debian package file
cat <<EOF > jetty/DEBIAN/control
Package: jetty
Priority: optional
Section: web
Maintainer: Florent Clairambault
Architecture: all
Version: ${JETTY_VERSION}
Depends: openjdk-7-jre
Description: Eclipse Jetty (9)
EOF
cat <<EOF > jetty/DEBIAN/postinst
#!/bin/sh
groupadd -r -f jetty
useradd -r -s /sbin/nologin -d /opt/jetty --gid jetty jetty
chown -R jetty:jetty /opt/jetty-${JETTY_VERSION}
cd /etc/init.d ; update-rc.d -f jetty defaults 2>/dev/null
service jetty start || /bin/echo "Could not start jetty !"
EOF
chmod 0755 jetty/DEBIAN/postinst
cat <<EOF > jetty/DEBIAN/prerm
#!/bin/sh
service jetty stop
cd /etc/init.d ; update-rc.d -f jetty remove 2>/dev/null
killall -9 -u jetty
userdel jetty || echo "No user jetty ? --> Not a big deal"
#groupdel jetty || echo "No group jetty ? --> Not a big deal"
EOF
chmod 0755 jetty/DEBIAN/prerm
dpkg-deb -b jetty
@johannrichard

This comment has been minimized.

Copy link
Owner Author

commented Dec 20, 2015

  • Updated to current Jetty version
  • Changed download path to correct one
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.