Refactor install_guac.sh for improved parameter handling
This commit is contained in:
committed by
GitHub
parent
98a5c6439d
commit
a0387422b3
+20
-20
@@ -14,20 +14,24 @@ GUAC_DB="guacamole_db"
|
|||||||
TOMCAT_VER=9.0.109
|
TOMCAT_VER=9.0.109
|
||||||
CRED_FILE="/root/guacamole-credentials.txt"
|
CRED_FILE="/root/guacamole-credentials.txt"
|
||||||
|
|
||||||
# --- Ask for parameters ---
|
# --- Parameters (env or interactive) ---
|
||||||
while true; do
|
SERVER_NAME=${SERVER_NAME:-}
|
||||||
read -p "Enter server name (FQDN) for Nginx/Let's Encrypt (e.g. guac.example.com): " SERVER_NAME
|
if [ -z "$SERVER_NAME" ]; then
|
||||||
if [ -n "$SERVER_NAME" ]; then break; fi
|
if [ -t 0 ]; then
|
||||||
echo -e "${RED}Server name cannot be empty!${NC}"
|
while true; do
|
||||||
done
|
read -p "Enter server name (FQDN) for Nginx/Let's Encrypt (e.g. guac.example.com): " SERVER_NAME
|
||||||
|
[ -n "$SERVER_NAME" ] && break
|
||||||
|
echo -e "${RED}Server name cannot be empty!${NC}"
|
||||||
|
done
|
||||||
|
else
|
||||||
|
echo -e "${RED}ERROR: SERVER_NAME not provided and no TTY available${NC}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
read -p "Advertise local LAN routes via Tailscale? (y/N): " ADV_ROUTES
|
MYSQL_ROOT_PWD=${MYSQL_ROOT_PWD:-$(openssl rand -base64 20)}
|
||||||
ADV_ROUTES=${ADV_ROUTES:-N}
|
GUAC_PWD=${GUAC_PWD:-$(openssl rand -base64 20)}
|
||||||
|
GUACADMIN_PWD=${GUACADMIN_PWD:-$(openssl rand -base64 20)}
|
||||||
# --- Secure password generation ---
|
|
||||||
MYSQL_ROOT_PWD=$(openssl rand -base64 20)
|
|
||||||
GUAC_PWD=$(openssl rand -base64 20)
|
|
||||||
GUACADMIN_PWD=$(openssl rand -base64 20)
|
|
||||||
|
|
||||||
# --- Base packages ---
|
# --- Base packages ---
|
||||||
echo -e "${BLUE}>>> Installing base packages...${NC}"
|
echo -e "${BLUE}>>> Installing base packages...${NC}"
|
||||||
@@ -254,13 +258,9 @@ echo -e "${BLUE}>>> Installing Tailscale...${NC}"
|
|||||||
curl -fsSL https://tailscale.com/install.sh | sh
|
curl -fsSL https://tailscale.com/install.sh | sh
|
||||||
systemctl enable --now tailscaled
|
systemctl enable --now tailscaled
|
||||||
|
|
||||||
read -p "Enter Tailscale auth key (leave blank for interactive login): " TSKEY
|
read -p "Enter Tailscale auth key (leave blank for interactive login): " TSKEY || true
|
||||||
if [ -n "$TSKEY" ]; then
|
if [ -n "${TSKEY:-}" ]; then
|
||||||
if [[ "${ADV_ROUTES,,}" == "y" ]]; then
|
tailscale up --authkey=${TSKEY} --ssh
|
||||||
tailscale up --authkey=${TSKEY} --ssh --advertise-routes=$(ip -o -f inet addr show | awk '/scope global/ {print $4}' | paste -sd,)
|
|
||||||
else
|
|
||||||
tailscale up --authkey=${TSKEY} --ssh
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
tailscale up --ssh
|
tailscale up --ssh
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user