Skip to content

Commit

Permalink
Issue appropriate#63 Bypass start.jar (appropriate#66)
Browse files Browse the repository at this point in the history
Issue appropriate#63 Bypass start.jar

- renamed command file to /jetty-start
- added warning if start.d is newer /jetty-start
- Any --dry-run command that produces more than one line is considered an
a terminating command and the output is reported.
- Rely on -e for non zero exit
  • Loading branch information
gregw authored Aug 17, 2017
1 parent 9c03b27 commit cdee9d9
Show file tree
Hide file tree
Showing 19 changed files with 404 additions and 5 deletions.
2 changes: 1 addition & 1 deletion 9.2-jre7/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ RUN set -xe \
&& mkdir -p "$TMPDIR" \
&& chown -R jetty:jetty "$TMPDIR"

COPY docker-entrypoint.sh /
COPY docker-entrypoint.sh generate-jetty-start.sh /

EXPOSE 8080
ENTRYPOINT ["/docker-entrypoint.sh"]
Expand Down
54 changes: 54 additions & 0 deletions 9.2-jre7/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,58 @@ if [ "$1" = "java" -a -n "$JAVA_OPTIONS" ] ; then
set -- java $JAVA_OPTIONS "$@"
fi

if expr "$*" : 'java .*/start\.jar.*$' >/dev/null ; then
# this is a command to run jetty

# check if it is a terminating command
for A in "$@" ; do
case $A in
--add-to-start* |\
--create-files |\
--create-startd |\
--download |\
--dry-run |\
--exec-print |\
--help |\
--info |\
--list-all-modules |\
--list-classpath |\
--list-config |\
--list-modules* |\
--stop |\
--update-ini |\
--version |\
-v )\
# It is a terminating command, so exec directly
exec "$@"
esac
done

if [ -f /jetty-start ] ; then
if [ $JETTY_BASE/start.d -nt /jetty-start ] ; then
cat >&2 <<- 'EOWARN'
********************************************************************
WARNING: The $JETTY_BASE/start.d directory has been modified since
the /jetty-start files was generated. Please either delete
the /jetty-start file or re-run /generate-jetty-start.sh
from a Dockerfile
********************************************************************
EOWARN
fi
echo $(date +'%Y-%m-%d %H:%M:%S.000'):INFO:docker-entrypoint:jetty start command from /jetty-start
set -- $(cat /jetty-start)
else
# Do a jetty dry run to set the final command
"$@" --dry-run > /jetty-start
if [ $(egrep -v '\\$' /jetty-start | wc -l ) -gt 1 ] ; then
# command was more than a dry-run
cat /jetty-start \
| awk '/\\$/ { printf "%s", substr($0, 1, length($0)-1); next } 1' \
| egrep -v '[^ ]*java .* org\.eclipse\.jetty\.xml\.XmlConfiguration '
exit
fi
set -- $(sed 's/\\$//' /jetty-start)
fi
fi

exec "$@"
3 changes: 3 additions & 0 deletions 9.2-jre7/generate-jetty-start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
rm -f /jetty-start
/docker-entrypoint.sh --dry-run | sed 's/\\$//' > /jetty-start
2 changes: 1 addition & 1 deletion 9.2-jre8/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ RUN set -xe \
&& mkdir -p "$TMPDIR" \
&& chown -R jetty:jetty "$TMPDIR"

COPY docker-entrypoint.sh /
COPY docker-entrypoint.sh generate-jetty-start.sh /

EXPOSE 8080
ENTRYPOINT ["/docker-entrypoint.sh"]
Expand Down
54 changes: 54 additions & 0 deletions 9.2-jre8/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,58 @@ if [ "$1" = "java" -a -n "$JAVA_OPTIONS" ] ; then
set -- java $JAVA_OPTIONS "$@"
fi

if expr "$*" : 'java .*/start\.jar.*$' >/dev/null ; then
# this is a command to run jetty

# check if it is a terminating command
for A in "$@" ; do
case $A in
--add-to-start* |\
--create-files |\
--create-startd |\
--download |\
--dry-run |\
--exec-print |\
--help |\
--info |\
--list-all-modules |\
--list-classpath |\
--list-config |\
--list-modules* |\
--stop |\
--update-ini |\
--version |\
-v )\
# It is a terminating command, so exec directly
exec "$@"
esac
done

