1
0
mirror of https://github.com/community-scripts/ProxmoxVE.git synced 2025-03-08 13:19:05 +00:00

Apache Tomcat (#2797)

This commit is contained in:
CanbiZ 2025-03-04 14:02:48 +01:00 committed by GitHub
parent 80631f5152
commit 266eee3029
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 240 additions and 0 deletions

41
ct/apache-tomcat.sh Normal file
View File

@ -0,0 +1,41 @@
#!/usr/bin/env bash
source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
# Copyright (c) 2021-2025 community-scripts ORG
# Author: MickLesk (Canbiz)
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://tomcat.apache.org/
APP="Apache-Tomcat"
var_tags="webserver"
var_disk="5"
var_cpu="1"
var_ram="1024"
var_os="debian"
var_version="12"
var_unprivileged="1"
header_info "$APP"
variables
color
catch_errors
function update_script() {
header_info
check_container_storage
check_container_resources
if ! ls -d /opt/tomcat-* >/dev/null 2>&1; then
msg_error "No ${APP} Installation Found!"
exit
fi
msg_error "Currently we don't provide an update function for this ${APP}."
exit
}
start
build_container
description
msg_ok "Completed Successfully!\n"
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:8080${CL}"

View File

@ -0,0 +1,160 @@
#!/usr/bin/env bash
# Copyright (c) 2021-2025 community-scripts ORG
# Author: MickLesk (CanbiZ)
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://tomcat.apache.org/
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
catch_errors
setting_up_container
network_check
update_os
msg_info "Installing Dependencies"
$STD apt-get install -y \
gnupg2 \
curl \
sudo \
mc \
lsb-release \
gpg \
apt-transport-https
msg_ok "Installed Dependencies"
msg_info "Setting up Adoptium Repository"
mkdir -p /etc/apt/keyrings
wget -qO - https://packages.adoptium.net/artifactory/api/gpg/key/public | gpg --dearmor >/etc/apt/trusted.gpg.d/adoptium.gpg
echo "deb https://packages.adoptium.net/artifactory/deb $(awk -F= '/^VERSION_CODENAME/{print$2}' /etc/os-release) main" >/etc/apt/sources.list.d/adoptium.list
$STD apt-get update
msg_ok "Set up Adoptium Repository"
read -r -p "Which Tomcat version would you like to install? (9, 10.1, 11): " version
case $version in
9)
TOMCAT_VERSION="9"
echo "Which LTS Java version would you like to use? (8, 11, 17, 21): "
read -r jdk_version
case $jdk_version in
8)
msg_info "Installing Temurin JDK 8 (LTS) for Tomcat $TOMCAT_VERSION"
$STD apt-get install -y temurin-8-jdk
msg_ok "Setup Temurin JDK 8 (LTS)"
;;
11)
msg_info "Installing Temurin JDK 11 (LTS) for Tomcat $TOMCAT_VERSION"
$STD apt-get install -y temurin-11-jdk
msg_ok "Setup Temurin JDK 11 (LTS)"
;;
17)
msg_info "Installing Temurin JDK 17 (LTS) for Tomcat $TOMCAT_VERSION"
$STD apt-get install -qqy temurin-17-jdk
msg_ok "Setup Temurin JDK 17 (LTS)"
;;
21)
msg_info "Installing Temurin JDK 21 (LTS) for Tomcat $TOMCAT_VERSION"
$STD apt-get install -y temurin-21-jdk
msg_ok "Setup Temurin JDK 21 (LTS)"
;;
*)
msg_error "Invalid JDK version selected. Please enter 8, 11, 17 or 21."
exit 1
;;
esac
;;
10 | 10.1)
TOMCAT_VERSION="10"
echo "Which LTS Java version would you like to use? (11, 17): "
read -r jdk_version
case $jdk_version in
11)
msg_info "Installing Temurin JDK 11 (LTS) for Tomcat $TOMCAT_VERSION"
$STD apt-get install -y temurin-11-jdk
msg_ok "Setup Temurin JDK 11"
;;
17)
msg_info "Installing Temurin JDK 17 (LTS) for Tomcat $TOMCAT_VERSION"
$STD apt-get install -y temurin-17-jdk
msg_ok "Setup Temurin JDK 17"
;;
21)
msg_info "Installing Temurin JDK 21 (LTS) for Tomcat $TOMCAT_VERSION"
$STD apt-get install -y temurin-21-jdk
msg_ok "Setup Temurin JDK 21 (LTS)"
;;
*)
msg_error "Invalid JDK version selected. Please enter 11 or 17."
exit 1
;;
esac
;;
11)
TOMCAT_VERSION="11"
echo "Which LTS Java version would you like to use? (17, 21): "
read -r jdk_version
case $jdk_version in
17)
msg_info "Installing Temurin JDK 17 (LTS) for Tomcat $TOMCAT_VERSION"
$STD apt-get install -qqy temurin-17-jdk
msg_ok "Setup Temurin JDK 17"
;;
21)
msg_info "Installing Temurin JDK 21 (LTS) for Tomcat $TOMCAT_VERSION"
$STD apt-get install -y temurin-21-jdk
msg_ok "Setup Temurin JDK 21 (LTS)"
;;
*)
msg_error "Invalid JDK version selected. Please enter 17 or 21."
exit 1
;;
esac
;;
*)
msg_error "Invalid Tomcat version selected. Please enter 9, 10.1 or 11."
exit 1
;;
esac
msg_info "Installing Tomcat $TOMCAT_VERSION"
LATEST_VERSION=$(curl -s "https://dlcdn.apache.org/tomcat/tomcat-$TOMCAT_VERSION/" | grep -oP 'v[0-9]+\.[0-9]+\.[0-9]+(-M[0-9]+)?/' | sort -V | tail -n 1 | sed 's/\/$//; s/v//')
TOMCAT_URL="https://dlcdn.apache.org/tomcat/tomcat-$TOMCAT_VERSION/v$LATEST_VERSION/bin/apache-tomcat-$LATEST_VERSION.tar.gz"
wget -qO /tmp/tomcat.tar.gz "$TOMCAT_URL"
mkdir -p /opt/tomcat-$TOMCAT_VERSION
tar --strip-components=1 -xzf /tmp/tomcat.tar.gz -C /opt/tomcat-$TOMCAT_VERSION
chown -R root:root /opt/tomcat-$TOMCAT_VERSION
cat <<EOF >/etc/systemd/system/tomcat.service
[Unit]
Description=Apache Tomcat Web Application Container
After=network.target
[Service]
Type=forking
User=$(whoami)
Group=$(whoami)
Environment=JAVA_HOME=/usr/lib/jvm/temurin-${jdk_version}-jdk-amd64
Environment=CATALINA_HOME=/opt/tomcat-$TOMCAT_VERSION
Environment=CATALINA_BASE=/opt/tomcat-$TOMCAT_VERSION
Environment=CATALINA_PID=/opt/tomcat-$TOMCAT_VERSION/temp/tomcat.pid
ExecStart=/opt/tomcat-$TOMCAT_VERSION/bin/catalina.sh start
ExecStop=/opt/tomcat-$TOMCAT_VERSION/bin/catalina.sh stop
PIDFile=/opt/tomcat-$TOMCAT_VERSION/temp/tomcat.pid
SuccessExitStatus=143
Restart=on-abnormal
[Install]
WantedBy=multi-user.target
EOF
systemctl enable -q --now tomcat
msg_ok "Tomcat $LATEST_VERSION installed and started"
motd_ssh
customize
msg_info "Cleaning up"
rm -f /tmp/tomcat.tar.gz
$STD apt-get -y autoremove
$STD apt-get -y autoclean
msg_ok "Cleaned"

39
json/apache-tomcat.json Normal file
View File

@ -0,0 +1,39 @@
{
"name": "Apache Tomcat",
"slug": "apache-tomcat",
"categories": [
10
],
"date_created": "2025-03-03",
"type": "ct",
"updateable": false,
"privileged": false,
"interface_port": 8080,
"documentation": "https://cwiki.apache.org/confluence/display/TOMCAT",
"website": "https://tomcat.apache.org/",
"logo": "https://tomcat.apache.org/res/images/tomcat.png",
"description": "Apache Tomcat is an open-source application server that runs Java Servlets and JavaServer Pages (JSP). It allows developers to deploy and manage Java web applications by handling HTTP requests and serving dynamic content. Tomcat is widely used for lightweight web applications and supports various Java EE features like WebSockets and JNDI.",
"install_methods": [
{
"type": "default",
"script": "ct/apache-tomcat.sh",
"resources": {
"cpu": 1,
"ram": 1024,
"hdd": 5,
"os": "debian",
"version": "12"
}
}
],
"default_credentials": {
"username": null,
"password": null
},
"notes": [
{
"text": "User can select which Adoptium JDK should be used for the selected Tomcat version (9, 10.1 or 11). ",
"type": "info"
}
]
}