...
This commit is contained in:
53
scripts/buildscripts/build_and_run.sh
Executable file
53
scripts/buildscripts/build_and_run.sh
Executable file
@@ -0,0 +1,53 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Colors for better output
|
||||
GREEN='\033[0;32m'
|
||||
RED='\033[0;31m'
|
||||
YELLOW='\033[0;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
PROJECT_ROOT=$(pwd)
|
||||
SERVER_MAIN="$PROJECT_ROOT/cmd/server/main.go"
|
||||
OUTPUT_BIN="$PROJECT_ROOT/bin/heroagent"
|
||||
|
||||
echo -e "${YELLOW}Starting build process for HeroLauncher...${NC}"
|
||||
|
||||
# Create bin directory if it doesn't exist
|
||||
mkdir -p "$PROJECT_ROOT/bin"
|
||||
|
||||
# Make sure dependencies are up to date
|
||||
echo -e "${YELLOW}Updating dependencies...${NC}"
|
||||
go mod tidy
|
||||
if [ $? -ne 0 ]; then
|
||||
echo -e "${RED}Failed to update dependencies${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Run linter
|
||||
echo -e "${YELLOW}Running linter...${NC}"
|
||||
if command -v golangci-lint &> /dev/null; then
|
||||
golangci-lint run ./...
|
||||
if [ $? -ne 0 ]; then
|
||||
echo -e "${YELLOW}Linting issues found. Attempting to fix automatically...${NC}"
|
||||
golangci-lint run --fix ./...
|
||||
fi
|
||||
else
|
||||
echo -e "${YELLOW}golangci-lint not found, skipping linting. Consider installing it with:${NC}"
|
||||
echo -e "${YELLOW}go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest${NC}"
|
||||
fi
|
||||
|
||||
# Build the server
|
||||
echo -e "${YELLOW}Building server...${NC}"
|
||||
go build -o "$OUTPUT_BIN" "$SERVER_MAIN"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo -e "${RED}Build failed${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -e "${GREEN}Build successful!${NC}"
|
||||
echo -e "${GREEN}Binary located at: $OUTPUT_BIN${NC}"
|
||||
|
||||
# Run the server
|
||||
echo -e "${YELLOW}Starting server...${NC}"
|
||||
"$OUTPUT_BIN"
|
42
scripts/buildscripts/build_test.sh
Executable file
42
scripts/buildscripts/build_test.sh
Executable file
@@ -0,0 +1,42 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Clean up and create bin directory
|
||||
rm -rf bin
|
||||
mkdir -p bin
|
||||
|
||||
# Create a log file
|
||||
LOG_FILE="build_test.log"
|
||||
echo "Build test started at $(date)" > $LOG_FILE
|
||||
|
||||
# Build each component
|
||||
for dir in cmd/*; do
|
||||
if [ -f "$dir/main.go" ]; then
|
||||
component=$(basename $dir)
|
||||
|
||||
# Skip components with known build issues
|
||||
if [ "$component" == "processmanager" ] || [ "$component" == "vfsdavserver" ]; then
|
||||
echo "Skipping $component due to known build issues..." | tee -a $LOG_FILE
|
||||
continue
|
||||
fi
|
||||
|
||||
echo "Building $component..." | tee -a $LOG_FILE
|
||||
GOOS=linux GOARCH=amd64 go build -v -o bin/$component-linux-amd64 ./$dir 2>&1 | tee -a $LOG_FILE
|
||||
if [ ${PIPESTATUS[0]} -ne 0 ]; then
|
||||
echo "Error building $component" | tee -a $LOG_FILE
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
echo "All components built successfully" | tee -a $LOG_FILE
|
||||
ls -la bin/ | tee -a $LOG_FILE
|
||||
|
||||
# Create archive
|
||||
echo "Creating archive..." | tee -a $LOG_FILE
|
||||
tar -czf heroagent-linux-amd64.tar.gz bin/ 2>&1 | tee -a $LOG_FILE
|
||||
echo "Archive created successfully" | tee -a $LOG_FILE
|
||||
ls -la heroagent-linux-amd64.tar.gz | tee -a $LOG_FILE
|
||||
|
||||
echo "Build test completed at $(date)" | tee -a $LOG_FILE
|
||||
echo "Log file: $LOG_FILE"
|
44
scripts/connect_to_webdav.sh
Executable file
44
scripts/connect_to_webdav.sh
Executable file
@@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
|
||||
# This script helps connect to the WebDAV server from macOS Finder
|
||||
|
||||
# WebDAV server details
|
||||
SERVER_HOST="localhost"
|
||||
SERVER_PORT="9999"
|
||||
USERNAME="admin"
|
||||
PASSWORD="1234"
|
||||
PROTOCOL="http" # Change to https if your server uses HTTPS
|
||||
|
||||
# Create the WebDAV URL
|
||||
WEBDAV_URL="${PROTOCOL}://${SERVER_HOST}:${SERVER_PORT}/"
|
||||
|
||||
echo "===== WebDAV Connection Helper ====="
|
||||
echo "WebDAV URL: ${WEBDAV_URL}"
|
||||
echo "Username: ${USERNAME}"
|
||||
echo "Password: ${PASSWORD}"
|
||||
echo ""
|
||||
|
||||
echo "To connect from macOS Finder:"
|
||||
echo "1. In Finder, press Cmd+K or select 'Go > Connect to Server...'"
|
||||
echo "2. Enter the WebDAV URL: ${WEBDAV_URL}"
|
||||
echo "3. Click 'Connect'"
|
||||
echo "4. When prompted, enter the username and password"
|
||||
echo ""
|
||||
|
||||
echo "Testing WebDAV connection..."
|
||||
curl -u "${USERNAME}:${PASSWORD}" -X PROPFIND "${WEBDAV_URL}" -H "Depth: 1" -v
|
||||
|
||||
echo ""
|
||||
echo "If you see a 207 Multi-Status response above, the WebDAV server is accessible."
|
||||
echo "If you're still having trouble connecting from Finder, try these troubleshooting steps:"
|
||||
echo ""
|
||||
echo "1. Make sure the server is running with authentication enabled:"
|
||||
echo " ./bin/webdavserver -auth -debug"
|
||||
echo ""
|
||||
echo "2. For HTTPS connections, macOS requires trusted certificates. You may need to:"
|
||||
echo " a. Import the self-signed certificate into your macOS Keychain"
|
||||
echo " b. Or run the server with HTTP instead for testing purposes"
|
||||
echo ""
|
||||
echo "3. Try connecting with a different WebDAV client like Cyberduck or Transmit"
|
||||
echo ""
|
||||
echo "4. Check if your firewall is blocking the connection"
|
71
scripts/generate_cert.sh
Executable file
71
scripts/generate_cert.sh
Executable file
@@ -0,0 +1,71 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Script to generate a self-signed certificate for WebDAV HTTPS testing
|
||||
|
||||
# Default values
|
||||
CERT_DIR="./certs"
|
||||
CERT_FILE="$CERT_DIR/webdav.crt"
|
||||
KEY_FILE="$CERT_DIR/webdav.key"
|
||||
DAYS=365
|
||||
COMMON_NAME="localhost"
|
||||
|
||||
# Parse command line arguments
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
-d|--dir)
|
||||
CERT_DIR="$2"
|
||||
CERT_FILE="$CERT_DIR/webdav.crt"
|
||||
KEY_FILE="$CERT_DIR/webdav.key"
|
||||
shift 2
|
||||
;;
|
||||
-cn|--common-name)
|
||||
COMMON_NAME="$2"
|
||||
shift 2
|
||||
;;
|
||||
-days)
|
||||
DAYS="$2"
|
||||
shift 2
|
||||
;;
|
||||
-h|--help)
|
||||
echo "Usage: $0 [options]"
|
||||
echo "Options:"
|
||||
echo " -d, --dir DIR Directory to store certificates (default: ./certs)"
|
||||
echo " -cn, --common-name CN Common name for certificate (default: localhost)"
|
||||
echo " -days DAYS Validity period in days (default: 365)"
|
||||
echo " -h, --help Show this help message"
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Unknown option: $1"
|
||||
echo "Use --help for usage information"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Create certificate directory if it doesn't exist
|
||||
mkdir -p "$CERT_DIR"
|
||||
|
||||
echo "Generating self-signed certificate for $COMMON_NAME"
|
||||
echo "Certificate will be valid for $DAYS days"
|
||||
echo "Files will be stored in $CERT_DIR"
|
||||
|
||||
# Generate private key and certificate
|
||||
openssl req -x509 -newkey rsa:4096 -keyout "$KEY_FILE" -out "$CERT_FILE" -days "$DAYS" -nodes -subj "/CN=$COMMON_NAME"
|
||||
|
||||
# Check if generation was successful
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Certificate generation successful!"
|
||||
echo "Certificate: $CERT_FILE"
|
||||
echo "Private key: $KEY_FILE"
|
||||
|
||||
# Make the files readable
|
||||
chmod 644 "$CERT_FILE"
|
||||
chmod 600 "$KEY_FILE"
|
||||
|
||||
echo ""
|
||||
echo "To use these certificates with the WebDAV server, run:"
|
||||
echo "go run cmd/webdavserver/main.go -https -cert $CERT_FILE -key $KEY_FILE [other options]"
|
||||
else
|
||||
echo "Certificate generation failed!"
|
||||
fi
|
260
scripts/install.sh
Executable file
260
scripts/install.sh
Executable file
@@ -0,0 +1,260 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
# Function to print colored output
|
||||
print_color() {
|
||||
local color=$1
|
||||
local text=$2
|
||||
case $color in
|
||||
"red") echo -e "\033[0;31m$text\033[0m" ;;
|
||||
"green") echo -e "\033[0;32m$text\033[0m" ;;
|
||||
"yellow") echo -e "\033[0;33m$text\033[0m" ;;
|
||||
"blue") echo -e "\033[0;34m$text\033[0m" ;;
|
||||
*) echo "$text" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Function to get the latest release version from GitHub
|
||||
get_latest_release() {
|
||||
# Use a simpler approach with curl and grep
|
||||
local version
|
||||
version=$(curl -s "https://api.github.com/repos/freeflowuniverse/heroagent/releases/latest" |
|
||||
grep -o '"tag_name": *"[^"]*"' |
|
||||
sed 's/.*"v\?\([^"]*\)".*/\1/')
|
||||
|
||||
# If version is empty, use a default version
|
||||
if [ -z "$version" ]; then
|
||||
print_color "yellow" "Could not determine version from API response. Using default version."
|
||||
echo "0.1.0"
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo "$version"
|
||||
}
|
||||
|
||||
# Determine OS and architecture
|
||||
os_name="$(uname -s)"
|
||||
arch_name="$(uname -m)"
|
||||
|
||||
# Map architecture names
|
||||
case "$arch_name" in
|
||||
"x86_64") arch="amd64" ;;
|
||||
"aarch64" | "arm64") arch="arm64" ;;
|
||||
*)
|
||||
print_color "red" "Unsupported architecture: $arch_name"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# Map OS names
|
||||
case "$os_name" in
|
||||
"Linux") os="linux" ;;
|
||||
"Darwin") os="darwin" ;;
|
||||
*)
|
||||
print_color "red" "Unsupported operating system: $os_name"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# Get the latest version or use the specified one
|
||||
if [ -z "$1" ]; then
|
||||
print_color "blue" "Fetching latest release version..."
|
||||
# Capture the output of get_latest_release in a variable without any debug output
|
||||
version=$(get_latest_release 2>/dev/null)
|
||||
if [ -z "$version" ]; then
|
||||
print_color "red" "Error: Could not determine latest version"
|
||||
exit 1
|
||||
fi
|
||||
print_color "green" "Latest version: $version"
|
||||
else
|
||||
version="$1"
|
||||
print_color "blue" "Using specified version: $version"
|
||||
fi
|
||||
|
||||
# Determine file extension based on OS
|
||||
if [[ "$os" == "linux" || "$os" == "darwin" ]]; then
|
||||
ext="tar.gz"
|
||||
archive_name="heroagent-${os}-${arch}.${ext}"
|
||||
elif [[ "$os" == "windows" ]]; then
|
||||
ext="zip"
|
||||
archive_name="heroagent-${os}-${arch}.${ext}"
|
||||
else
|
||||
print_color "red" "Unsupported platform: $os $arch"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Construct the download URL - ensure version is clean
|
||||
version_clean=$(echo "$version" | tr -d '\n\r')
|
||||
base_url="https://github.com/freeflowuniverse/heroagent/releases/download/v${version_clean}"
|
||||
url="${base_url}/${archive_name}"
|
||||
|
||||
print_color "blue" "Download URL: $url"
|
||||
|
||||
# Check for existing heroagent installations
|
||||
print_color "blue" "Checking for existing installations..."
|
||||
existing_hero=$(which heroagent 2>/dev/null || true)
|
||||
if [ ! -z "$existing_hero" ]; then
|
||||
print_color "yellow" "Found existing heroagent installation at: $existing_hero"
|
||||
if [ -w "$(dirname "$existing_hero")" ]; then
|
||||
print_color "blue" "Removing existing heroagent installation..."
|
||||
rm "$existing_hero" || {
|
||||
print_color "red" "Error: Failed to remove existing heroagent binary at $existing_hero"
|
||||
exit 1
|
||||
}
|
||||
else
|
||||
print_color "red" "Error: Cannot remove existing heroagent installation at $existing_hero (permission denied)"
|
||||
print_color "yellow" "Please remove it manually with sudo and run this script again"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check for macOS-specific requirements
|
||||
if [[ "$os" == "darwin" ]]; then
|
||||
print_color "blue" "Detected macOS system, checking requirements..."
|
||||
|
||||
# Check if /usr/local/bin/heroagent exists and remove it
|
||||
if [ -f /usr/local/bin/heroagent ]; then
|
||||
print_color "yellow" "Removing existing heroagent binary from /usr/local/bin..."
|
||||
rm /usr/local/bin/heroagent 2>/dev/null || {
|
||||
print_color "red" "Error: Failed to remove existing heroagent binary from /usr/local/bin"
|
||||
print_color "yellow" "You may need to use sudo to remove it"
|
||||
}
|
||||
fi
|
||||
fi
|
||||
|
||||
# Ensure URL is valid
|
||||
if [ -z "$url" ]; then
|
||||
print_color "red" "Error: Could not determine download URL"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Set up trap to clean up temporary files on exit
|
||||
trap 'rm -rf "${temp_dir}" "${temp_file}" 2>/dev/null || true' EXIT
|
||||
|
||||
# Create installation directories
|
||||
install_dir="${HOME}/heroagent"
|
||||
bin_dir="${install_dir}/bin"
|
||||
mkdir -p "${bin_dir}"
|
||||
|
||||
# Download the archive
|
||||
print_color "blue" "Downloading HeroLauncher from: $url"
|
||||
temp_dir=$(mktemp -d)
|
||||
archive_path="${temp_dir}/${archive_name}"
|
||||
curl -L -o "${archive_path}" "${url}" || {
|
||||
print_color "red" "Error: Failed to download HeroLauncher"
|
||||
rm -rf "${temp_dir}"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Check if file size is reasonable (at least 1 MB)
|
||||
file_size=$(du -m "${archive_path}" | cut -f1)
|
||||
if [ "$file_size" -lt 1 ]; then
|
||||
print_color "red" "Error: Downloaded file is too small (${file_size}MB). Download may have failed."
|
||||
rm -rf "${temp_dir}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Extract the archive based on file type
|
||||
print_color "blue" "Extracting archive..."
|
||||
cd "${temp_dir}"
|
||||
if [[ "$ext" == "tar.gz" ]]; then
|
||||
tar -xzf "${archive_path}" || {
|
||||
print_color "red" "Error: Failed to extract tar.gz archive"
|
||||
rm -rf "${temp_dir}"
|
||||
exit 1
|
||||
}
|
||||
elif [[ "$ext" == "zip" ]]; then
|
||||
unzip "${archive_path}" || {
|
||||
print_color "red" "Error: Failed to extract zip archive"
|
||||
rm -rf "${temp_dir}"
|
||||
exit 1
|
||||
}
|
||||
fi
|
||||
|
||||
# Copy binaries to installation directory and create heroagent symlink
|
||||
print_color "blue" "Installing binaries to ${bin_dir}..."
|
||||
find bin -type f -executable | while read -r binary; do
|
||||
binary_name=$(basename "${binary}")
|
||||
cp "${binary}" "${bin_dir}/" || {
|
||||
print_color "red" "Error: Failed to copy ${binary_name} to ${bin_dir}"
|
||||
rm -rf "${temp_dir}"
|
||||
exit 1
|
||||
}
|
||||
chmod +x "${bin_dir}/${binary_name}"
|
||||
print_color "green" "Installed: ${bin_dir}/${binary_name}"
|
||||
|
||||
# Create heroagent symlink for the first binary (pmclient)
|
||||
if [[ "$binary_name" == *"pmclient"* ]]; then
|
||||
ln -sf "${bin_dir}/${binary_name}" "${bin_dir}/heroagent" || {
|
||||
print_color "red" "Error: Failed to create heroagent symlink"
|
||||
rm -rf "${temp_dir}"
|
||||
exit 1
|
||||
}
|
||||
print_color "green" "Created heroagent symlink to ${binary_name}"
|
||||
fi
|
||||
done
|
||||
|
||||
# Clean up temporary directory
|
||||
rm -rf "${temp_dir}"
|
||||
|
||||
# Update PATH in shell profile files
|
||||
print_color "blue" "Updating PATH in shell profile files..."
|
||||
for profile in "${HOME}/.bashrc" "${HOME}/.zshrc" "${HOME}/.bash_profile" "${HOME}/.zprofile"; do
|
||||
if [ -f "${profile}" ]; then
|
||||
# Remove any existing HeroLauncher PATH entries
|
||||
sed -i.bak '/heroagent/d' "${profile}" 2>/dev/null || true
|
||||
# Add new PATH entry
|
||||
echo "export PATH=\"\${PATH}:${bin_dir}\"" >> "${profile}"
|
||||
print_color "green" "Updated ${profile}"
|
||||
fi
|
||||
done
|
||||
|
||||
# Create symlinks in /usr/local/bin if possible (requires sudo)
|
||||
if [ -d "/usr/local/bin" ] && [ -w "/usr/local/bin" ]; then
|
||||
print_color "blue" "Creating symlinks in /usr/local/bin..."
|
||||
# Create heroagent symlink
|
||||
ln -sf "${bin_dir}/heroagent" "/usr/local/bin/heroagent" || true
|
||||
print_color "green" "Created symlink: /usr/local/bin/heroagent"
|
||||
|
||||
# Create symlinks for all binaries
|
||||
find "${bin_dir}" -type f -executable | while read -r binary; do
|
||||
binary_name=$(basename "${binary}")
|
||||
ln -sf "${binary}" "/usr/local/bin/${binary_name}" || true
|
||||
print_color "green" "Created symlink: /usr/local/bin/${binary_name}"
|
||||
done
|
||||
else
|
||||
print_color "yellow" "Note: Could not create symlinks in /usr/local/bin (permission denied)"
|
||||
print_color "yellow" "To create symlinks manually, run:"
|
||||
print_color "yellow" " sudo ln -sf ${bin_dir}/heroagent /usr/local/bin/heroagent"
|
||||
fi
|
||||
|
||||
print_color "green" "HeroLauncher v${version} installed successfully!"
|
||||
print_color "yellow" "IMPORTANT: You need to restart your terminal or source your shell profile to update your PATH."
|
||||
print_color "yellow" "To update your PATH in the current terminal, run one of the following commands:"
|
||||
|
||||
# Determine the user's shell
|
||||
current_shell=$(basename "$SHELL")
|
||||
case "$current_shell" in
|
||||
"bash")
|
||||
print_color "blue" " source ~/.bashrc"
|
||||
;;
|
||||
"zsh")
|
||||
print_color "blue" " source ~/.zshrc"
|
||||
;;
|
||||
*)
|
||||
print_color "blue" " source ~/.bashrc # or the appropriate profile file for your shell"
|
||||
;;
|
||||
esac
|
||||
|
||||
print_color "blue" "To verify installation, run: heroagent -version"
|
||||
print_color "blue" "Or directly from the installation directory: ${bin_dir}/heroagent -version"
|
||||
|
||||
# Check if heroagent is in the PATH
|
||||
if command -v heroagent >/dev/null 2>&1; then
|
||||
print_color "green" "heroagent command is available in your PATH."
|
||||
else
|
||||
print_color "yellow" "heroagent command is not yet available in your PATH."
|
||||
print_color "yellow" "You can run it directly using: ${bin_dir}/heroagent"
|
||||
print_color "yellow" "Or create a symlink manually: sudo ln -sf ${bin_dir}/heroagent /usr/local/bin/heroagent"
|
||||
fi
|
91
scripts/open_webdav_osx.sh
Executable file
91
scripts/open_webdav_osx.sh
Executable file
@@ -0,0 +1,91 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Default values
|
||||
HOST="localhost"
|
||||
PORT="9999"
|
||||
PATH_PREFIX=""
|
||||
USE_HTTPS=false
|
||||
USERNAME=""
|
||||
PASSWORD=""
|
||||
|
||||
# Parse command line arguments
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
-h|--host)
|
||||
HOST="$2"
|
||||
shift 2
|
||||
;;
|
||||
-p|--port)
|
||||
PORT="$2"
|
||||
shift 2
|
||||
;;
|
||||
-path|--path-prefix)
|
||||
PATH_PREFIX="$2"
|
||||
shift 2
|
||||
;;
|
||||
-s|--https)
|
||||
USE_HTTPS=true
|
||||
shift
|
||||
;;
|
||||
-u|--username)
|
||||
USERNAME="$2"
|
||||
shift 2
|
||||
;;
|
||||
-pw|--password)
|
||||
PASSWORD="$2"
|
||||
shift 2
|
||||
;;
|
||||
-h|--help)
|
||||
echo "Usage: $0 [options]"
|
||||
echo "Options:"
|
||||
echo " -h, --host HOSTNAME WebDAV server hostname (default: localhost)"
|
||||
echo " -p, --port PORT WebDAV server port (default: 9999)"
|
||||
echo " -path, --path-prefix PATH WebDAV path prefix (default: none)"
|
||||
echo " -s, --https Use HTTPS instead of HTTP"
|
||||
echo " -u, --username USERNAME Username for authentication"
|
||||
echo " -pw, --password PASSWORD Password for authentication"
|
||||
echo " --help Show this help message"
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Unknown option: $1"
|
||||
echo "Use --help for usage information"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Construct the WebDAV URL
|
||||
PROTOCOL="http"
|
||||
if [ "$USE_HTTPS" = true ]; then
|
||||
PROTOCOL="https"
|
||||
fi
|
||||
|
||||
# Build the URL with authentication if provided
|
||||
if [ -n "$USERNAME" ] && [ -n "$PASSWORD" ]; then
|
||||
# URL encode the username and password
|
||||
USERNAME_ENCODED=$(echo -n "$USERNAME" | xxd -plain | tr -d '\n' | sed 's/\(.\{2\}\)/%\1/g')
|
||||
PASSWORD_ENCODED=$(echo -n "$PASSWORD" | xxd -plain | tr -d '\n' | sed 's/\(.\{2\}\)/%\1/g')
|
||||
|
||||
WEBDAV_URL="${PROTOCOL}://${USERNAME_ENCODED}:${PASSWORD_ENCODED}@${HOST}:${PORT}${PATH_PREFIX}"
|
||||
echo "Opening WebDAV connection to ${PROTOCOL}://${USERNAME}:****@${HOST}:${PORT}${PATH_PREFIX} in Finder..."
|
||||
else
|
||||
WEBDAV_URL="${PROTOCOL}://${HOST}:${PORT}${PATH_PREFIX}"
|
||||
echo "Opening WebDAV connection to $WEBDAV_URL in Finder..."
|
||||
fi
|
||||
|
||||
# Open the WebDAV URL in Finder
|
||||
open "$WEBDAV_URL"
|
||||
|
||||
echo "WebDAV connection opened in Finder."
|
||||
|
||||
if [ -z "$USERNAME" ] || [ -z "$PASSWORD" ]; then
|
||||
echo "If prompted, enter your credentials to connect."
|
||||
fi
|
||||
|
||||
echo "Note: macOS may require you to reconnect after system restarts."
|
||||
echo "Debug tip: If connection fails, try the following:"
|
||||
echo " 1. Check that the WebDAV server is running"
|
||||
echo " 2. Verify the hostname and port are correct"
|
||||
echo " 3. If using HTTPS, ensure the certificate is trusted"
|
||||
echo " 4. Try connecting manually in Finder with Go > Connect to Server"
|
BIN
scripts/redis_mail_feeder
Executable file
BIN
scripts/redis_mail_feeder
Executable file
Binary file not shown.
120
scripts/redis_populate.sh
Executable file
120
scripts/redis_populate.sh
Executable file
@@ -0,0 +1,120 @@
|
||||
#!/bin/bash
|
||||
# Script to populate Redis with test data
|
||||
|
||||
# Set Redis port
|
||||
REDIS_PORT=6378
|
||||
|
||||
# Function to check if Redis is running
|
||||
check_redis() {
|
||||
if ! redis-cli -p $REDIS_PORT PING &>/dev/null; then
|
||||
echo "Error: Redis server is not running on port $REDIS_PORT"
|
||||
echo "Please start the Redis server first"
|
||||
exit 1
|
||||
fi
|
||||
echo "Redis server is running on port $REDIS_PORT"
|
||||
}
|
||||
|
||||
# Function to populate string data
|
||||
populate_strings() {
|
||||
echo "Populating string data..."
|
||||
|
||||
# User data
|
||||
redis-cli -p $REDIS_PORT SET user:1:name "John Doe"
|
||||
redis-cli -p $REDIS_PORT SET user:1:email "john@example.com"
|
||||
redis-cli -p $REDIS_PORT SET user:1:age "30"
|
||||
|
||||
# Set with expiration
|
||||
redis-cli -p $REDIS_PORT SET user:1:session "abc123" EX 60
|
||||
|
||||
redis-cli -p $REDIS_PORT SET user:2:name "Jane Smith"
|
||||
redis-cli -p $REDIS_PORT SET user:2:email "jane@example.com"
|
||||
redis-cli -p $REDIS_PORT SET user:2:age "28"
|
||||
|
||||
# Product data
|
||||
redis-cli -p $REDIS_PORT SET product:1:name "Laptop"
|
||||
redis-cli -p $REDIS_PORT SET product:1:price "999.99"
|
||||
redis-cli -p $REDIS_PORT SET product:1:stock "50"
|
||||
|
||||
redis-cli -p $REDIS_PORT SET product:2:name "Smartphone"
|
||||
redis-cli -p $REDIS_PORT SET product:2:price "499.99"
|
||||
redis-cli -p $REDIS_PORT SET product:2:stock "100"
|
||||
|
||||
# Configuration data
|
||||
redis-cli -p $REDIS_PORT SET config:app:name "HeroLauncher"
|
||||
redis-cli -p $REDIS_PORT SET config:app:version "1.0.0"
|
||||
redis-cli -p $REDIS_PORT SET config:app:environment "development"
|
||||
|
||||
echo "String data population complete"
|
||||
}
|
||||
|
||||
# Function to populate hash data
|
||||
populate_hashes() {
|
||||
echo "Populating hash data..."
|
||||
|
||||
# User profiles as hashes
|
||||
redis-cli -p $REDIS_PORT HSET user:1 name "John Doe" email "john@example.com" age 30 role "admin" active "true"
|
||||
redis-cli -p $REDIS_PORT HSET user:2 name "Jane Smith" email "jane@example.com" age 28 role "developer" active "true"
|
||||
redis-cli -p $REDIS_PORT HSET user:3 name "Bob Johnson" email "bob@example.com" age 35 role "manager" active "false"
|
||||
|
||||
# Product details as hashes
|
||||
redis-cli -p $REDIS_PORT HSET product:1 name "Laptop" price 999.99 stock 50 category "electronics" brand "TechBrand"
|
||||
redis-cli -p $REDIS_PORT HSET product:2 name "Smartphone" price 499.99 stock 100 category "electronics" brand "PhoneCo"
|
||||
redis-cli -p $REDIS_PORT HSET product:3 name "Headphones" price 149.99 stock 200 category "accessories" brand "AudioTech"
|
||||
|
||||
# Configuration settings as hashes
|
||||
redis-cli -p $REDIS_PORT HSET config:app name "HeroLauncher" version "1.0.0" environment "development" debug "true"
|
||||
redis-cli -p $REDIS_PORT HSET config:server host "localhost" port 9001 maxConnections 100 timeout 30
|
||||
|
||||
echo "Hash data population complete"
|
||||
}
|
||||
|
||||
# Function to test Redis commands
|
||||
test_commands() {
|
||||
echo "Testing Redis commands..."
|
||||
|
||||
echo -e "\nTesting PING:"
|
||||
redis-cli -p $REDIS_PORT PING
|
||||
|
||||
echo -e "\nTesting GET:"
|
||||
redis-cli -p $REDIS_PORT GET user:1:name
|
||||
|
||||
echo -e "\nTesting HGET:"
|
||||
redis-cli -p $REDIS_PORT HGET user:1 email
|
||||
|
||||
echo -e "\nTesting TYPE command:"
|
||||
redis-cli -p $REDIS_PORT TYPE user:1:name
|
||||
redis-cli -p $REDIS_PORT TYPE user:1
|
||||
|
||||
echo -e "\nTesting SCAN command:"
|
||||
redis-cli -p $REDIS_PORT SCAN 0 MATCH user:* COUNT 5
|
||||
|
||||
echo -e "\nTesting TTL command:"
|
||||
redis-cli -p $REDIS_PORT TTL user:1:name
|
||||
redis-cli -p $REDIS_PORT TTL user:1:session
|
||||
redis-cli -p $REDIS_PORT TTL nonexistent:key
|
||||
|
||||
echo -e "\nTesting EXPIRE command:"
|
||||
redis-cli -p $REDIS_PORT EXPIRE user:1:name 120
|
||||
redis-cli -p $REDIS_PORT TTL user:1:name
|
||||
redis-cli -p $REDIS_PORT EXPIRE nonexistent:key 60
|
||||
|
||||
echo -e "\nTesting INFO command:"
|
||||
redis-cli -p $REDIS_PORT INFO | head -n 20
|
||||
|
||||
echo -e "\nTesting KEYS command:"
|
||||
redis-cli -p $REDIS_PORT KEYS user:*
|
||||
|
||||
echo "Command testing complete"
|
||||
}
|
||||
|
||||
# Main execution
|
||||
echo "Redis Data Population Script"
|
||||
echo "==========================="
|
||||
|
||||
check_redis
|
||||
populate_strings
|
||||
populate_hashes
|
||||
test_commands
|
||||
|
||||
echo "==========================="
|
||||
echo "Redis population completed successfully!"
|
103
scripts/redis_queue_test.sh
Executable file
103
scripts/redis_queue_test.sh
Executable file
@@ -0,0 +1,103 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Redis Queue Test Script
|
||||
# This script tests the Redis queue commands (LPUSH, RPUSH, LPOP, RPOP, LLEN, LRANGE)
|
||||
|
||||
echo "Redis Queue Test Script"
|
||||
echo "======================="
|
||||
|
||||
# Check if Redis server is running
|
||||
redis-cli -p 6378 PING > /dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: Redis server is not running on port 6378"
|
||||
echo "Please start the server before running this script"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Redis server is running on port 6378"
|
||||
|
||||
# Clear any existing test keys
|
||||
redis-cli -p 6378 DEL test:queue > /dev/null
|
||||
redis-cli -p 6378 DEL test:queue2 > /dev/null
|
||||
|
||||
# Test LPUSH and LLEN
|
||||
echo -e "\nTesting LPUSH and LLEN:"
|
||||
echo "Adding items to the queue from the left side..."
|
||||
redis-cli -p 6378 LPUSH test:queue "item1"
|
||||
redis-cli -p 6378 LPUSH test:queue "item2"
|
||||
redis-cli -p 6378 LPUSH test:queue "item3"
|
||||
|
||||
echo "Queue length:"
|
||||
redis-cli -p 6378 LLEN test:queue
|
||||
|
||||
# Test LRANGE
|
||||
echo -e "\nTesting LRANGE:"
|
||||
echo "Queue contents (all items):"
|
||||
redis-cli -p 6378 LRANGE test:queue 0 -1
|
||||
|
||||
# Test RPUSH
|
||||
echo -e "\nTesting RPUSH:"
|
||||
echo "Adding items to the queue from the right side..."
|
||||
redis-cli -p 6378 RPUSH test:queue "item4"
|
||||
redis-cli -p 6378 RPUSH test:queue "item5"
|
||||
|
||||
echo "Queue length after RPUSH:"
|
||||
redis-cli -p 6378 LLEN test:queue
|
||||
|
||||
echo "Queue contents after RPUSH:"
|
||||
redis-cli -p 6378 LRANGE test:queue 0 -1
|
||||
|
||||
# Test LPOP
|
||||
echo -e "\nTesting LPOP:"
|
||||
echo "Removing item from the left side of the queue..."
|
||||
echo "Popped item: $(redis-cli -p 6378 LPOP test:queue)"
|
||||
|
||||
echo "Queue length after LPOP:"
|
||||
redis-cli -p 6378 LLEN test:queue
|
||||
|
||||
echo "Queue contents after LPOP:"
|
||||
redis-cli -p 6378 LRANGE test:queue 0 -1
|
||||
|
||||
# Test RPOP
|
||||
echo -e "\nTesting RPOP:"
|
||||
echo "Removing item from the right side of the queue..."
|
||||
echo "Popped item: $(redis-cli -p 6378 RPOP test:queue)"
|
||||
|
||||
echo "Queue length after RPOP:"
|
||||
redis-cli -p 6378 LLEN test:queue
|
||||
|
||||
echo "Queue contents after RPOP:"
|
||||
redis-cli -p 6378 LRANGE test:queue 0 -1
|
||||
|
||||
# Test queue as a FIFO (First In, First Out)
|
||||
echo -e "\nTesting queue as FIFO (using RPUSH and LPOP):"
|
||||
echo "Creating a new queue..."
|
||||
redis-cli -p 6378 RPUSH test:queue2 "first"
|
||||
redis-cli -p 6378 RPUSH test:queue2 "second"
|
||||
redis-cli -p 6378 RPUSH test:queue2 "third"
|
||||
|
||||
echo "Queue contents:"
|
||||
redis-cli -p 6378 LRANGE test:queue2 0 -1
|
||||
|
||||
echo "Dequeuing items in FIFO order:"
|
||||
echo "First out: $(redis-cli -p 6378 LPOP test:queue2)"
|
||||
echo "Second out: $(redis-cli -p 6378 LPOP test:queue2)"
|
||||
echo "Third out: $(redis-cli -p 6378 LPOP test:queue2)"
|
||||
|
||||
# Test queue as a LIFO (Last In, First Out) / Stack
|
||||
echo -e "\nTesting queue as LIFO/Stack (using LPUSH and LPOP):"
|
||||
echo "Creating a new stack..."
|
||||
redis-cli -p 6378 LPUSH test:queue2 "bottom"
|
||||
redis-cli -p 6378 LPUSH test:queue2 "middle"
|
||||
redis-cli -p 6378 LPUSH test:queue2 "top"
|
||||
|
||||
echo "Stack contents:"
|
||||
redis-cli -p 6378 LRANGE test:queue2 0 -1
|
||||
|
||||
echo "Popping items from stack:"
|
||||
echo "First out (top): $(redis-cli -p 6378 LPOP test:queue2)"
|
||||
echo "Second out (middle): $(redis-cli -p 6378 LPOP test:queue2)"
|
||||
echo "Third out (bottom): $(redis-cli -p 6378 LPOP test:queue2)"
|
||||
|
||||
echo -e "\nQueue tests completed successfully!"
|
||||
echo "======================="
|
146
scripts/release.sh
Executable file
146
scripts/release.sh
Executable file
@@ -0,0 +1,146 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Exit on error
|
||||
set -e
|
||||
|
||||
# Function to get the latest release from GitHub
|
||||
get_latest_release() {
|
||||
# Use a simpler approach with curl and grep
|
||||
local version
|
||||
version=$(curl -s "https://api.github.com/repos/freeflowuniverse/heroagent/releases/latest" |
|
||||
grep -o '"tag_name": *"[^"]*"' |
|
||||
sed 's/.*"v\?\([^"]*\)".*/\1/')
|
||||
|
||||
# If version is empty, check for error message
|
||||
if [ -z "$version" ]; then
|
||||
local error_message
|
||||
error_message=$(curl -s "https://api.github.com/repos/freeflowuniverse/heroagent/releases/latest" |
|
||||
grep -o '"message": *"[^"]*"' |
|
||||
sed 's/.*"\([^"]*\)".*/\1/')
|
||||
|
||||
if [[ "$error_message" == "Not Found" ]]; then
|
||||
echo "No releases found. You will create the first release." >&2
|
||||
return 0
|
||||
else
|
||||
echo "GitHub API Error: $error_message" >&2
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "$version"
|
||||
}
|
||||
|
||||
# Get repository root directory
|
||||
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
repo_root="$(cd "$script_dir/.." && pwd)"
|
||||
|
||||
# Change to repository root
|
||||
cd "$repo_root" || { echo "Error: Could not change to repository root directory" >&2; exit 1; }
|
||||
|
||||
# Show current version information
|
||||
echo "Current project information:"
|
||||
echo "----------------------------"
|
||||
|
||||
# Show Go version from go.mod
|
||||
if [ -f "go.mod" ]; then
|
||||
go_version=$(grep "^go " go.mod | awk '{print $2}')
|
||||
echo "Go version in go.mod: $go_version"
|
||||
fi
|
||||
|
||||
# Show current version from local git tags
|
||||
echo "Fetching latest tag from local git repository..."
|
||||
if git tag -l | grep -q "^v"; then
|
||||
latest_local_tag=$(git tag -l "v*" --sort=-v:refname | head -n 1)
|
||||
echo "Latest local git tag: $latest_local_tag"
|
||||
else
|
||||
echo "No version tags found in local git repository."
|
||||
fi
|
||||
|
||||
# Show current version from GitHub releases
|
||||
echo "Fetching latest release information from GitHub..."
|
||||
latest_release=$(get_latest_release 2>/dev/null)
|
||||
if [ -z "$latest_release" ]; then
|
||||
echo "No previous GitHub releases found. This will be the first release."
|
||||
else
|
||||
# Clean the version string
|
||||
latest_release=$(echo "$latest_release" | tr -d '\n\r')
|
||||
echo "Current latest GitHub release: $latest_release"
|
||||
fi
|
||||
|
||||
# Show current git branch
|
||||
current_branch=$(git rev-parse --abbrev-ref HEAD)
|
||||
echo "Current git branch: $current_branch"
|
||||
|
||||
echo "----------------------------"
|
||||
|
||||
# Determine current version to suggest as default
|
||||
current_version=""
|
||||
if [ -n "$latest_local_tag" ]; then
|
||||
# Remove 'v' prefix if present
|
||||
current_version=${latest_local_tag#v}
|
||||
elif [ -n "$latest_release" ]; then
|
||||
# Remove 'v' prefix if present
|
||||
current_version=${latest_release#v}
|
||||
else
|
||||
current_version="0.1.0" # Default if no version found
|
||||
fi
|
||||
|
||||
# Suggest an incremented patch version
|
||||
IFS='.' read -r major minor patch <<< "$current_version"
|
||||
suggested_version="$major.$minor.$((patch + 1))"
|
||||
|
||||
# Ask for new version with the suggested version as default
|
||||
read -p "Enter new version (current: $current_version, suggested: $suggested_version, press Enter to use suggested): " new_version
|
||||
|
||||
# Use suggested version if input is empty
|
||||
if [ -z "$new_version" ]; then
|
||||
new_version="$suggested_version"
|
||||
echo "Using suggested version: $new_version"
|
||||
fi
|
||||
|
||||
# Validate version format
|
||||
if ! [[ $new_version =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||
echo "Error: Version must be in format X.Y.Z (e.g., 1.0.4)" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Creating release v$new_version..."
|
||||
echo "This will trigger the GitHub Actions release workflow which will:"
|
||||
echo "- Build binaries for all platforms (Linux, macOS, Windows)"
|
||||
echo "- Create a GitHub release with the tag name"
|
||||
echo "- Upload the binaries as assets to the release"
|
||||
echo "- Generate release notes based on the commits since the last release"
|
||||
|
||||
# Confirm with user
|
||||
read -p "Do you want to continue? (y/n): " confirm
|
||||
if [[ "$confirm" != "y" && "$confirm" != "Y" ]]; then
|
||||
echo "Release cancelled."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Prepare git commands
|
||||
echo "Preparing git commands..."
|
||||
cmd="
|
||||
git remote set-url origin git@github.com:freeflowuniverse/heroagent.git
|
||||
git pull origin main
|
||||
git tag -a \"v$new_version\" -m \"Release version $new_version\"
|
||||
git push origin \"v$new_version\"
|
||||
"
|
||||
|
||||
echo "Will execute:"
|
||||
echo "$cmd"
|
||||
|
||||
# Confirm with user again
|
||||
read -p "Execute these commands? (y/n): " confirm
|
||||
if [[ "$confirm" != "y" && "$confirm" != "Y" ]]; then
|
||||
echo "Release cancelled."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Execute git commands
|
||||
eval "$cmd"
|
||||
|
||||
echo "Release v$new_version created and pushed!"
|
||||
echo "The GitHub Actions release workflow has been triggered."
|
||||
echo "You can check the progress at: https://github.com/freeflowuniverse/heroagent/actions/workflows/release.yml"
|
||||
echo "Once completed, the release will be available at: https://github.com/freeflowuniverse/heroagent/releases/tag/v$new_version"
|
147
scripts/test.sh
Executable file
147
scripts/test.sh
Executable file
@@ -0,0 +1,147 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Set architecture to 64-bit to avoid 32-bit compilation issues
|
||||
export GOARCH=amd64
|
||||
|
||||
# Initialize debug flag to false
|
||||
DEBUG=false
|
||||
|
||||
# Check for --debug flag
|
||||
for arg in "$@"; do
|
||||
if [ "$arg" = "--debug" ]; then
|
||||
DEBUG=true
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# Function to print debug messages
|
||||
debug_echo() {
|
||||
if [ "$DEBUG" = true ]; then
|
||||
echo "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
# Array of module paths to exclude from running tests
|
||||
# Paths are relative to the root of the repo
|
||||
EXCLUDED_MODULES=(
|
||||
# Uncomment modules you want to exclude
|
||||
# "pkg/doctree"
|
||||
# "pkg/sal/executor"
|
||||
# "pkg/handlerfactory"
|
||||
# "pkg/heroagent"
|
||||
# "pkg/heroscript"
|
||||
# "pkg/imapserver"
|
||||
# "pkg/mcp"
|
||||
# "pkg/openapi"
|
||||
# "pkg/ourdb"
|
||||
# "pkg/packagemanager"
|
||||
# "pkg/processmanager"
|
||||
# "pkg/radixtree"
|
||||
# "pkg/redisserver"
|
||||
# "pkg/smtpserver"
|
||||
# "pkg/system"
|
||||
# "pkg/telnetserver"
|
||||
# "pkg/tools"
|
||||
# "pkg/ui"
|
||||
# "pkg/vfs"
|
||||
# "pkg/lang"
|
||||
# "pkg/vm"
|
||||
# "pkg/webdavserver"
|
||||
# "pkg/wire"
|
||||
)
|
||||
|
||||
# Function to join array elements with a delimiter
|
||||
join_array() {
|
||||
local IFS="$1"
|
||||
shift
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
# Debug: Print the excluded modules
|
||||
debug_echo "Excluded modules:"
|
||||
debug_echo "Array size: ${#EXCLUDED_MODULES[@]}"
|
||||
if [ "$DEBUG" = true ]; then
|
||||
for module in "${EXCLUDED_MODULES[@]}"; do
|
||||
echo " $module"
|
||||
done
|
||||
fi
|
||||
|
||||
# Convert excluded modules into a grep -v pattern (e.g., "pkg/doctree\|pkg/sal/executor")
|
||||
EXCLUDE_PATTERN=$(join_array "|" "${EXCLUDED_MODULES[@]}")
|
||||
debug_echo "Exclude pattern: $EXCLUDE_PATTERN"
|
||||
|
||||
# Find all Go test files (*.go files containing "Test" in their name or content)
|
||||
ALL_TEST_FILES=$(find . -type f -name "*_test.go")
|
||||
debug_echo "All test files found:"
|
||||
if [ "$DEBUG" = true ]; then
|
||||
echo "$ALL_TEST_FILES"
|
||||
fi
|
||||
|
||||
# Exclude the modules specified in EXCLUDED_MODULES
|
||||
# Add word boundaries to ensure exact directory matching
|
||||
if [ ${#EXCLUDED_MODULES[@]} -eq 0 ]; then
|
||||
# If no modules are excluded, use all test files
|
||||
TEST_FILES="$ALL_TEST_FILES"
|
||||
debug_echo "No modules excluded, using all test files"
|
||||
else
|
||||
# Otherwise, exclude the specified modules
|
||||
TEST_FILES=$(echo "$ALL_TEST_FILES" | grep -v -E "($(join_array "|" "${EXCLUDED_MODULES[@]}"))(/|$)")
|
||||
debug_echo "Excluding specified modules"
|
||||
fi
|
||||
|
||||
# Check if there are any test files to run
|
||||
if [ -z "$TEST_FILES" ]; then
|
||||
echo "No test files found after excluding specified modules."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Initialize counters for test results
|
||||
TOTAL_TESTS=0
|
||||
PASSED_TESTS=0
|
||||
FAILED_TESTS=0
|
||||
|
||||
# Run go test on the remaining modules
|
||||
debug_echo "Running tests for the following files:"
|
||||
if [ "$DEBUG" = true ]; then
|
||||
echo "$TEST_FILES"
|
||||
fi
|
||||
echo "---------------------------------------"
|
||||
|
||||
# Convert test files to package paths and run go test
|
||||
for file in $TEST_FILES; do
|
||||
# Get the directory of the test file (package path)
|
||||
pkg=$(dirname "$file")
|
||||
if [ "$DEBUG" = true ]; then
|
||||
echo "Testing package: $pkg"
|
||||
fi
|
||||
|
||||
# Run the test and capture the output
|
||||
TEST_OUTPUT=$(go test -v "$pkg")
|
||||
TEST_RESULT=$?
|
||||
|
||||
# Display the test output
|
||||
echo "$TEST_OUTPUT"
|
||||
|
||||
# Count the number of tests run, passed, and failed
|
||||
TESTS_RUN=$(echo "$TEST_OUTPUT" | grep -c "=== RUN")
|
||||
TOTAL_TESTS=$((TOTAL_TESTS + TESTS_RUN))
|
||||
|
||||
if [ $TEST_RESULT -eq 0 ]; then
|
||||
# All tests passed
|
||||
PASSED_TESTS=$((PASSED_TESTS + TESTS_RUN))
|
||||
else
|
||||
# Count failed tests - use grep with a pattern that escapes the hyphens
|
||||
TESTS_FAILED=$(echo "$TEST_OUTPUT" | grep -c "\-\-\- FAIL")
|
||||
FAILED_TESTS=$((FAILED_TESTS + TESTS_FAILED))
|
||||
PASSED_TESTS=$((PASSED_TESTS + TESTS_RUN - TESTS_FAILED))
|
||||
fi
|
||||
done
|
||||
|
||||
echo "---------------------------------------"
|
||||
echo "TEST SUMMARY"
|
||||
echo "---------------------------------------"
|
||||
echo "Total Tests: $TOTAL_TESTS"
|
||||
echo "Passed Tests: $PASSED_TESTS"
|
||||
echo "Failed Tests: $FAILED_TESTS"
|
||||
echo "---------------------------------------"
|
||||
echo "All applicable tests completed."
|
108
scripts/test_auto_cert_webdav.sh
Executable file
108
scripts/test_auto_cert_webdav.sh
Executable file
@@ -0,0 +1,108 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Test script for WebDAV server with auto-certificate generation
|
||||
# This script demonstrates how the WebDAV server automatically generates certificates when needed
|
||||
|
||||
# Create test directory for WebDAV files
|
||||
TEST_DIR="/tmp/heroagent_test"
|
||||
CERT_DIR="/tmp/certificates"
|
||||
|
||||
# Clean up any existing test directories
|
||||
if [ -d "$TEST_DIR" ]; then
|
||||
echo "Removing existing test directory to start fresh..."
|
||||
rm -rf "$TEST_DIR"
|
||||
fi
|
||||
|
||||
# Clean up any existing certificates
|
||||
if [ -d "$CERT_DIR" ]; then
|
||||
echo "Removing existing certificates to test auto-generation..."
|
||||
rm -rf "$CERT_DIR"
|
||||
fi
|
||||
|
||||
# Create test directory and add a test file
|
||||
mkdir -p "$TEST_DIR"
|
||||
echo "Test content" > "$TEST_DIR/test.txt"
|
||||
|
||||
# Function to display section headers
|
||||
section() {
|
||||
echo ""
|
||||
echo "====================================="
|
||||
echo " $1"
|
||||
echo "====================================="
|
||||
}
|
||||
|
||||
# Function to run a test case
|
||||
run_test() {
|
||||
local name="$1"
|
||||
local cmd="$2"
|
||||
local connect_cmd="$3"
|
||||
|
||||
section "TEST: $name"
|
||||
echo "Running command: $cmd"
|
||||
|
||||
# Run the WebDAV server in the background
|
||||
eval "$cmd" &
|
||||
SERVER_PID=$!
|
||||
|
||||
# Wait for server to start
|
||||
sleep 2
|
||||
|
||||
# Display connection command
|
||||
if [ -n "$connect_cmd" ]; then
|
||||
echo ""
|
||||
echo "To connect to this server, run:"
|
||||
echo "$connect_cmd"
|
||||
echo ""
|
||||
echo "Press Enter to continue to the next test..."
|
||||
read
|
||||
else
|
||||
echo "Server is running. Press Enter to continue to the next test..."
|
||||
read
|
||||
fi
|
||||
|
||||
# Kill the server
|
||||
kill $SERVER_PID
|
||||
wait $SERVER_PID 2>/dev/null
|
||||
echo "Server stopped."
|
||||
}
|
||||
|
||||
# Test 1: WebDAV with HTTPS and auto-generated certificates
|
||||
run_test "WebDAV Server with Auto-Generated Certificates" \
|
||||
"./bin/webdavserver -fs $TEST_DIR -debug -https" \
|
||||
"./scripts/open_webdav_osx.sh -s"
|
||||
|
||||
# Test 2: Check if certificates were generated
|
||||
section "Checking Generated Certificates"
|
||||
if [ -f "$CERT_DIR/webdav.crt" ] && [ -f "$CERT_DIR/webdav.key" ]; then
|
||||
echo "✅ Certificates were successfully auto-generated:"
|
||||
echo " - $CERT_DIR/webdav.crt"
|
||||
echo " - $CERT_DIR/webdav.key"
|
||||
|
||||
# Display certificate information
|
||||
echo ""
|
||||
echo "Certificate information:"
|
||||
openssl x509 -in "$CERT_DIR/webdav.crt" -text -noout | grep -E "Subject:|Issuer:|Not Before:|Not After :|DNS:"
|
||||
else
|
||||
echo "❌ Certificates were not generated properly"
|
||||
fi
|
||||
|
||||
# Test 3: WebDAV with HTTPS using the generated certificates
|
||||
run_test "WebDAV Server with Previously Generated Certificates" \
|
||||
"./bin/webdavserver -fs $TEST_DIR -debug -https -cert $CERT_DIR/webdav.crt -key $CERT_DIR/webdav.key" \
|
||||
"./scripts/open_webdav_osx.sh -s"
|
||||
|
||||
# Test 4: WebDAV with HTTPS, authentication and custom certificate settings
|
||||
run_test "WebDAV Server with Custom Certificate Settings" \
|
||||
"./bin/webdavserver -fs $TEST_DIR -debug -https -auth -username testuser -password testpass -cert-validity 30 -cert-org \"Test Organization\"" \
|
||||
"./scripts/open_webdav_osx.sh -s -u testuser -pw testpass"
|
||||
|
||||
section "All tests completed"
|
||||
echo "The WebDAV server has been tested with auto-certificate generation:"
|
||||
echo "- Basic auto-generation"
|
||||
echo "- Reusing generated certificates"
|
||||
echo "- Custom certificate settings"
|
||||
echo ""
|
||||
echo "For production use, consider:"
|
||||
echo "1. Using properly signed certificates instead of self-signed ones"
|
||||
echo "2. Setting a longer validity period (default is 365 days)"
|
||||
echo "3. Always enabling authentication with strong credentials"
|
94
scripts/test_webdav.sh
Executable file
94
scripts/test_webdav.sh
Executable file
@@ -0,0 +1,94 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Test script for WebDAV server with all features
|
||||
# This script demonstrates how to use the WebDAV server with debug mode, authentication, and HTTPS
|
||||
|
||||
# Create test directory for WebDAV files
|
||||
TEST_DIR="/tmp/webdav_test"
|
||||
mkdir -p "$TEST_DIR"
|
||||
echo "Test content" > "$TEST_DIR/test.txt"
|
||||
|
||||
# Generate self-signed certificate for HTTPS testing if it doesn't exist
|
||||
CERT_DIR="./certs"
|
||||
if [ ! -f "$CERT_DIR/webdav.crt" ] || [ ! -f "$CERT_DIR/webdav.key" ]; then
|
||||
echo "Generating self-signed certificate for HTTPS testing..."
|
||||
./scripts/generate_cert.sh
|
||||
fi
|
||||
|
||||
# Function to display section headers
|
||||
section() {
|
||||
echo ""
|
||||
echo "====================================="
|
||||
echo " $1"
|
||||
echo "====================================="
|
||||
}
|
||||
|
||||
# Function to run a test case
|
||||
run_test() {
|
||||
local name="$1"
|
||||
local cmd="$2"
|
||||
local connect_cmd="$3"
|
||||
|
||||
section "TEST: $name"
|
||||
echo "Running command: $cmd"
|
||||
|
||||
# Run the WebDAV server in the background
|
||||
eval "$cmd" &
|
||||
SERVER_PID=$!
|
||||
|
||||
# Wait for server to start
|
||||
sleep 2
|
||||
|
||||
# Display connection command
|
||||
if [ -n "$connect_cmd" ]; then
|
||||
echo ""
|
||||
echo "To connect to this server, run:"
|
||||
echo "$connect_cmd"
|
||||
echo ""
|
||||
echo "Press Enter to continue to the next test..."
|
||||
read
|
||||
else
|
||||
echo "Server is running. Press Enter to continue to the next test..."
|
||||
read
|
||||
fi
|
||||
|
||||
# Kill the server
|
||||
kill $SERVER_PID
|
||||
wait $SERVER_PID 2>/dev/null
|
||||
echo "Server stopped."
|
||||
}
|
||||
|
||||
# Test 1: Basic WebDAV server
|
||||
run_test "Basic WebDAV Server" \
|
||||
"./bin/webdavserver -fs $TEST_DIR" \
|
||||
"./scripts/open_webdav_osx.sh"
|
||||
|
||||
# Test 2: WebDAV with debug mode
|
||||
run_test "WebDAV Server with Debug Mode" \
|
||||
"./bin/webdavserver -fs $TEST_DIR -debug" \
|
||||
"./scripts/open_webdav_osx.sh"
|
||||
|
||||
# Test 3: WebDAV with authentication
|
||||
run_test "WebDAV Server with Authentication" \
|
||||
"./bin/webdavserver -fs $TEST_DIR -auth -username testuser -password testpass" \
|
||||
"./scripts/open_webdav_osx.sh -u testuser -pw testpass"
|
||||
|
||||
# Test 4: WebDAV with HTTPS
|
||||
run_test "WebDAV Server with HTTPS" \
|
||||
"./bin/webdavserver -fs $TEST_DIR -https -cert $CERT_DIR/webdav.crt -key $CERT_DIR/webdav.key" \
|
||||
"./scripts/open_webdav_osx.sh -s"
|
||||
|
||||
# Test 5: WebDAV with all features
|
||||
run_test "WebDAV Server with All Features" \
|
||||
"./bin/webdavserver -fs $TEST_DIR -debug -auth -username testuser -password testpass -https -cert $CERT_DIR/webdav.crt -key $CERT_DIR/webdav.key" \
|
||||
"./scripts/open_webdav_osx.sh -s -u testuser -pw testpass"
|
||||
|
||||
section "All tests completed"
|
||||
echo "The WebDAV server has been tested with all features:"
|
||||
echo "- Basic functionality"
|
||||
echo "- Debug mode"
|
||||
echo "- Authentication"
|
||||
echo "- HTTPS support"
|
||||
echo ""
|
||||
echo "To run the WebDAV server in production mode, use:"
|
||||
echo "./bin/webdavserver -fs /path/to/your/files -auth -username your_username -password your_password -https -cert /path/to/cert.pem -key /path/to/key.pem"
|
47
scripts/test_windows_build.sh
Executable file
47
scripts/test_windows_build.sh
Executable file
@@ -0,0 +1,47 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Clean up and create bin directory
|
||||
rm -rf bin
|
||||
mkdir -p bin
|
||||
|
||||
# Create a log file
|
||||
LOG_FILE="windows_build_test.log"
|
||||
echo "Windows build test started at $(date)" > $LOG_FILE
|
||||
|
||||
# Build each component for Windows
|
||||
for dir in cmd/*; do
|
||||
if [ -f "$dir/main.go" ]; then
|
||||
component=$(basename $dir)
|
||||
|
||||
# Skip components with known build issues
|
||||
if [ "$component" == "processmanager" ] || [ "$component" == "vfsdavserver" ]; then
|
||||
echo "Skipping $component due to known build issues..." | tee -a $LOG_FILE
|
||||
continue
|
||||
fi
|
||||
|
||||
echo "Building $component for Windows..." | tee -a $LOG_FILE
|
||||
GOOS=windows GOARCH=amd64 go build -v -o bin/$component-windows-amd64.exe ./$dir 2>&1 | tee -a $LOG_FILE
|
||||
if [ ${PIPESTATUS[0]} -ne 0 ]; then
|
||||
echo "Error building $component for Windows" | tee -a $LOG_FILE
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
echo "All components built successfully for Windows" | tee -a $LOG_FILE
|
||||
ls -la bin/ | tee -a $LOG_FILE
|
||||
|
||||
# Create archive (simulating Windows PowerShell command)
|
||||
echo "Creating archive (simulating Windows PowerShell command)..." | tee -a $LOG_FILE
|
||||
echo "In a real Windows environment, this would be:" | tee -a $LOG_FILE
|
||||
echo "powershell -Command \"Compress-Archive -Path 'bin/*' -DestinationPath 'heroagent-windows-amd64.zip' -Force\"" | tee -a $LOG_FILE
|
||||
|
||||
# Since we're on Linux, use zip instead
|
||||
echo "Using zip on Linux to simulate Windows archive creation..." | tee -a $LOG_FILE
|
||||
zip -r heroagent-windows-amd64.zip bin/ 2>&1 | tee -a $LOG_FILE
|
||||
echo "Archive created successfully" | tee -a $LOG_FILE
|
||||
ls -la heroagent-windows-amd64.zip | tee -a $LOG_FILE
|
||||
|
||||
echo "Windows build test completed at $(date)" | tee -a $LOG_FILE
|
||||
echo "Log file: $LOG_FILE"
|
Reference in New Issue
Block a user