diff --git a/.gitignore b/.gitignore index 56f0b2a..48b5290 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,10 @@ logs/ # OS specific .DS_Store Thumbs.db +notes/ + +# CI/CD sensitive files +kubernetes/gitea-kubeconfig.yaml +kubernetes/kubeconfig-base64.txt +*kubeconfig*.yaml +*kubeconfig*.txt diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 75370a7..0000000 --- a/.travis.yml +++ /dev/null @@ -1,12 +0,0 @@ -language: rust -rust: -- stable -- nightly -- beta -matrix: - allow_failures: - - rust: stable - fast_finish: true -cache: cargo -before_install: -- npm install diff --git a/docker-quickstart.sh b/docker-quickstart.sh deleted file mode 100755 index d45d317..0000000 --- a/docker-quickstart.sh +++ /dev/null @@ -1,393 +0,0 @@ -#!/bin/bash -# Quick Start Script for socktop webterm Docker Deployment -# This script helps you set up and run the containerized application - -set -e - -# Colors for output -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[1;33m' -BLUE='\033[0;34m' -NC='\033[0m' # No Color - -# Function to print colored output -print_info() { - echo -e "${BLUE}ℹ ${NC}$1" -} - -print_success() { - echo -e "${GREEN}✓${NC} $1" -} - -print_warning() { - echo -e "${YELLOW}⚠${NC} $1" -} - -print_error() { - echo -e "${RED}✗${NC} $1" -} - -print_header() { - echo "" - echo -e "${BLUE}╔════════════════════════════════════════════════════════════╗${NC}" - echo -e "${BLUE}║${NC} $1" - echo -e "${BLUE}╚════════════════════════════════════════════════════════════╝${NC}" - echo "" -} - -# Check if Docker is installed -check_docker() { - print_info "Checking Docker installation..." - if ! command -v docker &> /dev/null; then - print_error "Docker is not installed. Please install Docker first." - echo " Visit: https://docs.docker.com/get-docker/" - exit 1 - fi - print_success "Docker is installed: $(docker --version)" - - if ! command -v docker-compose &> /dev/null; then - print_warning "docker-compose not found, checking for docker compose plugin..." - if ! docker compose version &> /dev/null; then - print_error "Docker Compose is not available. Please install Docker Compose." - exit 1 - fi - print_success "Docker Compose plugin is available" - DOCKER_COMPOSE="docker compose" - else - print_success "Docker Compose is installed: $(docker-compose --version)" - DOCKER_COMPOSE="docker-compose" - fi -} - -# Check if configuration files exist -check_config_files() { - print_info "Checking configuration files..." - - local missing_files=() - - # Check for required files - if [ ! -f "files/alacritty.toml" ]; then - missing_files+=("files/alacritty.toml") - fi - - if [ ! -f "files/catppuccin-frappe.toml" ]; then - missing_files+=("files/catppuccin-frappe.toml") - fi - - if [ ! -f "files/profiles.json" ]; then - missing_files+=("files/profiles.json") - fi - - if [ ${#missing_files[@]} -gt 0 ]; then - print_warning "Some configuration files are missing:" - for file in "${missing_files[@]}"; do - echo " - $file" - done - echo "" - read -p "Would you like to create them from examples? (y/n) " -n 1 -r - echo - if [[ $REPLY =~ ^[Yy]$ ]]; then - create_config_from_examples - else - print_error "Cannot continue without configuration files." - exit 1 - fi - else - print_success "All required configuration files found" - fi -} - -# Create config files from examples -create_config_from_examples() { - print_info "Creating configuration files from examples..." - - mkdir -p files - - if [ ! -f "files/alacritty.toml" ] && [ -f "files/alacritty.toml.example" ]; then - cp files/alacritty.toml.example files/alacritty.toml - print_success "Created files/alacritty.toml" - fi - - if [ ! -f "files/catppuccin-frappe.toml" ] && [ -f "files/catppuccin-frappe.toml.example" ]; then - cp files/catppuccin-frappe.toml.example files/catppuccin-frappe.toml - print_success "Created files/catppuccin-frappe.toml" - fi - - if [ ! -f "files/profiles.json" ] && [ -f "files/profiles.json.example" ]; then - cp files/profiles.json.example files/profiles.json - print_success "Created files/profiles.json" - fi - - print_warning "Note: You may need to customize these files for your environment" -} - -# Check SSH keys -check_ssh_keys() { - print_info "Checking SSH keys..." - - local key_files=("rpi-master.pem" "rpi-worker-1.pem" "rpi-worker-2.pem" "rpi-worker-3.pem") - local missing_keys=() - - for key in "${key_files[@]}"; do - if [ ! -f "files/$key" ]; then - missing_keys+=("$key") - else - # Check permissions - if [ "$(stat -c %a "files/$key" 2>/dev/null || stat -f %A "files/$key" 2>/dev/null)" != "600" ]; then - print_warning "Fixing permissions for files/$key" - chmod 600 "files/$key" - fi - fi - done - - if [ ${#missing_keys[@]} -gt 0 ]; then - print_warning "Some SSH key files are missing:" - for key in "${missing_keys[@]}"; do - echo " - files/$key" - done - echo "" - print_info "If you don't have SSH keys yet, the container will still start with local monitoring." - print_info "You can add keys later and restart the container." - else - print_success "All SSH key files found" - fi -} - -# Build the Docker image -build_image() { - print_header "Building Docker Image" - - print_info "This may take several minutes on first build..." - if $DOCKER_COMPOSE build; then - print_success "Docker image built successfully" - else - print_error "Failed to build Docker image" - exit 1 - fi -} - -# Start the container -start_container() { - print_header "Starting Container" - - if $DOCKER_COMPOSE up -d; then - print_success "Container started successfully" - echo "" - print_info "Waiting for services to be ready..." - sleep 5 - - # Check if container is running - if docker ps | grep -q socktop-webterm; then - print_success "Container is running" - else - print_error "Container failed to start. Check logs with:" - echo " $DOCKER_COMPOSE logs" - exit 1 - fi - else - print_error "Failed to start container" - exit 1 - fi -} - -# Show container status -show_status() { - print_header "Container Status" - - # Show running containers - print_info "Running containers:" - docker ps --filter name=socktop-webterm --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}" - - echo "" - - # Show recent logs - print_info "Recent logs (last 20 lines):" - $DOCKER_COMPOSE logs --tail=20 -} - -# Show access information -show_access_info() { - print_header "Access Information" - - echo -e "${GREEN}✓ socktop webterm is ready!${NC}" - echo "" - echo " 🌐 Web Interface: http://localhost:8082" - echo " 📊 Features:" - echo " - Beautiful Catppuccin Frappe theme" - echo " - Transparent terminal window" - echo " - Auto-running socktop -P local" - echo " - GitHub, Crates.io, APT links" - echo "" - echo " 📝 Useful commands:" - echo " View logs: $DOCKER_COMPOSE logs -f" - echo " Stop container: $DOCKER_COMPOSE down" - echo " Restart: $DOCKER_COMPOSE restart" - echo " Shell access: docker exec -it socktop-webterm bash" - echo "" -} - -# Show help menu -show_help() { - echo "socktop webterm Docker Quick Start Script" - echo "" - echo "Usage: $0 [COMMAND]" - echo "" - echo "Commands:" - echo " start - Build and start the container (default)" - echo " stop - Stop the container" - echo " restart - Restart the container" - echo " rebuild - Rebuild the image from scratch" - echo " logs - Show container logs" - echo " shell - Open a shell in the container" - echo " status - Show container status" - echo " clean - Stop and remove container and volumes" - echo " help - Show this help message" - echo "" -} - -# Stop container -stop_container() { - print_header "Stopping Container" - - if $DOCKER_COMPOSE down; then - print_success "Container stopped" - else - print_error "Failed to stop container" - exit 1 - fi -} - -# Restart container -restart_container() { - print_header "Restarting Container" - - if $DOCKER_COMPOSE restart; then - print_success "Container restarted" - else - print_error "Failed to restart container" - exit 1 - fi -} - -# Rebuild image -rebuild_image() { - print_header "Rebuilding Image" - - print_info "Stopping container..." - $DOCKER_COMPOSE down - - print_info "Removing old image..." - docker rmi socktop-webterm:latest 2>/dev/null || true - - print_info "Building new image (no cache)..." - if $DOCKER_COMPOSE build --no-cache; then - print_success "Image rebuilt successfully" - - read -p "Start the container now? (y/n) " -n 1 -r - echo - if [[ $REPLY =~ ^[Yy]$ ]]; then - start_container - show_access_info - fi - else - print_error "Failed to rebuild image" - exit 1 - fi -} - -# Show logs -show_logs() { - print_header "Container Logs" - - print_info "Showing logs (Ctrl+C to exit)..." - $DOCKER_COMPOSE logs -f -} - -# Open shell -open_shell() { - print_header "Container Shell" - - print_info "Opening bash shell in container..." - docker exec -it socktop-webterm bash -} - -# Clean everything -clean_all() { - print_header "Cleaning Up" - - print_warning "This will remove the container and all volumes!" - read -p "Are you sure? (y/n) " -n 1 -r - echo - - if [[ $REPLY =~ ^[Yy]$ ]]; then - print_info "Stopping and removing container..." - $DOCKER_COMPOSE down -v - - print_info "Removing image..." - docker rmi socktop-webterm:latest 2>/dev/null || true - - print_success "Cleanup complete" - else - print_info "Cleanup cancelled" - fi -} - -# Main function -main() { - # Parse command - COMMAND=${1:-start} - - case $COMMAND in - start) - print_header "socktop webterm - Quick Start" - check_docker - check_config_files - check_ssh_keys - build_image - start_container - show_status - show_access_info - ;; - stop) - check_docker - stop_container - ;; - restart) - check_docker - restart_container - ;; - rebuild) - check_docker - rebuild_image - ;; - logs) - check_docker - show_logs - ;; - shell) - check_docker - open_shell - ;; - status) - check_docker - show_status - ;; - clean) - check_docker - clean_all - ;; - help|--help|-h) - show_help - ;; - *) - print_error "Unknown command: $COMMAND" - echo "" - show_help - exit 1 - ;; - esac -} - -# Run main function -main "$@" diff --git a/publish-to-gitea-multiarch.sh b/publish-to-gitea-multiarch.sh deleted file mode 100755 index 6f6423a..0000000 --- a/publish-to-gitea-multiarch.sh +++ /dev/null @@ -1,146 +0,0 @@ -#!/bin/bash -set -e - -# Colors for output -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[1;33m' -NC='\033[0m' # No Color - -# Configuration -GITEA_HOST="192.168.1.208:3002" -IMAGE_NAME="socktop-webterm" -CARGO_TOML="Cargo.toml" - -echo -e "${GREEN}=== Socktop WebTerm - Multi-Architecture Build & Publish ===${NC}" -echo "" -echo "This script builds for both AMD64 (x86_64) and ARM64 (Raspberry Pi)" -echo "" - -# Check if buildx is available -if ! docker buildx version &> /dev/null; then - echo -e "${RED}Error: docker buildx is not available${NC}" - echo "" - echo "Install buildx:" - echo " Docker Desktop: Already included" - echo " Docker Engine: https://docs.docker.com/buildx/working-with-buildx/" - exit 1 -fi - -echo -e "${GREEN}✓ Docker buildx is available${NC}" -echo "" - -# Extract version from Cargo.toml -if [ ! -f "$CARGO_TOML" ]; then - echo -e "${RED}Error: Cargo.toml not found!${NC}" - exit 1 -fi - -VERSION=$(grep '^version = ' "$CARGO_TOML" | head -1 | sed 's/version = "\(.*\)"/\1/') - -if [ -z "$VERSION" ]; then - echo -e "${RED}Error: Could not extract version from Cargo.toml${NC}" - exit 1 -fi - -echo -e "${YELLOW}Version detected:${NC} $VERSION" -echo -e "${YELLOW}Gitea Host:${NC} $GITEA_HOST" -echo "" - -# Prompt for Gitea username -read -p "Enter Gitea username: " GITEA_USER - -if [ -z "$GITEA_USER" ]; then - echo -e "${RED}Error: Username cannot be empty${NC}" - exit 1 -fi - -# Prompt for Gitea password (hidden input) -read -s -p "Enter Gitea password: " GITEA_PASSWORD -echo "" - -if [ -z "$GITEA_PASSWORD" ]; then - echo -e "${RED}Error: Password cannot be empty${NC}" - exit 1 -fi - -echo "" - -# Docker login to Gitea registry -echo -e "${YELLOW}Logging in to Gitea Docker registry...${NC}" -echo "$GITEA_PASSWORD" | docker login "$GITEA_HOST" -u "$GITEA_USER" --password-stdin - -if [ $? -ne 0 ]; then - echo -e "${RED}Error: Docker login failed${NC}" - exit 1 -fi - -echo -e "${GREEN}✓ Login successful${NC}" -echo "" - -# Create or use existing buildx builder -BUILDER_NAME="multiarch-builder" -echo -e "${YELLOW}Setting up buildx builder...${NC}" - -if ! docker buildx inspect "$BUILDER_NAME" &> /dev/null; then - echo "Creating new buildx builder: $BUILDER_NAME" - docker buildx create --name "$BUILDER_NAME" --use -else - echo "Using existing buildx builder: $BUILDER_NAME" - docker buildx use "$BUILDER_NAME" -fi - -# Bootstrap the builder -docker buildx inspect --bootstrap - -echo -e "${GREEN}✓ Builder ready${NC}" -echo "" - -# Build and push multi-architecture image -echo -e "${YELLOW}Building multi-architecture image...${NC}" -echo "Target platforms: linux/amd64, linux/arm64" -echo "" -echo "This will take several minutes as it builds for both architectures..." -echo "" - -docker buildx build \ - --platform linux/amd64,linux/arm64 \ - --tag "${GITEA_HOST}/${GITEA_USER}/${IMAGE_NAME}:${VERSION}" \ - --tag "${GITEA_HOST}/${GITEA_USER}/${IMAGE_NAME}:latest" \ - --push \ - . - -if [ $? -ne 0 ]; then - echo -e "${RED}Error: Build failed${NC}" - exit 1 -fi - -echo "" -echo -e "${GREEN}✓ Build and push successful${NC}" -echo "" - -# Summary -echo -e "${GREEN}=== Publication Complete ===${NC}" -echo "" -echo "Multi-architecture images published to Gitea registry:" -echo -e " ${GREEN}${GITEA_HOST}/${GITEA_USER}/${IMAGE_NAME}:${VERSION}${NC}" -echo -e " ${GREEN}${GITEA_HOST}/${GITEA_USER}/${IMAGE_NAME}:latest${NC}" -echo "" -echo "Architectures:" -echo " - linux/amd64 (x86_64)" -echo " - linux/arm64 (Raspberry Pi, ARM servers)" -echo "" -echo "To pull on your k3s cluster (will automatically use correct architecture):" -echo -e " ${YELLOW}docker pull ${GITEA_HOST}/${GITEA_USER}/${IMAGE_NAME}:${VERSION}${NC}" -echo -e " ${YELLOW}docker pull ${GITEA_HOST}/${GITEA_USER}/${IMAGE_NAME}:latest${NC}" -echo "" -echo "For Kubernetes, use image:" -echo -e " ${YELLOW}image: ${GITEA_HOST}/${GITEA_USER}/${IMAGE_NAME}:${VERSION}${NC}" -echo "" - -# Logout -echo -e "${YELLOW}Logging out from Gitea registry...${NC}" -docker logout "$GITEA_HOST" -echo -e "${GREEN}✓ Logged out${NC}" -echo "" -echo -e "${GREEN}Done!${NC}" diff --git a/publish-to-gitea.sh b/publish-to-gitea.sh deleted file mode 100755 index e956f90..0000000 --- a/publish-to-gitea.sh +++ /dev/null @@ -1,131 +0,0 @@ -#!/bin/bash -set -e - -# Colors for output -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[1;33m' -NC='\033[0m' # No Color - -# Configuration -GITEA_HOST="192.168.1.208:3002" -IMAGE_NAME="socktop-webterm" -CARGO_TOML="Cargo.toml" - -echo -e "${GREEN}=== Socktop WebTerm - Gitea Docker Registry Publisher ===${NC}" -echo "" - -# Extract version from Cargo.toml -if [ ! -f "$CARGO_TOML" ]; then - echo -e "${RED}Error: Cargo.toml not found!${NC}" - exit 1 -fi - -VERSION=$(grep '^version = ' "$CARGO_TOML" | head -1 | sed 's/version = "\(.*\)"/\1/') - -if [ -z "$VERSION" ]; then - echo -e "${RED}Error: Could not extract version from Cargo.toml${NC}" - exit 1 -fi - -echo -e "${YELLOW}Version detected:${NC} $VERSION" -echo -e "${YELLOW}Gitea Host:${NC} $GITEA_HOST" -echo "" - -# Prompt for Gitea username -read -p "Enter Gitea username: " GITEA_USER - -if [ -z "$GITEA_USER" ]; then - echo -e "${RED}Error: Username cannot be empty${NC}" - exit 1 -fi - -# Prompt for Gitea password (hidden input) -read -s -p "Enter Gitea password: " GITEA_PASSWORD -echo "" - -if [ -z "$GITEA_PASSWORD" ]; then - echo -e "${RED}Error: Password cannot be empty${NC}" - exit 1 -fi - -echo "" - -# Docker login to Gitea registry -echo -e "${YELLOW}Logging in to Gitea Docker registry...${NC}" -echo "$GITEA_PASSWORD" | docker login "$GITEA_HOST" -u "$GITEA_USER" --password-stdin - -if [ $? -ne 0 ]; then - echo -e "${RED}Error: Docker login failed${NC}" - exit 1 -fi - -echo -e "${GREEN}✓ Login successful${NC}" -echo "" - -# Build the Docker image -echo -e "${YELLOW}Building Docker image...${NC}" -docker build -t "${IMAGE_NAME}:${VERSION}" -t "${IMAGE_NAME}:latest" . - -if [ $? -ne 0 ]; then - echo -e "${RED}Error: Docker build failed${NC}" - exit 1 -fi - -echo -e "${GREEN}✓ Build successful${NC}" -echo "" - -# Tag images for Gitea registry -echo -e "${YELLOW}Tagging images for Gitea registry...${NC}" -docker tag "${IMAGE_NAME}:${VERSION}" "${GITEA_HOST}/${GITEA_USER}/${IMAGE_NAME}:${VERSION}" -docker tag "${IMAGE_NAME}:latest" "${GITEA_HOST}/${GITEA_USER}/${IMAGE_NAME}:latest" - -echo -e "${GREEN}✓ Tagged: ${GITEA_HOST}/${GITEA_USER}/${IMAGE_NAME}:${VERSION}${NC}" -echo -e "${GREEN}✓ Tagged: ${GITEA_HOST}/${GITEA_USER}/${IMAGE_NAME}:latest${NC}" -echo "" - -# Push version tag -echo -e "${YELLOW}Pushing version ${VERSION} to registry...${NC}" -docker push "${GITEA_HOST}/${GITEA_USER}/${IMAGE_NAME}:${VERSION}" - -if [ $? -ne 0 ]; then - echo -e "${RED}Error: Failed to push version tag${NC}" - exit 1 -fi - -echo -e "${GREEN}✓ Pushed version ${VERSION}${NC}" -echo "" - -# Push latest tag -echo -e "${YELLOW}Pushing 'latest' tag to registry...${NC}" -docker push "${GITEA_HOST}/${GITEA_USER}/${IMAGE_NAME}:latest" - -if [ $? -ne 0 ]; then - echo -e "${RED}Error: Failed to push latest tag${NC}" - exit 1 -fi - -echo -e "${GREEN}✓ Pushed 'latest' tag${NC}" -echo "" - -# Summary -echo -e "${GREEN}=== Publication Complete ===${NC}" -echo "" -echo "Images published to Gitea registry:" -echo -e " ${GREEN}${GITEA_HOST}/${GITEA_USER}/${IMAGE_NAME}:${VERSION}${NC}" -echo -e " ${GREEN}${GITEA_HOST}/${GITEA_USER}/${IMAGE_NAME}:latest${NC}" -echo "" -echo "To pull on your k3s cluster or CasaOS:" -echo -e " ${YELLOW}docker pull ${GITEA_HOST}/${GITEA_USER}/${IMAGE_NAME}:${VERSION}${NC}" -echo -e " ${YELLOW}docker pull ${GITEA_HOST}/${GITEA_USER}/${IMAGE_NAME}:latest${NC}" -echo "" -echo "For Kubernetes, use image:" -echo -e " ${YELLOW}image: ${GITEA_HOST}/${GITEA_USER}/${IMAGE_NAME}:${VERSION}${NC}" -echo "" - -# Logout -echo -e "${YELLOW}Logging out from Gitea registry...${NC}" -docker logout "$GITEA_HOST" -echo -e "${GREEN}✓ Logged out${NC}" -echo "" -echo -e "${GREEN}Done!${NC}" diff --git a/templates/term.html b/templates/term.html index 97c019a..163a144 100644 --- a/templates/term.html +++ b/templates/term.html @@ -149,14 +149,21 @@