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.
This commit is contained in:
WLTBAgent committed 2026-02-23 23:59:10 +00:00
1 parent 497f9ccb3b
commit 801d5cf0aa
1 file changed
+25 -39
+25 -39
View File
@@ -7,9 +7,6 @@ set -e
# Check arguments # Check arguments
if [ $# -ne 3 ]; then if [ $# -ne 3 ]; then
echo "Usage: $0 <server-url> <username> <token>" echo "Usage: $0 <server-url> <username> <token>"
echo ""
echo "Example:"
echo " $0 https://teamworkapps.com wltbagent@shortcutsolutions.net YOUR_APP_TOKEN"
exit 1 exit 1
fi fi
@@ -17,25 +14,21 @@ SERVER_URL="$1"
USERNAME="$2" USERNAME="$2"
TOKEN="$3" TOKEN="$3"
echo ""
echo "Building Nextcloud CLI tools with credentials..." echo "Building Nextcloud CLI tools with credentials..."
echo "Server: $SERVER_URL" echo " Server: $SERVER_URL"
echo "User: $USERNAME" echo " Username: $USERNAME"
echo "Token: ${TOKEN:0:10}..." 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 "" echo ""
# Prompt for email credentials # Prompt for email credentials
echo "" read -p "IMAP Server hostname: " IMAP_SERVER
read -p "IMAP Server hostname (default: teamworkapps.com): " IMAP_SERVER if [ -z "$IMAP_SERVER" ]; then
IMAP_SERVER=${IMAP_SERVER:-teamworkapps.com} 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} IMAP_PORT=${IMAP_PORT:-993}
read -p "IMAP Username: " IMAP_USER read -p "IMAP Username: " IMAP_USER
@@ -50,25 +43,24 @@ if [ -z "$IMAP_PASS" ]; then
exit 1 exit 1
fi fi
echo "" read -p "SMTP Server hostname: " SMTP_SERVER
echo ""
read -p "SMTP Server hostname (default: teamworkapps.com): " SMTP_SERVER
SMTP_SERVER=${SMTP_SERVER:-teamworkapps.com} 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} SMTP_PORT=${SMTP_PORT:-465}
read -p "SMTP Username (default: same as IMAP): " SMTP_USER read -p "SMTP Username: " SMTP_USER
SMTP_USER=${SMTP_USER:-$IMAP_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 if [ -z "$SMTP_PASS" ]; then
SMTP_PASS="$IMAP_PASS" SMTP_PASS="$IMAP_PASS"
fi fi
read -p "Use SSL/TLS? (Y/n, default: Y): " USE_SSL read -p "Use SSL/TLS? (Y/n, default: Y): " USE_SSL
USE_SSL=${USE_SSL:-Y} USE_SSL=${USE_SSL:-Y}
if [ "$USE_SSL" = "Y" ] || [ "$USE_SSL" = "y" ]; then if [ "$USE_SSL" = "Y" ] || [ "$USE_SSL" = "y" ]; then
USE_SSL="true" USE_SSL="true"
else else
@@ -77,25 +69,14 @@ fi
read -p "Ignore certificate validity errors? (y/N, default: N): " IGNORE_CERTS read -p "Ignore certificate validity errors? (y/N, default: N): " IGNORE_CERTS
IGNORE_CERTS=${IGNORE_CERTS:-N} IGNORE_CERTS=${IGNORE_CERTS:-N}
if [ "$IGNORE_CERTS" = "Y" ] || [ "$IGNORE_CERTS" = "y" ]; then if [ "$IGNORE_CERTS" = "Y" ] || [ "$IGNORE_CERTS" = "y" ]; then
IGNORE_CERTS="true" IGNORE_CERTS="true"
else else
IGNORE_CERTS="false" IGNORE_CERTS="false"
fi 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 # Build nextcloud-client
echo "Building nextcloud-client" echo "Building nextcloud-client..."
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$SCRIPT_DIR/tools/go/nextcloud-client" 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 . 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" cd "$SCRIPT_DIR/tools/go/nextcloud-mail"
# Build with compile-time credentials using multiple -ldflags arguments # Build with compile-time credentials using multiple -ldflags arguments
# This approach handles ALL special characters: spaces, quotes, #, $, @, etc.
go build \ go build \
-ldflags="-X main.BuildIMAPServer=$IMAP_SERVER" \ -ldflags="-X main.BuildIMAPServer=$IMAP_SERVER" \
-ldflags="-X main.BuildIMAPPort=$IMAP_PORT" \ -ldflags="-X main.BuildIMAPPort=$IMAP_PORT" \
@@ -131,7 +111,13 @@ go build \
-ldflags="-X main.BuildUseSSL=$USE_SSL" \ -ldflags="-X main.BuildUseSSL=$USE_SSL" \
-ldflags="-X main.BuildIgnoreCerts=$IGNORE_CERTS" \ -ldflags="-X main.BuildIgnoreCerts=$IGNORE_CERTS" \
-o ~/bin/nextcloud-mail -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 ""
echo "All tools built successfully!" echo "All tools built successfully!"