mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-05-30 12:34:43 +00:00
Apache Guacamole: Function Bump + update_script (#10728)
This commit is contained in:
committed by
GitHub
parent
0ec96f8287
commit
57c87169a9
+96
-2
@@ -27,8 +27,102 @@ function update_script() {
|
|||||||
msg_error "No ${APP} Installation Found!"
|
msg_error "No ${APP} Installation Found!"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
setup_mariadb
|
|
||||||
msg_error "Currently we don't provide an update function for this ${APP}."
|
# Fetch latest versions
|
||||||
|
LATEST_TOMCAT=$(curl -fsSL https://dlcdn.apache.org/tomcat/tomcat-9/ | grep -oP '(?<=href=")v[^"/]+(?=/")' | sed 's/^v//' | sort -V | tail -n1)
|
||||||
|
LATEST_SERVER=$(curl -fsSL https://api.github.com/repos/apache/guacamole-server/tags | jq -r '.[].name' | grep -v -- '-RC' | head -n 1)
|
||||||
|
LATEST_CLIENT=$(curl -fsSL https://api.github.com/repos/apache/guacamole-client/tags | jq -r '.[].name' | grep -v -- '-RC' | head -n 1)
|
||||||
|
LATEST_MYSQL_CONNECTOR=$(curl -fsSL "https://repo1.maven.org/maven2/com/mysql/mysql-connector-j/maven-metadata.xml" | grep -oP '<latest>\K[^<]+')
|
||||||
|
|
||||||
|
# Read current versions from ~/.guacamole_*
|
||||||
|
CURRENT_TOMCAT=$(cat ~/.guacamole_tomcat 2>/dev/null || echo "unknown")
|
||||||
|
CURRENT_SERVER=$(cat ~/.guacamole_server 2>/dev/null || echo "unknown")
|
||||||
|
CURRENT_CLIENT=$(cat ~/.guacamole_client 2>/dev/null || echo "unknown")
|
||||||
|
CURRENT_MYSQL_CONNECTOR=$(cat ~/.guacamole_mysql_connector 2>/dev/null || echo "unknown")
|
||||||
|
|
||||||
|
UPDATE_NEEDED=false
|
||||||
|
[[ "$CURRENT_TOMCAT" != "$LATEST_TOMCAT" ]] && UPDATE_NEEDED=true
|
||||||
|
[[ "$CURRENT_SERVER" != "$LATEST_SERVER" ]] && UPDATE_NEEDED=true
|
||||||
|
[[ "$CURRENT_CLIENT" != "$LATEST_CLIENT" ]] && UPDATE_NEEDED=true
|
||||||
|
[[ "$CURRENT_MYSQL_CONNECTOR" != "$LATEST_MYSQL_CONNECTOR" ]] && UPDATE_NEEDED=true
|
||||||
|
|
||||||
|
if [[ "$UPDATE_NEEDED" == "false" ]]; then
|
||||||
|
msg_ok "All components are up to date"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
JAVA_VERSION="11" setup_java
|
||||||
|
|
||||||
|
msg_info "Stopping Services"
|
||||||
|
systemctl stop guacd tomcat
|
||||||
|
msg_ok "Stopped Services"
|
||||||
|
|
||||||
|
# Update Tomcat
|
||||||
|
if [[ "$CURRENT_TOMCAT" != "$LATEST_TOMCAT" ]]; then
|
||||||
|
msg_info "Updating Tomcat (${CURRENT_TOMCAT} → ${LATEST_TOMCAT})"
|
||||||
|
cp -a /opt/apache-guacamole/tomcat9/conf /tmp/tomcat-conf-backup
|
||||||
|
curl -fsSL "https://dlcdn.apache.org/tomcat/tomcat-9/v${LATEST_TOMCAT}/bin/apache-tomcat-${LATEST_TOMCAT}.tar.gz" | tar -xz -C /opt/apache-guacamole/tomcat9 --strip-components=1 --exclude='conf/*'
|
||||||
|
cp -a /tmp/tomcat-conf-backup/* /opt/apache-guacamole/tomcat9/conf/
|
||||||
|
rm -rf /tmp/tomcat-conf-backup
|
||||||
|
chown -R tomcat: /opt/apache-guacamole/tomcat9
|
||||||
|
echo "${LATEST_TOMCAT}" >~/.guacamole_tomcat
|
||||||
|
msg_ok "Updated Tomcat"
|
||||||
|
else
|
||||||
|
msg_ok "Tomcat already up to date (${CURRENT_TOMCAT})"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Update Guacamole Server
|
||||||
|
if [[ "$CURRENT_SERVER" != "$LATEST_SERVER" ]]; then
|
||||||
|
msg_info "Updating Guacamole Server (${CURRENT_SERVER} → ${LATEST_SERVER})"
|
||||||
|
rm -rf /opt/apache-guacamole/server/*
|
||||||
|
curl -fsSL "https://api.github.com/repos/apache/guacamole-server/tarball/refs/tags/${LATEST_SERVER}" | tar -xz --strip-components=1 -C /opt/apache-guacamole/server
|
||||||
|
cd /opt/apache-guacamole/server
|
||||||
|
export CPPFLAGS="-Wno-error=deprecated-declarations"
|
||||||
|
$STD autoreconf -fi
|
||||||
|
$STD ./configure --with-init-dir=/etc/init.d --enable-allow-freerdp-snapshots
|
||||||
|
$STD make
|
||||||
|
$STD make install
|
||||||
|
$STD ldconfig
|
||||||
|
echo "${LATEST_SERVER}" >~/.guacamole_server
|
||||||
|
msg_ok "Updated Guacamole Server"
|
||||||
|
|
||||||
|
# Auth JDBC follows server version
|
||||||
|
msg_info "Updating Guacamole Auth JDBC"
|
||||||
|
rm -f /etc/guacamole/extensions/guacamole-auth-jdbc-mysql-*.jar
|
||||||
|
curl -fsSL "https://downloads.apache.org/guacamole/${LATEST_SERVER}/binary/guacamole-auth-jdbc-${LATEST_SERVER}.tar.gz" -o "/tmp/guacamole-auth-jdbc.tar.gz"
|
||||||
|
$STD tar -xf /tmp/guacamole-auth-jdbc.tar.gz -C /tmp
|
||||||
|
mv /tmp/guacamole-auth-jdbc-"${LATEST_SERVER}"/mysql/guacamole-auth-jdbc-mysql-"${LATEST_SERVER}".jar /etc/guacamole/extensions/
|
||||||
|
rm -rf /tmp/guacamole-auth-jdbc*
|
||||||
|
echo "${LATEST_SERVER}" >~/.guacamole_auth_jdbc
|
||||||
|
msg_ok "Updated Guacamole Auth JDBC"
|
||||||
|
else
|
||||||
|
msg_ok "Guacamole Server already up to date (${CURRENT_SERVER})"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Update Guacamole Client
|
||||||
|
if [[ "$CURRENT_CLIENT" != "$LATEST_CLIENT" ]]; then
|
||||||
|
msg_info "Updating Guacamole Client (${CURRENT_CLIENT} → ${LATEST_CLIENT})"
|
||||||
|
curl -fsSL "https://downloads.apache.org/guacamole/${LATEST_CLIENT}/binary/guacamole-${LATEST_CLIENT}.war" -o "/opt/apache-guacamole/tomcat9/webapps/guacamole.war"
|
||||||
|
echo "${LATEST_CLIENT}" >~/.guacamole_client
|
||||||
|
msg_ok "Updated Guacamole Client"
|
||||||
|
else
|
||||||
|
msg_ok "Guacamole Client already up to date (${CURRENT_CLIENT})"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Update MySQL Connector
|
||||||
|
if [[ "$CURRENT_MYSQL_CONNECTOR" != "$LATEST_MYSQL_CONNECTOR" ]]; then
|
||||||
|
msg_info "Updating MySQL Connector (${CURRENT_MYSQL_CONNECTOR} → ${LATEST_MYSQL_CONNECTOR})"
|
||||||
|
curl -fsSL "https://repo1.maven.org/maven2/com/mysql/mysql-connector-j/${LATEST_MYSQL_CONNECTOR}/mysql-connector-j-${LATEST_MYSQL_CONNECTOR}.jar" -o "/etc/guacamole/lib/mysql-connector-j.jar"
|
||||||
|
echo "${LATEST_MYSQL_CONNECTOR}" >~/.guacamole_mysql_connector
|
||||||
|
msg_ok "Updated MySQL Connector"
|
||||||
|
else
|
||||||
|
msg_ok "MySQL Connector already up to date (${CURRENT_MYSQL_CONNECTOR})"
|
||||||
|
fi
|
||||||
|
|
||||||
|
msg_info "Starting Services"
|
||||||
|
systemctl start tomcat guacd
|
||||||
|
msg_ok "Started Services"
|
||||||
|
msg_ok "Updated successfully!"
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
],
|
],
|
||||||
"date_created": "2024-12-19",
|
"date_created": "2024-12-19",
|
||||||
"type": "ct",
|
"type": "ct",
|
||||||
"updateable": false,
|
"updateable": true,
|
||||||
"privileged": false,
|
"privileged": false,
|
||||||
"interface_port": 8080,
|
"interface_port": 8080,
|
||||||
"documentation": "https://guacamole.apache.org/doc/gug/",
|
"documentation": "https://guacamole.apache.org/doc/gug/",
|
||||||
|
|||||||
@@ -15,12 +15,11 @@ update_os
|
|||||||
msg_info "Installing Dependencies"
|
msg_info "Installing Dependencies"
|
||||||
$STD apt install -y \
|
$STD apt install -y \
|
||||||
build-essential \
|
build-essential \
|
||||||
jq \
|
|
||||||
libcairo2-dev \
|
libcairo2-dev \
|
||||||
libturbojpeg0 \
|
libjpeg62-turbo-dev \
|
||||||
libpng-dev \
|
libpng-dev \
|
||||||
libtool-bin \
|
libtool-bin \
|
||||||
libossp-uuid-dev \
|
uuid-dev \
|
||||||
libvncserver-dev \
|
libvncserver-dev \
|
||||||
freerdp3-dev \
|
freerdp3-dev \
|
||||||
libssh2-1-dev \
|
libssh2-1-dev \
|
||||||
@@ -34,71 +33,60 @@ $STD apt install -y \
|
|||||||
libswscale-dev \
|
libswscale-dev \
|
||||||
libavcodec-dev \
|
libavcodec-dev \
|
||||||
libavutil-dev \
|
libavutil-dev \
|
||||||
libavformat-dev \
|
libavformat-dev
|
||||||
default-jdk
|
|
||||||
msg_ok "Installed Dependencies"
|
msg_ok "Installed Dependencies"
|
||||||
|
|
||||||
|
JAVA_VERSION="11" setup_java
|
||||||
setup_mariadb
|
setup_mariadb
|
||||||
|
MARIADB_DB_NAME="guacamole_db" MARIADB_DB_USER="guacamole_user" setup_mariadb_db
|
||||||
|
|
||||||
msg_info "Setup Apache Tomcat"
|
msg_info "Setup Apache Tomcat"
|
||||||
RELEASE=$(curl -fsSL https://dlcdn.apache.org/tomcat/tomcat-9/ | grep -oP '(?<=href=")v[^"/]+(?=/")' | sed 's/^v//' | sort -V | tail -n1)
|
TOMCAT_VERSION=$(curl -fsSL https://dlcdn.apache.org/tomcat/tomcat-9/ | grep -oP '(?<=href=")v[^"/]+(?=/")' | sed 's/^v//' | sort -V | tail -n1)
|
||||||
mkdir -p /opt/apache-guacamole/tomcat9
|
mkdir -p /opt/apache-guacamole/{tomcat9,server}
|
||||||
mkdir -p /opt/apache-guacamole/server
|
curl -fsSL "https://dlcdn.apache.org/tomcat/tomcat-9/v${TOMCAT_VERSION}/bin/apache-tomcat-${TOMCAT_VERSION}.tar.gz" | tar -xz -C /opt/apache-guacamole/tomcat9 --strip-components=1
|
||||||
curl -fsSL "https://dlcdn.apache.org/tomcat/tomcat-9/v${RELEASE}/bin/apache-tomcat-${RELEASE}.tar.gz" | tar -xz -C /opt/apache-guacamole/tomcat9 --strip-components=1
|
|
||||||
useradd -r -d /opt/apache-guacamole/tomcat9 -s /bin/false tomcat
|
useradd -r -d /opt/apache-guacamole/tomcat9 -s /bin/false tomcat
|
||||||
chown -R tomcat: /opt/apache-guacamole/tomcat9
|
chown -R tomcat: /opt/apache-guacamole/tomcat9
|
||||||
chmod -R g+r /opt/apache-guacamole/tomcat9/conf
|
chmod -R g+r /opt/apache-guacamole/tomcat9/conf
|
||||||
chmod g+x /opt/apache-guacamole/tomcat9/conf
|
chmod g+x /opt/apache-guacamole/tomcat9/conf
|
||||||
msg_ok "Setup Apache Tomcat"
|
echo "${TOMCAT_VERSION}" >~/.guacamole_tomcat
|
||||||
|
msg_ok "Setup Apache Tomcat ${TOMCAT_VERSION}"
|
||||||
|
|
||||||
msg_info "Setup Apache Guacamole"
|
msg_info "Setup Apache Guacamole"
|
||||||
mkdir -p /etc/guacamole/{extensions,lib}
|
mkdir -p /etc/guacamole/{extensions,lib}
|
||||||
RELEASE_SERVER=$(curl -fsSL https://api.github.com/repos/apache/guacamole-server/tags | jq -r '.[].name' | grep -v -- '-RC' | head -n 1)
|
GUAC_SERVER_VERSION=$(curl -fsSL https://api.github.com/repos/apache/guacamole-server/tags | jq -r '.[].name' | grep -v -- '-RC' | head -n 1)
|
||||||
curl -fsSL "https://api.github.com/repos/apache/guacamole-server/tarball/refs/tags/${RELEASE_SERVER}" | tar -xz --strip-components=1 -C /opt/apache-guacamole/server
|
GUAC_CLIENT_VERSION=$(curl -fsSL https://api.github.com/repos/apache/guacamole-client/tags | jq -r '.[].name' | grep -v -- '-RC' | head -n 1)
|
||||||
|
MYSQL_CONNECTOR_VERSION=$(curl -fsSL "https://repo1.maven.org/maven2/com/mysql/mysql-connector-j/maven-metadata.xml" | grep -oP '<latest>\K[^<]+')
|
||||||
|
curl -fsSL "https://api.github.com/repos/apache/guacamole-server/tarball/refs/tags/${GUAC_SERVER_VERSION}" | tar -xz --strip-components=1 -C /opt/apache-guacamole/server
|
||||||
cd /opt/apache-guacamole/server
|
cd /opt/apache-guacamole/server
|
||||||
export CPPFLAGS="-Wno-error=deprecated-declarations"
|
export CPPFLAGS="-Wno-error=deprecated-declarations"
|
||||||
$STD autoreconf -fi
|
$STD autoreconf -fi
|
||||||
$STD ./configure --with-init-dir=/etc/init.d --enable-allow-freerdp-snapshots --disable-guaclog
|
$STD ./configure --with-init-dir=/etc/init.d --enable-allow-freerdp-snapshots
|
||||||
$STD make
|
$STD make
|
||||||
$STD make install
|
$STD make install
|
||||||
$STD ldconfig
|
$STD ldconfig
|
||||||
RELEASE_CLIENT=$(curl -fsSL https://api.github.com/repos/apache/guacamole-client/tags | jq -r '.[].name' | grep -v -- '-RC' | head -n 1)
|
echo "${GUAC_SERVER_VERSION}" >~/.guacamole_server
|
||||||
curl -fsSL "https://downloads.apache.org/guacamole/${RELEASE_CLIENT}/binary/guacamole-${RELEASE_CLIENT}.war" -o "/opt/apache-guacamole/tomcat9/webapps/guacamole.war"
|
curl -fsSL "https://downloads.apache.org/guacamole/${GUAC_CLIENT_VERSION}/binary/guacamole-${GUAC_CLIENT_VERSION}.war" -o "/opt/apache-guacamole/tomcat9/webapps/guacamole.war"
|
||||||
cd /root
|
echo "${GUAC_CLIENT_VERSION}" >~/.guacamole_client
|
||||||
curl -fsSL "https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-j-9.3.0.tar.gz" -o "/root/mysql-connector-j-9.3.0.tar.gz"
|
curl -fsSL "https://repo1.maven.org/maven2/com/mysql/mysql-connector-j/${MYSQL_CONNECTOR_VERSION}/mysql-connector-j-${MYSQL_CONNECTOR_VERSION}.jar" -o "/etc/guacamole/lib/mysql-connector-j.jar"
|
||||||
$STD tar -xf ~/mysql-connector-j-9.3.0.tar.gz
|
echo "${MYSQL_CONNECTOR_VERSION}" >~/.guacamole_mysql_connector
|
||||||
mv ~/mysql-connector-j-9.3.0/mysql-connector-j-9.3.0.jar /etc/guacamole/lib/
|
curl -fsSL "https://downloads.apache.org/guacamole/${GUAC_SERVER_VERSION}/binary/guacamole-auth-jdbc-${GUAC_SERVER_VERSION}.tar.gz" -o "/root/guacamole-auth-jdbc-${GUAC_SERVER_VERSION}.tar.gz"
|
||||||
curl -fsSL "https://downloads.apache.org/guacamole/${RELEASE_SERVER}/binary/guacamole-auth-jdbc-${RELEASE_SERVER}.tar.gz" -o "/root/guacamole-auth-jdbc-${RELEASE_SERVER}.tar.gz"
|
$STD tar -xf ~/guacamole-auth-jdbc-"$GUAC_SERVER_VERSION".tar.gz
|
||||||
$STD tar -xf ~/guacamole-auth-jdbc-"$RELEASE_SERVER".tar.gz
|
mv ~/guacamole-auth-jdbc-"$GUAC_SERVER_VERSION"/mysql/guacamole-auth-jdbc-mysql-"$GUAC_SERVER_VERSION".jar /etc/guacamole/extensions/
|
||||||
mv ~/guacamole-auth-jdbc-"$RELEASE_SERVER"/mysql/guacamole-auth-jdbc-mysql-"$RELEASE_SERVER".jar /etc/guacamole/extensions/
|
echo "${GUAC_SERVER_VERSION}" >~/.guacamole_auth_jdbc
|
||||||
rm -rf ~/mysql-connector-j-9.3.0{,.tar.gz}
|
|
||||||
msg_ok "Setup Apache Guacamole"
|
msg_ok "Setup Apache Guacamole"
|
||||||
|
|
||||||
msg_info "Setup Database"
|
msg_info "Importing Database Schema"
|
||||||
DB_NAME=guacamole_db
|
cd ~/guacamole-auth-jdbc-"${GUAC_SERVER_VERSION}"/mysql/schema
|
||||||
DB_USER=guacamole_user
|
cat *.sql | mariadb -u root ${MARIADB_DB_NAME}
|
||||||
DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13)
|
|
||||||
$STD mariadb -u root -e "CREATE DATABASE $DB_NAME;"
|
|
||||||
$STD mariadb -u root -e "CREATE USER '$DB_USER'@'localhost' IDENTIFIED BY '$DB_PASS';"
|
|
||||||
$STD mariadb -u root -e "GRANT ALL ON $DB_NAME.* TO '$DB_USER'@'localhost'; FLUSH PRIVILEGES;"
|
|
||||||
{
|
|
||||||
echo "Guacamole-Credentials"
|
|
||||||
echo "Database User: $DB_USER"
|
|
||||||
echo "Database Password: $DB_PASS"
|
|
||||||
echo "Database Name: $DB_NAME"
|
|
||||||
} >>~/guacamole.creds
|
|
||||||
cd guacamole-auth-jdbc-"${RELEASE_SERVER}"/mysql/schema
|
|
||||||
cat *.sql | mariadb -u root ${DB_NAME}
|
|
||||||
{
|
{
|
||||||
echo "mysql-hostname: 127.0.0.1"
|
echo "mysql-hostname: 127.0.0.1"
|
||||||
echo "mysql-port: 3306"
|
echo "mysql-port: 3306"
|
||||||
echo "mysql-database: $DB_NAME"
|
echo "mysql-database: $MARIADB_DB_NAME"
|
||||||
echo "mysql-username: $DB_USER"
|
echo "mysql-username: $MARIADB_DB_USER"
|
||||||
echo "mysql-password: $DB_PASS"
|
echo "mysql-password: $MARIADB_DB_PASS"
|
||||||
|
|
||||||
} >>/etc/guacamole/guacamole.properties
|
} >>/etc/guacamole/guacamole.properties
|
||||||
rm -rf ~/guacamole-auth-jdbc-"$RELEASE_SERVER"{,.tar.gz}
|
rm -rf ~/guacamole-auth-jdbc-"$GUAC_SERVER_VERSION"{,.tar.gz}
|
||||||
msg_ok "Setup Database"
|
msg_ok "Imported Database Schema"
|
||||||
|
|
||||||
msg_info "Setup Service"
|
msg_info "Setup Service"
|
||||||
cat <<EOF >/etc/guacamole/guacd.conf
|
cat <<EOF >/etc/guacamole/guacd.conf
|
||||||
@@ -143,7 +131,7 @@ PIDFile=/var/run/guacd.pid
|
|||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
EOF
|
EOF
|
||||||
systemctl -q enable --now mysql tomcat guacd
|
systemctl enable -q --now mysql tomcat guacd
|
||||||
msg_ok "Setup Service"
|
msg_ok "Setup Service"
|
||||||
|
|
||||||
motd_ssh
|
motd_ssh
|
||||||
|
|||||||
Reference in New Issue
Block a user