diff --git a/build.sh b/build.sh index df0cf29..8e4b7d3 100755 --- a/build.sh +++ b/build.sh @@ -21,19 +21,27 @@ echo "Token: ${TOKEN:0:10}..." echo "" # Prompt for email credentials -echo "━━━━━━━━━━━━━━━━━━━━━━" +echo "━━━━━━━━━━━━━━━━━━" echo "Enter IMAP and SMTP credentials for nextcloud-mail" -echo "━━━━━━━━━━━━━━━━━━━━━━━━━━" +echo "━━━━━━━━━━━━━━━━━━━━━━" echo "" echo "Nextcloud Mail uses different credentials from other Nextcloud tools." echo "These are IMAP/SMTP credentials, not Nextcloud API credentials." echo "" -# Prompt for email credentials with proper quoting -read -p "IMAP Server hostname [default: teamworkapps.com]: " IMAP_SERVER +# Prompt for email credentials +echo "━━━━━━━━━━━━━━━━━━━━━━━━" +echo "Email Integration Setup (IMAP/SMTP)" +echo "━━━━━━━━━━━━━━━━━━━━━━" +echo "" +echo "IMAP and SMTP credentials will be embedded at compile time." +echo "Provide values below, or press Enter to leave a field empty (uses default)." +echo "" + +read -p "IMAP Server hostname [required]: " IMAP_SERVER IMAP_SERVER="${IMAP_SERVER:-teamworkapps.com}" -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 [required]: " IMAP_USER @@ -51,61 +59,52 @@ fi read -p "SMTP Server hostname [default: teamworkapps.com]: " 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_INPUT -read -sp "SMTP Password [default: same as IMAP]: " SMTP_PASS_INPUT -echo "" - -# Apply defaults for SMTP if user left them empty -if [ -z "$SMTP_USER_INPUT" ] && [ -z "$SMTP_PASS_INPUT" ]; then +read -p "SMTP Username [default: same as IMAP]: " SMTP_USER +read -sp "SMTP Username" +if [ -z "$SMTP_USER" ]; then SMTP_USER="$IMAP_USER" +fi + +read -sp "SMTP Password [default: same as IMAP]: " SMTP_PASS +if [ -z "$SMTP_PASS" ]; then SMTP_PASS="$IMAP_PASS" -else - SMTP_USER="${SMTP_USER_INPUT}" - SMTP_PASS="${SMTP_PASS_INPUT}" fi -# Validate SMTP username/password if provided -if [ "$SMTP_USER_INPUT" ] && [ -z "$SMTP_USER" ]; then - echo "❌ Error: SMTP username is empty" - exit 1 -fi - -if [ "$SMTP_PASS_INPUT" ] && [ -z "$SMTP_PASS" ]; then - echo "❌ Error: SMTP password is empty" - exit 1 -fi - -read -p "Use SSL/TLS? [Y/n, default: Y]: " USE_SSL_INPUT -USE_SSL="${USE_SSL_INPUT:-Y}" - -if [ "$USE_SSL_INPUT" = "Y" ] || [ "$USE_SSL_INPUT" = "y" ]; then +read -p "Use SSL/TLS? [default: Y]: " USE_SSL +USE_SSL="${USE_SSL:-Y}" +if [ "$USE_SSL" = "Y" ] || [ "$USE_SSL" = "y" ]; then USE_SSL="true" else USE_SSL="false" fi -read -p "Ignore certificate validity errors? [y/N, default: N]: " IGNORE_CERTS_INPUT -IGNORE_CERTS="${IGNORE_CERTS_INPUT:-N}" - -if [ "$IGNORE_CERTS_INPUT" = "Y" ] || [ "$IGNORE_CERTS_INPUT" = "y" ]; then +read -p "Ignore certificate validity errors? [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 "Build Summary" +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━" echo "" -echo " IMAP: $IMAP_USER@$IMAP_SERVER:$IMAP_PORT" -echo " SMTP: $SMTP_USER@$SMTP_SERVER:$SMTP_PORT" +echo " IMAP Server: $IMAP_SERVER" +echo " IMAP Port: $IMAP_PORT" +echo " IMAP Username: $IMAP_USER" +echo " IMAP Password: [hidden]" +echo " SMTP Server: $SMTP_SERVER" +echo " SMTP Port: $SMTP_PORT" +echo " SMTP Username: $SMTP_USER" +echo " SMTP Password: [hidden]" echo " SSL: $USE_SSL" echo " Ignore Certs: $IGNORE_CERTS" -echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" echo "" # Build nextcloud-client @@ -131,8 +130,8 @@ echo "✓ nextcloud-calendar built successfully" echo "Building nextcloud-mail..." cd "$SCRIPT_DIR/tools/go/nextcloud-mail" -# Build with compile-time credentials using multiple -ldflags arguments -# Each value is double-quoted to ensure Go receives them correctly +# Build with compile-time credentials +# Using -X "name"="value" format ensures Go receives actual strings, not empty defaults go build \ -ldflags="-X main.BuildIMAPServer=\"$IMAP_SERVER\"" \ -ldflags="-X main.BuildIMAPPort=\"$IMAP_PORT\"" \