Skip to content

Instantly share code, notes, and snippets.

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.
# Newest Jetty 9 version (See
# 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${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/etc/init.d/jetty || return 1
# We prepare the default file
cat <<EOF > jetty/etc/default/jetty
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
Depends: openjdk-7-jre
Description: Eclipse Jetty (9)
cat <<EOF > jetty/DEBIAN/postinst
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 !"
chmod 0755 jetty/DEBIAN/postinst
cat <<EOF > jetty/DEBIAN/prerm
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"
chmod 0755 jetty/DEBIAN/prerm
dpkg-deb -b jetty

This comment has been minimized.

Copy link
Owner Author

johannrichard 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.