if [ -f /jetty-start ] ; then
if [ $JETTY_BASE/start.d -nt /jetty-start ] ; then
cat >&2 <<- 'EOWARN'
********************************************************************
WARNING: The $JETTY_BASE/start.d directory has been modified since
the /jetty-start files was generated. Please either delete
the /jetty-start file or re-run /generate-jetty-start.sh
from a Dockerfile
********************************************************************
EOWARN
fi
echo $(date +'%Y-%m-%d %H:%M:%S.000'):INFO:docker-entrypoint:jetty start command from /jetty-start
set -- $(cat /jetty-start)
else
# Do a jetty dry run to set the final command
"$@" --dry-run > /jetty-start
if [ $(egrep -v '\\$' /jetty-start | wc -l ) -gt 1 ] ; then
# command was more than a dry-run
cat /jetty-start \
| awk '/\\$/ { printf "%s", substr($0, 1, length($0)-1); next } 1' \
| egrep -v '[^ ]*java .* org\.eclipse\.jetty\.xml\.XmlConfiguration '
exit
fi
set -- $(sed 's/\\$//' /jetty-start)
fi
fi

exec "$@"
3 changes: 3 additions & 0 deletions 9.2-jre8/generate-jetty-start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
rm -f /jetty-start
/docker-entrypoint.sh --dry-run | sed 's/\\$//' > /jetty-start
2 changes: 1 addition & 1 deletion 9.3-jre8/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ RUN set -xe \
&& mkdir -p "$TMPDIR" \
&& chown -R jetty:jetty "$TMPDIR"

COPY docker-entrypoint.sh /
COPY docker-entrypoint.sh generate-jetty-start.sh /

EXPOSE 8080
ENTRYPOINT ["/docker-entrypoint.sh"]
Expand Down
54 changes: 54 additions & 0 deletions 9.3-jre8/alpine/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,58 @@ if [ "$1" = "java" -a -n "$JAVA_OPTIONS" ] ; then
set -- java $JAVA_OPTIONS "$@"
fi

if expr "$*" : 'java .*/start\.jar.*$' >/dev/null ; then
# this is a command to run jetty

# check if it is a terminating command
for A in "$@" ; do
case $A in
--add-to-start* |\
--create-files |\
--create-startd |\
--download |\
--dry-run |\
--exec-print |\
--help |\
--info |\
--list-all-modules |\
--list-classpath |\
--list-config |\
--list-modules* |\
--stop |\
--update-ini |\
--version |\
-v )\
# It is a terminating command, so exec directly
exec "$@"
esac
done

if [ -f /jetty-start ] ; then
if [ $JETTY_BASE/start.d -nt /jetty-start ] ; then
cat >&2 <<- 'EOWARN'
********************************************************************
WARNING: The $JETTY_BASE/start.d directory has been modified since
the /jetty-start files was generated. Please either delete
the /jetty-start file or re-run /generate-jetty-start.sh
from a Dockerfile
********************************************************************
EOWARN
fi
echo $(date +'%Y-%m-%d %H:%M:%S.000'):INFO:docker-entrypoint:jetty start command from /jetty-start
set -- $(cat /jetty-start)
else
# Do a jetty dry run to set the final command
"$@" --dry-run > /jetty-start
if [ $(egrep -v '\\$' /jetty-start | wc -l ) -gt 1 ] ; then
# command was more than a dry-run
cat /jetty-start \
| awk '/\\$/ { printf "%s", substr($0, 1, length($0)-1); next } 1' \
| egrep -v '[^ ]*java .* org\.eclipse\.jetty\.xml\.XmlConfiguration '
exit
fi
set -- $(sed 's/\\$//' /jetty-start)
fi
fi

exec "$@"
3 changes: 3 additions & 0 deletions 9.3-jre8/alpine/generate-jetty-start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
rm -f /jetty-start
/docker-entrypoint.sh --dry-run | sed 's/\\$//' > /jetty-start
54 changes: 54 additions & 0 deletions 9.3-jre8/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,58 @@ if [ "$1" = "java" -a -n "$JAVA_OPTIONS" ] ; then
set -- java $JAVA_OPTIONS "$@"
fi

if expr "$*" : 'java .*/start\.jar.*$' >/dev/null ; then
# this is a command to run jetty

