Skip to content

Instantly share code, notes, and snippets.

@LeifW
Created October 2, 2011 09:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save LeifW/1257261 to your computer and use it in GitHub Desktop.
Save LeifW/1257261 to your computer and use it in GitHub Desktop.
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
<!-- =============================================================== -->
<!-- Configure the Jetty SetUIDServer -->
<!-- this configuration file should be used in combination with -->
<!-- other configuration files. e.g. -->
<!-- java -jar start.jar etc/jetty-setuid.xml etc/jetty.xml -->
<!-- =============================================================== -->
<Configure id="Server" class="org.mortbay.setuid.SetUIDServer">
<Set name="uid">jettyUserUID</Set>
<Set name="gid">2</Set>
</Configure>
# set JAVA_HOME
[ -f /etc/profile.d/jre.sh ] && . /etc/profile.d/jre.sh
[ -f /etc/profile.d/jdk.sh ] && . /etc/profile.d/jdk.sh
[ -f /etc/profile.d/openjdk6.sh ] && . /etc/profile.d/openjdk6.sh
# or set your variant
#JAVA_HOME=/somewhere
# Other Java options
#JAVA_OPTS=
JETTY_HOME=/opt/jetty
# Jetty's variables
#JETTY_OPTS=
post_install() {
id jetty &>/dev/null || useradd -r -c "Jetty daemon" -g daemon -d /opt/jetty -s /bin/false jetty
sed -i "s/jettyUserUID/`id -u jetty`/" /opt/jetty/etc/jetty-setuid.xml
chown -R jetty.daemon /opt/jetty/logs
}
pre_upgrade() {
id jetty &>/dev/null || useradd -r -c "Jetty daemon" -g daemon -d /opt/jetty -s /bin/false jetty
}
post_upgrade() {
sed -i "s/jettyUserUID/`id -u jetty`/" /opt/jetty/etc/jetty-setuid.xml
chown -R jetty.daemon /opt/jetty/logs
}
post_remove() {
userdel jetty &>/dev/null
}
# Contributor: [Vitaliy Berdinskikh](mailto:ur6lad@archlinux.org.ua) aka UR6LAD
# Contributor: Leif Warner <abimelech@gmail.com>
_timestamp=v20111024
pkgname=jetty
pkgver=8.0.4
pkgrel=1
pkgdesc="A full-fledged production-grade lightweight Java Servlet Container"
arch=('i686' 'x86_64')
url="http://jetty.codehaus.org/jetty/"
license=('Apache' 'EPL')
depends=('java-runtime')
install=jetty.install
source=(http://dist.codehaus.org/${pkgname}/${pkgname}-hightide-${pkgver}/${pkgname}-hightide-${pkgver}.${_timestamp}.tar.gz
rc.$pkgname
$pkgname.conf.d
jetty-setuid.xml
setuid.patch)
md5sums=('b878170caac1d9aea589d48e0995390a'
'a912afd9817f5c9675e9932971fb689a'
'a191d0246f97a314355cbcfd5c74d6a6'
'532d8f6b250c660f8cb2854576cd1c9f'
'a68e53f7b423ab46f9c7357fd9abf12d')
if test "$CARCH" == i686; then
source=("${source[@]}" http://mirrors.ibiblio.org/pub/mirrors/maven2/org/mortbay/jetty/libsetuid/${pkgver}.${_timestamp}/libsetuid-${pkgver}.${_timestamp}-sources.jar)
md5sums=("${md5sums[@]}" 'c746c3362e4771df97577f2aaf8002c0')
fi
options=(!strip)
_foldername=${pkgname}-hightide-${pkgver}.${_timestamp}
build() {
if test "$CARCH" == i686; then
gcc -I$JAVA_HOME/include/ -I$JAVA_HOME/include/linux/ -shared org_mortbay_setuid_SetUID.c -o ${_foldername}/lib/setuid/libsetuid.so
chmod 644 ${_foldername}/lib/setuid/libsetuid.so
fi
patch $srcdir/${_foldername}/start.ini < setuid.patch
rm -r $srcdir/${_foldername}/bin/*cygwin*
}
package() {
install -d $pkgdir/opt
cp -a $srcdir/${_foldername} $pkgdir/opt/$pkgname
install jetty-setuid.xml $pkgdir/opt/jetty/etc/jetty-setuid.xml
install -D -m755 rc.$pkgname $pkgdir/etc/rc.d/$pkgname
install -D -m644 $pkgname.conf.d $pkgdir/etc/conf.d/$pkgname
}
# vim:set ts=2 sw=2 et:
#!/bin/bash
# general config
. /etc/rc.conf
. /etc/rc.d/functions
# set Jetty's variables
. /etc/conf.d/jetty
case "$1" in
start)
stat_busy "Starting Jetty Servlet Container"
cd $JETTY_HOME
$JAVA_HOME/bin/java -jar $JAVA_OPTS start.jar $JETTY_OPTS >> /var/log/jetty.log 2>&1 &
echo $! > /var/run/jetty.pid
if [ $? -gt 0 ]; then
stat_fail
else
add_daemon jetty
stat_done
fi
;;
stop)
stat_busy "Stopping Jetty Servlet Container"
cd $JETTY_HOME
[ -e /var/run/jetty.pid ] && PID=`cat /var/run/jetty.pid`
[ ! -z "$PID" ] && kill $PID &> /dev/null
if [ $? -gt 0 ]; then
stat_fail
else
rm_daemon jetty
rm -f /var/run/jetty.pid
stat_done
fi
;;
restart)
$0 stop
sleep 3
$0 start
;;
*)
echo "usage: $0 {start|stop|restart}"
esac
--- jetty-hightide-8.0.1.v20110908/start.ini 2011-09-08 12:17:50.000000000 -0700
+++ ../jetty-hightide-8.0.1.v20110908/start.ini 2011-09-30 10:33:11.907265084 -0700
@@ -45,7 +45,7 @@
# for a full listing do
# java -jar start.jar --list-options
#-----------------------------------------------------------
-OPTIONS=Server,jsp,jmx,resources,websocket,ext,plus,annotations,jta,jdbc
+OPTIONS=Server,jsp,jmx,resources,websocket,ext,plus,annotations,jta,jdbc,setuid
#-----------------------------------------------------------
@@ -54,6 +54,7 @@
# For a full list of available configuration files do
# java -jar start.jar --help
#-----------------------------------------------------------
+etc/jetty-setuid.xml
etc/jetty-jmx.xml
etc/jetty.xml
etc/jetty-hightide.xml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment