From dd90d1560bac3037fc37ed11fb68d5440e428042 Mon Sep 17 00:00:00 2001 From: Michel Roegl-Brunner Date: Tue, 3 Dec 2024 16:06:40 +0100 Subject: [PATCH 1/3] New Script: Apache Guacamole --- ct/apache-guacamole.sh | 59 +++++++++++ install/apache-guacamole-install.sh | 148 ++++++++++++++++++++++++++++ json/apache-guacamole.json | 44 +++++++++ 3 files changed, 251 insertions(+) create mode 100644 ct/apache-guacamole.sh create mode 100644 install/apache-guacamole-install.sh create mode 100644 json/apache-guacamole.json diff --git a/ct/apache-guacamole.sh b/ct/apache-guacamole.sh new file mode 100644 index 00000000..3b66561e --- /dev/null +++ b/ct/apache-guacamole.sh @@ -0,0 +1,59 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/michelroegl-brunner/ProxmoxVE/refs/heads/dev/misc/build.func) +# Copyright (c) 2021-2024 community-scripts ORG +# Author: Michel Roegl-Brunner (michelroegl-brunner) +# License: MIT +# https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +function header_info { +clear +cat <<"EOF" + ___ __ ______ __ + / | ____ ____ ______/ /_ ___ / ____/_ ______ __________ _____ ___ ____ / /__ + / /| | / __ \/ __ `/ ___/ __ \/ _ \ / / __/ / / / __ `/ ___/ __ `/ __ `__ \/ __ \/ / _ \ + / ___ |/ /_/ / /_/ / /__/ / / / __/ / /_/ / /_/ / /_/ / /__/ /_/ / / / / / / /_/ / / __/ +/_/ |_/ .___/\__,_/\___/_/ /_/\___/ \____/\__,_/\__,_/\___/\__,_/_/ /_/ /_/\____/_/\___/ + /_/ +EOF +} +header_info +echo -e "Loading..." +APP="Apache-Guacamole" + +var_disk="4" +var_cpu="1" +var_ram="2048" +var_os="debian" +var_version="12" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET="dhcp" + GATE="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" diff --git a/install/apache-guacamole-install.sh b/install/apache-guacamole-install.sh new file mode 100644 index 00000000..d7da57a3 --- /dev/null +++ b/install/apache-guacamole-install.sh @@ -0,0 +1,148 @@ +#!/usr/bin/env bash + +#Copyright (c) 2021-2024 community-scripts ORG +# Author: Michel Roegl-Brunner (michelroegl-brunner) +# License: MIT +# https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE + +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 \ + build-essential \ + curl \ + jq \ + libcairo2-dev \ + libturbojpeg0 \ + libpng-dev \ + libtool-bin \ + libossp-uuid-dev \ + libvncserver-dev \ + freerdp2-dev \ + libssh2-1-dev \ + libtelnet-dev \ + libwebsockets-dev \ + libpulse-dev \ + libvorbis-dev \ + libwebp-dev \ + libssl-dev \ + libpango1.0-dev \ + libswscale-dev \ + libavcodec-dev \ + libavutil-dev \ + libavformat-dev \ + mariadb-server \ + default-jdk +msg_ok "Installed Dependencies" + +msg_info "Install Tomcat" +mkdir /opt/${APPLICATION} +mkdir /opt/${APPLICATION}/tomcat9 +$STD wget https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.97/bin/apache-tomcat-9.0.97.tar.gz +$STD tar xzf apache-tomcat-9.0.97.tar.gz -C /opt/${APPLICATION}/tomcat9 --strip-components=1 +useradd -r -d /opt/tomcat9 -s /bin/false tomcat +chown -R tomcat: /opt/${APPLICATION}/tomcat9/{logs,temp,webapps,work} +chown -R :tomcat /opt/${APPLICATION}/tomcat9/ +chmod -R g+r /opt/${APPLICATION}/tomcat9/conf +chmod g+x /opt/${APPLICATION}/tomcat9/conf +JAVA_HOME=$(update-alternatives --query javadoc | grep Value: | head -n1 | sed 's/Value: //' | sed 's@bin/javadoc$@@') +cat </etc/systemd/system/tomcat.service +[Unit] +Description=Apache Tomcat Web Application Container +After=network.target + +[Service] +Type=forking + +Environment="JAVA_HOME=${JAVA_HOME}" +Environment="CATALINA_PID=/opt/${APPLICATION}/tomcat9/temp/tomcat.pid" +Environment="CATALINA_HOME=/opt/${APPLICATION}/tomcat9/" +Environment="CATALINA_BASE=/opt/${APPLICATION}/tomcat9/" +Environment="CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC" +Environment="JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom" + +ExecStart=/opt/${APPLICATION}/tomcat9/bin/startup.sh +ExecStop=/opt/${APPLICATION}/tomcat9/bin/shutdown.sh + +User=tomcat +Group=tomcat +UMask=0007 +RestartSec=10 +Restart=always + +[Install] +WantedBy=multi-user.target +EOF +$STD systemctl daemon-reload +$STD systemctl enable --now tomcat +msg_ok "Installed Tomcat" + +msg_info "Installing Guacamole" +mkdir -p /etc/guacamole/{extensions,lib} +REALESE_SERVER=$(curl -sL https://api.github.com/repos/apache/guacamole-server/tags | jq -r '.[0].name') +mkdir /opt/${APPLICATION}/apache-guacamole-server-${REALESE_SERVER} +$STD wget -O apache-guacamole-server-${REALESE_SERVER} https://api.github.com/repos/apache/guacamole-server/tarball/refs/tags/${REALESE_SERVER} +$STD tar -xvf apache-guacamole-server-${REALESE_SERVER} -C /opt/${APPLICATION}/apache-guacamole-server-${REALESE_SERVER} --strip-components=1 +cd /opt/${APPLICATION}/apache-guacamole-server-${REALESE_SERVER} +$STD autoreconf -fi +$STD ./configure --with-init-dir=/etc/init.d --enable-allow-freerdp-snapshots +$STD make +$STD make install +$STD ldconfig +$STD systemctl daemon-reload +$STD systemctl enable --now guacd +REALESE_CLIENT=$(curl -sL https://api.github.com/repos/apache/guacamole-client/tags | jq -r '.[0].name') +$STD wget -O /opt/${APPLICATION}/tomcat9/webapps/guacamole.war https://downloads.apache.org/guacamole/${REALESE_CLIENT}/binary/guacamole-${REALESE_CLIENT}.war +$STD systemctl restart guacd tomcat +msg_ok "Installed Guacamole" + +msg_info "Creating Service" +cd /root +$STD wget https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-8.0.26.tar.gz +$STD tar -xf mysql-connector-java-8.0.26.tar.gz +mv mysql-connector-java-8.0.26/mysql-connector-java-8.0.26.jar /etc/guacamole/lib/ +$STD wget https://downloads.apache.org/guacamole/1.5.5/binary/guacamole-auth-jdbc-1.5.5.tar.gz +$STD tar -xf guacamole-auth-jdbc-1.5.5.tar.gz +mv guacamole-auth-jdbc-1.5.5/mysql/guacamole-auth-jdbc-mysql-1.5.5.jar /etc/guacamole/extensions/ +DB_NAME=guacamole_db +DB_USER=guacamole_user +DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13) +mysql -u root -e "CREATE DATABASE $DB_NAME;" +mysql -u root -e "CREATE USER '$DB_USER'@'localhost' IDENTIFIED WITH mysql_native_password AS PASSWORD('$DB_PASS');" +mysql -u root -e "GRANT ALL ON $DB_NAME.* TO '$DB_USER'@'localhost'; FLUSH PRIVILEGES;" +{ + echo "SnipeIT-Credentials" + echo "SnipeIT Database User: $DB_USER" + echo "SnipeIT Database Password: $DB_PASS" + echo "SnipeIT Database Name: $DB_NAME" +} >> ~/guacamole.creds +cd guacamole-auth-jdbc-1.5.5/mysql/schema +cat *.sql | mysql -u root ${DB_NAME} +{ + echo "mysql-hostname: 127.0.0.1" + echo "mysql-port: 3306" + echo "mysql-database: $DB_NAME" + echo "mysql-username: $DB_USER" + echo "mysql-password: $DB_PASS" + +} >> /etc/guacamole/guacamole.properties +$STD systemctl restart tomcat guacd mysql +msg_ok "Creted Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD rm mysql-connector-java-8.0.26.tar.gz +$STD rm -rf mysql-connector-java-8.0.26 +$STD rm guacamole-auth-jdbc-1.5.5.tar.gz +$STD rm -rf guacamole-auth-jdbc-1.5.5 +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/json/apache-guacamole.json b/json/apache-guacamole.json new file mode 100644 index 00000000..757605db --- /dev/null +++ b/json/apache-guacamole.json @@ -0,0 +1,44 @@ +{ + "name": "Apache Guacamole", + "slug": "apache-guacamole", + "categories": [ + 11 + ], + "date_created": "2024-12-02", + "type": "ct", + "updateable": false, + "privileged": false, + "interface_port": null, + "documentation": null, + "website": "https://guacamole.apache.org/", + "logo": "https://guacamole.apache.org/images/logos/guac-tricolor-logo.svg", + "description": "Apache Guacamole is a clientless remote desktop gateway. It supports standard protocols like VNC, RDP, and SSH.", + "install_methods": [ + { + "type": "default", + "script": "/ct/apacheguacamole.sh", + "resources": { + "cpu": 1, + "ram": 2048, + "hdd": 4, + "os": "Debian", + "version": "12" + } + } + ], + "default_credentials": { + "username": null, + "password": null + }, + "notes": [ + { + "text": "After installation you can reach the Management Dashboard with $IP:8080/guacamole" + "type": "info" + } + { + "text": "Default Username is guacadmin, Password is guacadmin" + "type": "info" + } + + ] +} From 7da447d1b9c051daeec876249a239db31e56f467 Mon Sep 17 00:00:00 2001 From: Michel Roegl-Brunner Date: Wed, 4 Dec 2024 11:58:41 +0100 Subject: [PATCH 2/3] Changes as requested --- ct/apache-guacamole.sh | 2 +- install/apache-guacamole-install.sh | 67 ++++++++++++++--------------- json/apache-guacamole.json | 18 ++------ 3 files changed, 37 insertions(+), 50 deletions(-) diff --git a/ct/apache-guacamole.sh b/ct/apache-guacamole.sh index 3b66561e..afcc66f2 100644 --- a/ct/apache-guacamole.sh +++ b/ct/apache-guacamole.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -source <(curl -s https://raw.githubusercontent.com/michelroegl-brunner/ProxmoxVE/refs/heads/dev/misc/build.func) +source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/refs/heads/main/misc/build.func) # Copyright (c) 2021-2024 community-scripts ORG # Author: Michel Roegl-Brunner (michelroegl-brunner) # License: MIT diff --git a/install/apache-guacamole-install.sh b/install/apache-guacamole-install.sh index d7da57a3..734271f0 100644 --- a/install/apache-guacamole-install.sh +++ b/install/apache-guacamole-install.sh @@ -1,5 +1,4 @@ #!/usr/bin/env bash - #Copyright (c) 2021-2024 community-scripts ORG # Author: Michel Roegl-Brunner (michelroegl-brunner) # License: MIT @@ -41,16 +40,16 @@ $STD apt-get install -y \ default-jdk msg_ok "Installed Dependencies" -msg_info "Install Tomcat" -mkdir /opt/${APPLICATION} -mkdir /opt/${APPLICATION}/tomcat9 -$STD wget https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.97/bin/apache-tomcat-9.0.97.tar.gz -$STD tar xzf apache-tomcat-9.0.97.tar.gz -C /opt/${APPLICATION}/tomcat9 --strip-components=1 +msg_info "Setup Apache Tomcat" +mkdir /opt/apache-guacamole +mkdir /opt/apache-guacamole/tomcat9 +wget -q https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.97/bin/apache-tomcat-9.0.97.tar.gz +$STD tar xzf apache-tomcat-9.0.97.tar.gz -C /opt/apache-guacamole/tomcat9 --strip-components=1 useradd -r -d /opt/tomcat9 -s /bin/false tomcat -chown -R tomcat: /opt/${APPLICATION}/tomcat9/{logs,temp,webapps,work} -chown -R :tomcat /opt/${APPLICATION}/tomcat9/ -chmod -R g+r /opt/${APPLICATION}/tomcat9/conf -chmod g+x /opt/${APPLICATION}/tomcat9/conf +chown -R tomcat: /opt/apache-guacamole/tomcat9/{logs,temp,webapps,work} +chown -R :tomcat /opt/apache-guacamole/tomcat9/ +chmod -R g+r /opt/apache-guacamole/tomcat9/conf +chmod g+x /opt/apache-guacamole/tomcat9/conf JAVA_HOME=$(update-alternatives --query javadoc | grep Value: | head -n1 | sed 's/Value: //' | sed 's@bin/javadoc$@@') cat </etc/systemd/system/tomcat.service [Unit] @@ -61,14 +60,14 @@ After=network.target Type=forking Environment="JAVA_HOME=${JAVA_HOME}" -Environment="CATALINA_PID=/opt/${APPLICATION}/tomcat9/temp/tomcat.pid" -Environment="CATALINA_HOME=/opt/${APPLICATION}/tomcat9/" -Environment="CATALINA_BASE=/opt/${APPLICATION}/tomcat9/" +Environment="CATALINA_PID=/opt/apache-guacamole/tomcat9/temp/tomcat.pid" +Environment="CATALINA_HOME=/opt/apache-guacamole/tomcat9/" +Environment="CATALINA_BASE=/opt/apache-guacamole/tomcat9/" Environment="CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC" Environment="JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom" -ExecStart=/opt/${APPLICATION}/tomcat9/bin/startup.sh -ExecStop=/opt/${APPLICATION}/tomcat9/bin/shutdown.sh +ExecStart=/opt/apache-guacamole/tomcat9/bin/startup.sh +ExecStop=/opt/apache-guacamole/tomcat9/bin/shutdown.sh User=tomcat Group=tomcat @@ -79,37 +78,35 @@ Restart=always [Install] WantedBy=multi-user.target EOF -$STD systemctl daemon-reload -$STD systemctl enable --now tomcat -msg_ok "Installed Tomcat" +msg_ok "Setup Apache Tomcat" -msg_info "Installing Guacamole" +msg_info "Setup Apache Guacamole" mkdir -p /etc/guacamole/{extensions,lib} -REALESE_SERVER=$(curl -sL https://api.github.com/repos/apache/guacamole-server/tags | jq -r '.[0].name') -mkdir /opt/${APPLICATION}/apache-guacamole-server-${REALESE_SERVER} -$STD wget -O apache-guacamole-server-${REALESE_SERVER} https://api.github.com/repos/apache/guacamole-server/tarball/refs/tags/${REALESE_SERVER} -$STD tar -xvf apache-guacamole-server-${REALESE_SERVER} -C /opt/${APPLICATION}/apache-guacamole-server-${REALESE_SERVER} --strip-components=1 -cd /opt/${APPLICATION}/apache-guacamole-server-${REALESE_SERVER} +RELEASE_SERVER=$(curl -sL https://api.github.com/repos/apache/guacamole-server/tags | jq -r '.[0].name') +mkdir /opt/apache-guacamole/apache-guacamole-server-${RELEASE_SERVER} +wget -q -O apache-guacamole-server-${RELEASE_SERVER} https://api.github.com/repos/apache/guacamole-server/tarball/refs/tags/${RELEASE_SERVER} +$STD tar -xvf apache-guacamole-server-${RELEASE_SERVER} -C /opt/apache-guacamole/apache-guacamole-server-${RELEASE_SERVER} --strip-components=1 +cd /opt/apache-guacamole/apache-guacamole-server-${RELEASE_SERVER} $STD autoreconf -fi $STD ./configure --with-init-dir=/etc/init.d --enable-allow-freerdp-snapshots $STD make $STD make install $STD ldconfig -$STD systemctl daemon-reload -$STD systemctl enable --now guacd -REALESE_CLIENT=$(curl -sL https://api.github.com/repos/apache/guacamole-client/tags | jq -r '.[0].name') -$STD wget -O /opt/${APPLICATION}/tomcat9/webapps/guacamole.war https://downloads.apache.org/guacamole/${REALESE_CLIENT}/binary/guacamole-${REALESE_CLIENT}.war -$STD systemctl restart guacd tomcat -msg_ok "Installed Guacamole" +RELEASE_CLIENT=$(curl -sL https://api.github.com/repos/apache/guacamole-client/tags | jq -r '.[0].name') +wget -q -O /opt/apache-guacamole/tomcat9/webapps/guacamole.war https://downloads.apache.org/guacamole/${RELEASE_CLIENT}/binary/guacamole-${RELEASE_CLIENT}.war +msg_ok "Setup Apache Guacamole" -msg_info "Creating Service" +msg_info "Setup Databas" cd /root -$STD wget https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-8.0.26.tar.gz +wget -q https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-8.0.26.tar.gz $STD tar -xf mysql-connector-java-8.0.26.tar.gz mv mysql-connector-java-8.0.26/mysql-connector-java-8.0.26.jar /etc/guacamole/lib/ -$STD wget https://downloads.apache.org/guacamole/1.5.5/binary/guacamole-auth-jdbc-1.5.5.tar.gz +wget -q https://downloads.apache.org/guacamole/1.5.5/binary/guacamole-auth-jdbc-1.5.5.tar.gz $STD tar -xf guacamole-auth-jdbc-1.5.5.tar.gz mv guacamole-auth-jdbc-1.5.5/mysql/guacamole-auth-jdbc-mysql-1.5.5.jar /etc/guacamole/extensions/ +msg_ok "Setup Databse" + +msg_info "Setup Service" DB_NAME=guacamole_db DB_USER=guacamole_user DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13) @@ -132,8 +129,8 @@ cat *.sql | mysql -u root ${DB_NAME} echo "mysql-password: $DB_PASS" } >> /etc/guacamole/guacamole.properties -$STD systemctl restart tomcat guacd mysql -msg_ok "Creted Service" +systemctl -q enable --now tomcat guacd mysql +msg_ok "Setup Service" motd_ssh customize diff --git a/json/apache-guacamole.json b/json/apache-guacamole.json index 757605db..4a691b76 100644 --- a/json/apache-guacamole.json +++ b/json/apache-guacamole.json @@ -8,7 +8,7 @@ "type": "ct", "updateable": false, "privileged": false, - "interface_port": null, + "interface_port": 8080, "documentation": null, "website": "https://guacamole.apache.org/", "logo": "https://guacamole.apache.org/images/logos/guac-tricolor-logo.svg", @@ -27,18 +27,8 @@ } ], "default_credentials": { - "username": null, - "password": null + "username": "guacadmin", + "password": "guacadmin" }, - "notes": [ - { - "text": "After installation you can reach the Management Dashboard with $IP:8080/guacamole" - "type": "info" - } - { - "text": "Default Username is guacadmin, Password is guacadmin" - "type": "info" - } - - ] + "notes": [] } From 502c5d61a12a52774e3beab96ea18aaebd639dab Mon Sep 17 00:00:00 2001 From: Michel Roegl-Brunner Date: Fri, 6 Dec 2024 12:31:59 +0100 Subject: [PATCH 3/3] Changed to new System --- ct/apache-guacamole.sh | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/ct/apache-guacamole.sh b/ct/apache-guacamole.sh index afcc66f2..f4fa87b3 100644 --- a/ct/apache-guacamole.sh +++ b/ct/apache-guacamole.sh @@ -2,28 +2,24 @@ source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/refs/heads/main/misc/build.func) # Copyright (c) 2021-2024 community-scripts ORG # Author: Michel Roegl-Brunner (michelroegl-brunner) -# License: MIT -# https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE -function header_info { -clear -cat <<"EOF" - ___ __ ______ __ - / | ____ ____ ______/ /_ ___ / ____/_ ______ __________ _____ ___ ____ / /__ - / /| | / __ \/ __ `/ ___/ __ \/ _ \ / / __/ / / / __ `/ ___/ __ `/ __ `__ \/ __ \/ / _ \ - / ___ |/ /_/ / /_/ / /__/ / / / __/ / /_/ / /_/ / /_/ / /__/ /_/ / / / / / / /_/ / / __/ -/_/ |_/ .___/\__,_/\___/_/ /_/\___/ \____/\__,_/\__,_/\___/\__,_/_/ /_/ /_/\____/_/\___/ - /_/ -EOF -} -header_info -echo -e "Loading..." -APP="Apache-Guacamole" +# License: | MIT https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://guacamole.apache.org/ +#App Default Values +APP="Apache-Guacamole" +TAGS="webserver;remote" var_disk="4" var_cpu="1" var_ram="2048" var_os="debian" var_version="12" +var_unprivileged="1" + +# App Output & Base Settings +header_info "$APP" +base_settings + +# Core variables color catch_errors @@ -57,3 +53,7 @@ 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/guacamole${CL}" +