# check if it is a terminating command
for A in "$@" ; do
case $A in
--add-to-start* |\
--create-files |\
--create-startd |\
--download |\
--dry-run |\
--exec-print |\
--help |\
--info |\
--list-all-modules |\
--list-classpath |\
--list-config |\
--list-modules* |\
--stop |\
--update-ini |\
--version |\
-v )\
# It is a terminating command, so exec directly
exec "$@"
esac
done

if [ -f /jetty-start ] ; then
if [ $JETTY_BASE/start.d -nt /jetty-start ] ; then
cat >&2 <<- 'EOWARN'
********************************************************************
WARNING: The $JETTY_BASE/start.d directory has been modified since
the /jetty-start files was generated. Please either delete
the /jetty-start file or re-run /generate-jetty-start.sh
from a Dockerfile
********************************************************************
EOWARN
fi
echo $(date +'%Y-%m-%d %H:%M:%S.000'):INFO:docker-entrypoint:jetty start command from /jetty-start
set -- $(cat /jetty-start)
else
# Do a jetty dry run to set the final command
"$@" --dry-run > /jetty-start
if [ $(egrep -v '\\$' /jetty-start | wc -l ) -gt 1 ] ; then
# command was more than a dry-run
cat /jetty-start \
| awk '/\\$/ { printf "%s", substr($0, 1, length($0)-1); next } 1' \
| egrep -v '[^ ]*java .* org\.eclipse\.jetty\.xml\.XmlConfiguration '
exit
fi
set -- $(sed 's/\\$//' /jetty-start)
fi
fi

exec "$@"
3 changes: 3 additions & 0 deletions 9.3-jre8/generate-jetty-start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
rm -f /jetty-start
/docker-entrypoint.sh --dry-run | sed 's/\\$//' > /jetty-start
2 changes: 1 addition & 1 deletion 9.4-jre8/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ RUN set -xe \
&& mkdir -p "$TMPDIR" \
&& chown -R jetty:jetty "$TMPDIR"

COPY docker-entrypoint.sh /
COPY docker-entrypoint.sh generate-jetty-start.sh /

EXPOSE 8080
ENTRYPOINT ["/docker-entrypoint.sh"]
Expand Down
54 changes: 54 additions & 0 deletions 9.4-jre8/alpine/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,58 @@ if [ "$1" = "java" -a -n "$JAVA_OPTIONS" ] ; then
set -- java $JAVA_OPTIONS "$@"
fi

if expr "$*" : 'java .*/start\.jar.*$' >/dev/null ; then
# this is a command to run jetty

# check if it is a terminating command
for A in "$@" ; do
case $A in
--add-to-start* |\
--create-files |\
--create-startd |\
--download |\
--dry-run |\
--exec-print |\
--help |\
--info |\
--list-all-modules |\
--list-classpath |\
--list-config |\
--list-modules* |\
--stop |\
--update-ini |\
--version |\
-v )\
# It is a terminating command, so exec directly
exec "$@"
esac
done

if [ -f /jetty-start ] ; then
if [ $JETTY_BASE/start.d -nt /jetty-start ] ; then
cat >&2 <<- 'EOWARN'
********************************************************************
WARNING: The $JETTY_BASE/start.d directory has been modified since
the /jetty-start files was generated. Please either delete
the /jetty-start file or re-run /generate-jetty-start.sh
from a Dockerfile
********************************************************************
EOWARN
fi
echo $(date +'%Y-%m-%d %H:%M:%S.000'):INFO:docker-entrypoint:jetty start command from /jetty-start
set -- $(cat /jetty-start)
else
# Do a jetty dry run to set the final command
"$@" --dry-run > /jetty-start
if [ $(egrep -v '\\$' /jetty-start | wc -l ) -gt 1 ] ; then
# command was more than a dry-run
cat /jetty-start \
| awk '/\\$/ { printf "%s", substr($0, 1, length($0)-1); next } 1' \
| egrep -v '[^ ]*java .* org\.eclipse\.jetty\.xml\.XmlConfiguration '
exit
fi
set -- $(sed 's/\\$//' /jetty-start)
fi
fi

exec "$@"
3 changes: 3 additions & 0 deletions 9.4-jre8/alpine/generate-jetty-start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
rm -f /jetty-start
/docker-entrypoint.sh --dry-run | sed 's/\\$//' > /jetty-start
Loading

0 comments on commit cdee9d9

Please sign in to comment.