Enhance install_guac.sh for Guacamole setup
Added variables for Guacamole installation and MySQL setup. Updated VNC server systemd service configuration and included installation steps for Google Chrome and Tampermonkey.
This commit is contained in:
committed by
GitHub
parent
31aa0a33b8
commit
23461d5198
+114
-18
@@ -8,6 +8,13 @@ RED='\033[0;31m'
|
|||||||
GREEN='\033[0;32m'
|
GREEN='\033[0;32m'
|
||||||
NC='\033[0m'
|
NC='\033[0m'
|
||||||
|
|
||||||
|
GUACVERSION="1.5.5"
|
||||||
|
MYSQL_ROOT_PWD="password"
|
||||||
|
GUAC_USER="guacamole_user"
|
||||||
|
GUAC_PWD="password"
|
||||||
|
GUAC_DB="guacamole_db"
|
||||||
|
TOMCAT_VER=9.0.109
|
||||||
|
|
||||||
# Root check
|
# Root check
|
||||||
if [ "$(id -u)" -ne 0 ]; then
|
if [ "$(id -u)" -ne 0 ]; then
|
||||||
echo -e "${RED}Please run as root${NC}"
|
echo -e "${RED}Please run as root${NC}"
|
||||||
@@ -55,12 +62,30 @@ startxfce4 &
|
|||||||
EOF
|
EOF
|
||||||
chmod +x ~/.vnc/xstartup
|
chmod +x ~/.vnc/xstartup
|
||||||
fi
|
fi
|
||||||
systemctl enable vncserver@1.service || true
|
|
||||||
|
if [ ! -f /etc/systemd/system/vncserver@.service ]; then
|
||||||
|
cat > /etc/systemd/system/vncserver@.service <<EOF
|
||||||
|
[Unit]
|
||||||
|
Description=Start TightVNC server at startup
|
||||||
|
After=syslog.target network.target
|
||||||
|
[Service]
|
||||||
|
Type=forking
|
||||||
|
User=root
|
||||||
|
Group=root
|
||||||
|
WorkingDirectory=/root
|
||||||
|
PIDFile=/root/.vnc/%H:%i.pid
|
||||||
|
ExecStartPre=-/usr/bin/vncserver -kill :%i > /dev/null 2>&1
|
||||||
|
ExecStart=/usr/bin/vncserver -depth 24 -geometry 1280x800 -localhost :%i
|
||||||
|
ExecStop=/usr/bin/vncserver -kill :%i
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
EOF
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
systemctl start vncserver@1 || true
|
systemctl enable vncserver@1.service
|
||||||
|
fi
|
||||||
|
systemctl restart vncserver@1 || true
|
||||||
|
|
||||||
# ----------- Tomcat 9 ----------- #
|
# ----------- Tomcat 9 ----------- #
|
||||||
TOMCAT_VER=9.0.109
|
|
||||||
if [ ! -d /opt/apache-tomcat-${TOMCAT_VER} ]; then
|
if [ ! -d /opt/apache-tomcat-${TOMCAT_VER} ]; then
|
||||||
echo -e "${BLUE}>>> Installing Tomcat ${TOMCAT_VER}...${NC}"
|
echo -e "${BLUE}>>> Installing Tomcat ${TOMCAT_VER}...${NC}"
|
||||||
cd /opt
|
cd /opt
|
||||||
@@ -93,25 +118,96 @@ systemctl daemon-reload
|
|||||||
systemctl enable --now tomcat9
|
systemctl enable --now tomcat9
|
||||||
|
|
||||||
# ----------- Guacamole ----------- #
|
# ----------- Guacamole ----------- #
|
||||||
echo -e "${BLUE}>>> Installing Guacamole...${NC}"
|
|
||||||
cd /root
|
cd /root
|
||||||
curl -sSL https://raw.githubusercontent.com/MysticRyuujin/guac-install/master/guac-install.sh -o guac-install.sh
|
if [ ! -d guacamole-server-${GUACVERSION} ]; then
|
||||||
chmod +x guac-install.sh
|
echo -e "${BLUE}>>> Downloading Guacamole ${GUACVERSION}...${NC}"
|
||||||
|
SERVER="https://downloads.apache.org/guacamole/${GUACVERSION}"
|
||||||
|
wget -q ${SERVER}/source/guacamole-server-${GUACVERSION}.tar.gz
|
||||||
|
tar -xzf guacamole-server-${GUACVERSION}.tar.gz
|
||||||
|
wget -q ${SERVER}/binary/guacamole-${GUACVERSION}.war -O /etc/guacamole.war
|
||||||
|
wget -q ${SERVER}/binary/guacamole-auth-jdbc-${GUACVERSION}.tar.gz
|
||||||
|
tar -xzf guacamole-auth-jdbc-${GUACVERSION}.tar.gz
|
||||||
|
fi
|
||||||
|
|
||||||
# Patch installer to use /opt/tomcat9
|
# Build guacd if not installed
|
||||||
sed -i 's#/var/lib/${TOMCAT}/webapps/#/opt/tomcat9/webapps/#' guac-install.sh
|
if ! command -v guacd >/dev/null 2>&1; then
|
||||||
sed -i 's/service ${TOMCAT} restart/systemctl restart tomcat9/' guac-install.sh
|
echo -e "${BLUE}>>> Building guacd...${NC}"
|
||||||
sed -i 's/systemctl enable ${TOMCAT}/systemctl enable tomcat9/' guac-install.sh
|
cd guacamole-server-${GUACVERSION}
|
||||||
sed -i 's/echo -e "${RED}Failed. Can.t find Tomcat package.*exit 1/echo "Using external Tomcat9"/' guac-install.sh
|
./configure --with-systemd-dir=/etc/systemd/system
|
||||||
|
make -j$(nproc)
|
||||||
|
make install
|
||||||
|
ldconfig
|
||||||
|
cd ..
|
||||||
|
fi
|
||||||
|
|
||||||
# Run installer (idempotent: drops db if exists, recreates)
|
# guacd service
|
||||||
./guac-install.sh --mysqlpwd password --guacpwd password --nomfa --installmysql || true
|
if [ ! -f /etc/systemd/system/guacd.service ]; then
|
||||||
rm guac-install.sh
|
cat > /etc/systemd/system/guacd.service <<EOF
|
||||||
|
[Unit]
|
||||||
|
Description=Guacamole proxy daemon
|
||||||
|
After=network.target
|
||||||
|
|
||||||
# ----------- guacd sanity ----------- #
|
[Service]
|
||||||
systemctl enable guacd || true
|
Type=simple
|
||||||
systemctl restart guacd || true
|
ExecStart=/usr/local/sbin/guacd -f
|
||||||
pgrep -x guacd >/dev/null || (echo -e "${RED}guacd failed to start, try running manually${NC}")
|
User=daemon
|
||||||
|
Group=daemon
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
systemctl daemon-reload
|
||||||
|
systemctl enable --now guacd
|
||||||
|
|
||||||
|
# Deploy webapp + extensions
|
||||||
|
mkdir -p /etc/guacamole/extensions /etc/guacamole/lib
|
||||||
|
cp /etc/guacamole.war /opt/tomcat9/webapps/guacamole.war
|
||||||
|
cp guacamole-auth-jdbc-${GUACVERSION}/mysql/guacamole-auth-jdbc-mysql-${GUACVERSION}.jar /etc/guacamole/extensions/
|
||||||
|
|
||||||
|
# MySQL setup
|
||||||
|
echo -e "${BLUE}>>> Setting up MySQL database...${NC}"
|
||||||
|
mysql -u root -p${MYSQL_ROOT_PWD} -e "DROP DATABASE IF EXISTS ${GUAC_DB}; CREATE DATABASE ${GUAC_DB};"
|
||||||
|
mysql -u root -p${MYSQL_ROOT_PWD} -e "DROP USER IF EXISTS '${GUAC_USER}'@'localhost'; CREATE USER '${GUAC_USER}'@'localhost' IDENTIFIED BY '${GUAC_PWD}'; GRANT SELECT,INSERT,UPDATE,DELETE ON ${GUAC_DB}.* TO '${GUAC_USER}'@'localhost'; FLUSH PRIVILEGES;"
|
||||||
|
cat guacamole-auth-jdbc-${GUACVERSION}/mysql/schema/*.sql | mysql -u root -p${MYSQL_ROOT_PWD} ${GUAC_DB}
|
||||||
|
|
||||||
|
cat > /etc/guacamole/guacamole.properties <<EOF
|
||||||
|
mysql-hostname: localhost
|
||||||
|
mysql-port: 3306
|
||||||
|
mysql-database: ${GUAC_DB}
|
||||||
|
mysql-username: ${GUAC_USER}
|
||||||
|
mysql-password: ${GUAC_PWD}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
systemctl restart tomcat9
|
||||||
|
|
||||||
|
# ----------- Chrome ----------- #
|
||||||
|
if ! command -v google-chrome >/dev/null 2>&1; then
|
||||||
|
echo -e "${BLUE}>>> Installing Google Chrome...${NC}"
|
||||||
|
ARCH=$(dpkg --print-architecture)
|
||||||
|
if [ "$ARCH" = "amd64" ]; then
|
||||||
|
CHROME_DEB="https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb"
|
||||||
|
elif [ "$ARCH" = "arm64" ]; then
|
||||||
|
CHROME_DEB="https://dl.google.com/linux/direct/google-chrome-stable_current_arm64.deb"
|
||||||
|
fi
|
||||||
|
TMP_DEB="/tmp/chrome.deb"
|
||||||
|
wget -q -O "$TMP_DEB" "$CHROME_DEB"
|
||||||
|
dpkg -i "$TMP_DEB" || apt-get install -f -y
|
||||||
|
rm -f "$TMP_DEB"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ----------- Tampermonkey ----------- #
|
||||||
|
EXT_ID="dhdgffkkebhmkfjojejmpbldmpobfkfo"
|
||||||
|
EXT_DIR="/opt/google/chrome/extensions"
|
||||||
|
if [ ! -f "$EXT_DIR/$EXT_ID.json" ]; then
|
||||||
|
echo -e "${BLUE}>>> Registering Tampermonkey...${NC}"
|
||||||
|
mkdir -p "$EXT_DIR"
|
||||||
|
cat > "$EXT_DIR/$EXT_ID.json" <<EOF
|
||||||
|
{
|
||||||
|
"external_update_url": "https://clients2.google.com/service/update2/crx"
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
# ----------- Final info ----------- #
|
# ----------- Final info ----------- #
|
||||||
IP=$(curl -s ifconfig.me || echo "localhost")
|
IP=$(curl -s ifconfig.me || echo "localhost")
|
||||||
|
|||||||
Reference in New Issue
Block a user