Skip to content

Commit

Permalink
Merge pull request #23 from jamf/add-server-template-support
Browse files Browse the repository at this point in the history
Add a server xml template file within a new directory
  • Loading branch information
battlecow authored Jan 21, 2023
2 parents 5096c03 + 5ae07c0 commit 2de5c3a
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 2 deletions.
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ RUN apt-get update -qq && \
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
adduser --disabled-password --gecos '' tomcat && \
rm -rf /usr/local/tomcat/webapps && \
mkdir -p /usr/local/tomcat/webapps
mkdir -p /usr/local/tomcat/webapps && \
mkdir /jamfpro-config

COPY startup.sh /startup.sh
COPY log4j.stdout.replace /log4j.stdout.replace
COPY log4j2.stdout.appenders.replace /log4j2.stdout.appenders.replace
COPY log4j2.stdout.loggers.analytics.replace /log4j2.stdout.loggers.analytics.replace
COPY log4j2.stdout.loggers.root.replace /log4j2.stdout.loggers.root.replace
COPY log4j2.stdout.loggers.vpp.replace /log4j2.stdout.loggers.vpp.replace
COPY server.template /jamfpro-config/server.template
COPY configuration.sh /configuration.sh

CMD ["/startup.sh"]
Expand Down
9 changes: 8 additions & 1 deletion configuration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,12 @@ memcached.timeToLiveSeconds=120
EOF
}

## Move the server.xml template into proper location
tomcatServerXML() {
echo_time "Moving custom server.xml into tomcat"
eval "echo \"$(cat "/jamfpro-config/server.template")\" " > /usr/local/tomcat/conf/server.xml
}

##########################################################
# Arguments:
# Cluster primary node name / ip
Expand All @@ -148,7 +154,7 @@ create_cluster_properties() {
echo_time "Creating the clustering properties file"
cat <<- EOF > /usr/local/tomcat/webapps/ROOT/WEB-INF/classes/clustering.properties
cluster.settings.enabled=true
cluster.settings.monitor_frequency=180
cluster.settings.monitor_frequency=60
cluster.node[0]=$1
EOF
}
Expand Down Expand Up @@ -205,5 +211,6 @@ setup_jmx_remote_opts

setup_java_opts

tomcatServerXML

##########################################################
79 changes: 79 additions & 0 deletions server.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?xml version='1.0' encoding='utf-8'?>

<Server port=\"-1\" shutdown=\"SHUTDOWN\">
<Listener className=\"org.apache.catalina.startup.VersionLoggerListener\" />
<Listener className=\"org.apache.catalina.core.AprLifecycleListener\" SSLEngine=\"on\" />
<Listener className=\"org.apache.catalina.core.JreMemoryLeakPreventionListener\" />
<Listener className=\"org.apache.catalina.mbeans.GlobalResourcesLifecycleListener\" />
<Listener className=\"org.apache.catalina.core.ThreadLocalLeakPreventionListener\" />

<GlobalNamingResources>

<Resource
name=\"UserDatabase\"
auth=\"Container\"
type=\"org.apache.catalina.UserDatabase\"
description=\"User database that can be updated and saved\"
factory=\"org.apache.catalina.users.MemoryUserDatabaseFactory\"
pathname=\"conf/tomcat-users.xml\"
/>

</GlobalNamingResources>

<Service name=\"Catalina\">

<Executor
name=\"tomcatThreadPool\"
namePrefix=\"Tomcat-\"
maxThreads=\"${tomcat_executor_max_threads:=150}\"
minSpareThreads=\"${tomcat_executor_min_threads:=4}\"/>

<Connector
executor=\"tomcatThreadPool\"
port=\"${tomcat_connector_port:=8080}\"
protocol=\"HTTP/1.1\"
connectionTimeout=\"${tomcat_connection_timeout:=61000}\"
URIEncoding=\"UTF-8\"
scheme=\"https\"
redirectPort=\"8443\"
secure=\"true\"
proxyPort=\"${tomcat_connector_proxy_port:=443}\"
server=\"${tomcat_connector_server:=Jamf}\"
maxParameterCount=\"${tomcat_connector_max_parameter_count:=300000}\"
/>

<Engine name=\"Catalina\" defaultHost=\"localhost\">

<Realm className=\"org.apache.catalina.realm.LockOutRealm\">

<Realm
className=\"org.apache.catalina.realm.UserDatabaseRealm\"
resourceName=\"UserDatabase\"
/>

</Realm>

<Host
name=\"localhost\"
appBase=\"${tomcat_host_app_base:=webapps}\"
unpackWARs=\"${tomcat_host_unpack_wars:=true}\"
autoDeploy=\"${tomcat_host_auto_deploy:=true}\"
startStopThreads=\"${tomcat_host_start_stop_threads:=4}\"
>

<Valve className=\"org.apache.catalina.valves.RemoteIpValve\" />

<Valve className=\"org.apache.catalina.valves.ErrorReportValve\"
showReport=\"false\"
showServerInfo=\"false\"
/>

<Valve
className=\"org.apache.catalina.valves.StuckThreadDetectionValve\"
threshold=\"${tomcat_host_stuck_threads_threshold:=600}\"
/>

</Host>
</Engine>
</Service>
</Server>

0 comments on commit 2de5c3a

Please sign in to comment.