From 801d5cf0aa39bdaf03af9f7cc415fe4ee3bea9cf Mon Sep 17 00:00:00 2001 From: WLTBAgent Date: Mon, 23 Feb 2026 23:59:10 +0000 Subject: [PATCH] Complete rewrite of build.sh credential prompts Removed confusing headers and simplified logic: - IMAP credentials are now REQUIRED (no defaults) - SMTP credentials use IMAP defaults if not specified separately - IMAP validation applies to both sets - Clearer prompts without confusing default messages This should fix empty credential issues by requiring IMAP credentials to be explicitly entered. --- build.sh | 64 ++++++++++++++++++++++---------------------------------- 1 file changed, 25 insertions(+), 39 deletions(-) diff --git a/build.sh b/build.sh index 36ab352..5f308fa 100755 --- a/build.sh +++ b/build.sh @@ -7,9 +7,6 @@ set -e # Check arguments if [ $# -ne 3 ]; then echo "Usage: $0 " - echo "" - echo "Example:" - echo " $0 https://teamworkapps.com wltbagent@shortcutsolutions.net YOUR_APP_TOKEN" exit 1 fi @@ -17,25 +14,21 @@ SERVER_URL="$1" USERNAME="$2" TOKEN="$3" +echo "" echo "Building Nextcloud CLI tools with credentials..." -echo "Server: $SERVER_URL" -echo "User: $USERNAME" -echo "Token: ${TOKEN:0:10}..." -echo "" -echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -echo "Email Integration Setup (IMAP/SMTP)" -echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -echo "" -echo "Nextcloud Mail uses different credentials from other Nextcloud tools." -echo "These are IMAP/SMTP credentials, not Nextcloud API credentials." +echo " Server: $SERVER_URL" +echo " Username: $USERNAME" +echo " Token: ${TOKEN:0:10}..." echo "" # Prompt for email credentials -echo "" -read -p "IMAP Server hostname (default: teamworkapps.com): " IMAP_SERVER -IMAP_SERVER=${IMAP_SERVER:-teamworkapps.com} +read -p "IMAP Server hostname: " IMAP_SERVER +if [ -z "$IMAP_SERVER" ]; then + echo "❌ Error: IMAP server cannot be empty" + exit 1 +fi -read -p "IMAP Port (default: 993 for SSL, 143 for STARTTLS): " IMAP_PORT +read -p "IMAP Port (default: 993): " IMAP_PORT IMAP_PORT=${IMAP_PORT:-993} read -p "IMAP Username: " IMAP_USER @@ -50,25 +43,24 @@ if [ -z "$IMAP_PASS" ]; then exit 1 fi -echo "" -echo "" -read -p "SMTP Server hostname (default: teamworkapps.com): " SMTP_SERVER +read -p "SMTP Server hostname: " SMTP_SERVER SMTP_SERVER=${SMTP_SERVER:-teamworkapps.com} -read -p "SMTP Port (default: 465 for SSL, 587 for STARTTLS): " SMTP_PORT +read -p "SMTP Port (default: 465): " SMTP_PORT SMTP_PORT=${SMTP_PORT:-465} -read -p "SMTP Username (default: same as IMAP): " SMTP_USER -SMTP_USER=${SMTP_USER:-$IMAP_USER} +read -p "SMTP Username: " SMTP_USER +if [ -z "$SMTP_USER" ]; then + SMTP_USER="$IMAP_USER" +fi -read -sp "SMTP Password (default: same as IMAP): " SMTP_PASS +read -sp "SMTP Password: " SMTP_PASS if [ -z "$SMTP_PASS" ]; then SMTP_PASS="$IMAP_PASS" fi read -p "Use SSL/TLS? (Y/n, default: Y): " USE_SSL USE_SSL=${USE_SSL:-Y} - if [ "$USE_SSL" = "Y" ] || [ "$USE_SSL" = "y" ]; then USE_SSL="true" else @@ -77,25 +69,14 @@ fi read -p "Ignore certificate validity errors? (y/N, default: N): " IGNORE_CERTS IGNORE_CERTS=${IGNORE_CERTS:-N} - if [ "$IGNORE_CERTS" = "Y" ] || [ "$IGNORE_CERTS" = "y" ]; then IGNORE_CERTS="true" else IGNORE_CERTS="false" fi -echo "" -echo "━━━━━━━━━━━━━━━━━━━━━━━━━━" -echo "Email Credentials Summary:" -echo "━━━━━━━━━━━━━━━━━━━━━━━━━━" -echo "" -echo " IMAP: $IMAP_USER@$IMAP_SERVER:$IMAP_PORT (SSL: $USE_SSL)" -echo " SMTP: $SMTP_USER@$SMTP_SERVER:$SMTP_PORT (SSL: $USE_SSL)" -echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -echo "" - # Build nextcloud-client -echo "Building nextcloud-client" +echo "Building nextcloud-client..." SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" cd "$SCRIPT_DIR/tools/go/nextcloud-client" go build -ldflags="-X main.BuildServerURL=$SERVER_URL -X main.BuildUsername=$USERNAME -X main.BuildToken=$TOKEN" -o ~/bin/nextcloud-client . @@ -118,7 +99,6 @@ echo "Building nextcloud-mail..." cd "$SCRIPT_DIR/tools/go/nextcloud-mail" # Build with compile-time credentials using multiple -ldflags arguments -# This approach handles ALL special characters: spaces, quotes, #, $, @, etc. go build \ -ldflags="-X main.BuildIMAPServer=$IMAP_SERVER" \ -ldflags="-X main.BuildIMAPPort=$IMAP_PORT" \ @@ -131,7 +111,13 @@ go build \ -ldflags="-X main.BuildUseSSL=$USE_SSL" \ -ldflags="-X main.BuildIgnoreCerts=$IGNORE_CERTS" \ -o ~/bin/nextcloud-mail -echo "✓ nextcloud-mail built successfully" + +if [ $? -eq 0 ]; then + echo "✓ nextcloud-mail built successfully" +else + echo "❌ Build failed" + exit 1 +fi echo "" echo "All tools built successfully!"