From a45b03977733e733df08068afac6e7c3b903143c Mon Sep 17 00:00:00 2001 From: Jonathan Date: Fri, 30 May 2025 10:35:12 -0500 Subject: [PATCH] chore: remove outdated and redundant shell scripts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove 18 scripts that are no longer needed: - Archived scripts directory (one-time migrations, old tests) - Redundant build scripts (replaced by build.sh and GitHub Actions) - One-time setup/migration scripts - Scripts with security anti-patterns (hardcoded paths, baked credentials) - Unnecessary backup scripts Remaining scripts that need review are tracked in #139 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- publish-docker.sh | 36 --- scripts/archived/one-time/cleanup-scripts.sh | 263 ------------------ .../archived/one-time/prepare-clean-repo.sh | 87 ------ .../archived/one-time/reorganize-scripts.sh | 135 --------- .../archived/one-time/script-organization.md | 128 --------- scripts/archived/test-claude-version.sh | 7 - scripts/archived/test-direct-claude.sh | 9 - scripts/archived/update-aws-creds.sh | 26 -- scripts/aws/migrate-aws-credentials.sh | 119 -------- scripts/build/build-claude-container.sh | 22 -- scripts/build/build-claudecode.sh | 13 - scripts/build/update-production-image.sh | 106 ------- scripts/security/fix-credential-references.sh | 52 ---- scripts/setup/create-new-repo.sh | 46 --- scripts/setup/setup-claude-backup-cron.sh | 41 --- scripts/setup/setup-github-runner.sh | 91 ------ scripts/setup/setup-new-repo.sh | 49 ---- scripts/utils/backup-claude-db.sh | 57 ---- 18 files changed, 1287 deletions(-) delete mode 100755 publish-docker.sh delete mode 100755 scripts/archived/one-time/cleanup-scripts.sh delete mode 100755 scripts/archived/one-time/prepare-clean-repo.sh delete mode 100755 scripts/archived/one-time/reorganize-scripts.sh delete mode 100644 scripts/archived/one-time/script-organization.md delete mode 100755 scripts/archived/test-claude-version.sh delete mode 100755 scripts/archived/test-direct-claude.sh delete mode 100755 scripts/archived/update-aws-creds.sh delete mode 100755 scripts/aws/migrate-aws-credentials.sh delete mode 100755 scripts/build/build-claude-container.sh delete mode 100755 scripts/build/build-claudecode.sh delete mode 100755 scripts/build/update-production-image.sh delete mode 100755 scripts/security/fix-credential-references.sh delete mode 100755 scripts/setup/create-new-repo.sh delete mode 100755 scripts/setup/setup-claude-backup-cron.sh delete mode 100755 scripts/setup/setup-github-runner.sh delete mode 100755 scripts/setup/setup-new-repo.sh delete mode 100755 scripts/utils/backup-claude-db.sh diff --git a/publish-docker.sh b/publish-docker.sh deleted file mode 100755 index a280c1a..0000000 --- a/publish-docker.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash - -# Docker Hub publishing script for Claude GitHub Webhook -# Usage: ./publish-docker.sh YOUR_DOCKERHUB_USERNAME [VERSION] - -DOCKERHUB_USERNAME=${1:-intelligenceassist} -VERSION=${2:-latest} - -# Default to intelligenceassist organization - -IMAGE_NAME="claude-github-webhook" -FULL_IMAGE_NAME="$DOCKERHUB_USERNAME/$IMAGE_NAME" - -echo "Building Docker image..." -docker build -t $IMAGE_NAME:latest . - -echo "Tagging image as $FULL_IMAGE_NAME:$VERSION..." -docker tag $IMAGE_NAME:latest $FULL_IMAGE_NAME:$VERSION - -if [ "$VERSION" != "latest" ]; then - echo "Also tagging as $FULL_IMAGE_NAME:latest..." - docker tag $IMAGE_NAME:latest $FULL_IMAGE_NAME:latest -fi - -echo "Logging in to Docker Hub..." -docker login - -echo "Pushing to Docker Hub..." -docker push $FULL_IMAGE_NAME:$VERSION - -if [ "$VERSION" != "latest" ]; then - docker push $FULL_IMAGE_NAME:latest -fi - -echo "Successfully published to Docker Hub!" -echo "Users can now pull with: docker pull $FULL_IMAGE_NAME:$VERSION" \ No newline at end of file diff --git a/scripts/archived/one-time/cleanup-scripts.sh b/scripts/archived/one-time/cleanup-scripts.sh deleted file mode 100755 index b020d2f..0000000 --- a/scripts/archived/one-time/cleanup-scripts.sh +++ /dev/null @@ -1,263 +0,0 @@ -#!/bin/bash -set -e - -# Script to clean up redundant scripts after reorganization -echo "Starting script cleanup..." - -# Create a backup directory for redundant scripts -BACKUP_DIR="./scripts/archived" -mkdir -p "$BACKUP_DIR" -echo "Created backup directory: $BACKUP_DIR" - -# Function to archive a script instead of deleting it -archive_script() { - local script=$1 - if [ -f "$script" ]; then - echo "Archiving $script to $BACKUP_DIR" - git mv "$script" "$BACKUP_DIR/$(basename $script)" - else - echo "Warning: $script not found, skipping" - fi -} - -# Archive redundant test scripts -echo "Archiving redundant test scripts..." -archive_script "test/claude/test-direct-claude.sh" # Duplicate of test-claude-direct.sh -archive_script "test/claude/test-claude-version.sh" # Can be merged with test-claude-installation.sh - -# Archive obsolete AWS credential scripts -echo "Archiving obsolete AWS credential scripts..." -archive_script "scripts/aws/update-aws-creds.sh" # Obsolete, replaced by profile-based auth - -# Archive temporary/one-time setup scripts -echo "Moving one-time setup scripts to archived directory..." -mkdir -p "$BACKUP_DIR/one-time" -git mv "scripts/utils/prepare-clean-repo.sh" "$BACKUP_DIR/one-time/" -git mv "scripts/utils/fix-credential-references.sh" "$BACKUP_DIR/one-time/" - -# Archive redundant container test scripts that can be consolidated -echo "Archiving redundant container test scripts..." -archive_script "test/container/test-container-privileged.sh" # Can be merged with test-basic-container.sh - -# Archive our temporary reorganization scripts -echo "Archiving temporary reorganization scripts..." -git mv "reorganize-scripts.sh" "$BACKUP_DIR/one-time/" -git mv "script-organization.md" "$BACKUP_DIR/one-time/" - -# After archiving, create a consolidated container test script -echo "Creating consolidated container test script..." -cat > test/container/test-container.sh << 'EOF' -#!/bin/bash -# Consolidated container test script -# Usage: ./test-container.sh [basic|privileged|cleanup] - -set -e - -TEST_TYPE=${1:-basic} - -case "$TEST_TYPE" in - basic) - echo "Running basic container test..." - # Basic container test logic from test-basic-container.sh - docker run --rm -it \ - -e REPO_FULL_NAME="owner/test-repo" \ - -e ISSUE_NUMBER="1" \ - -e IS_PULL_REQUEST="false" \ - -e COMMAND="echo 'Basic container test'" \ - -e GITHUB_TOKEN="${GITHUB_TOKEN:-test-token}" \ - claude-code-runner:latest - ;; - - privileged) - echo "Running privileged container test..." - # Privileged container test logic from test-container-privileged.sh - docker run --rm -it \ - --privileged \ - -e REPO_FULL_NAME="owner/test-repo" \ - -e ISSUE_NUMBER="1" \ - -e IS_PULL_REQUEST="false" \ - -e COMMAND="echo 'Privileged container test'" \ - -e GITHUB_TOKEN="${GITHUB_TOKEN:-test-token}" \ - claude-code-runner:latest - ;; - - cleanup) - echo "Running container cleanup test..." - # Container cleanup test logic from test-container-cleanup.sh - docker run --rm -it \ - -e REPO_FULL_NAME="owner/test-repo" \ - -e ISSUE_NUMBER="1" \ - -e IS_PULL_REQUEST="false" \ - -e COMMAND="echo 'Container cleanup test'" \ - -e GITHUB_TOKEN="${GITHUB_TOKEN:-test-token}" \ - claude-code-runner:latest - ;; - - *) - echo "Unknown test type: $TEST_TYPE" - echo "Usage: ./test-container.sh [basic|privileged|cleanup]" - exit 1 - ;; -esac - -echo "Test complete!" -EOF -chmod +x test/container/test-container.sh - -# Create a consolidated Claude test script -echo "Creating consolidated Claude test script..." -cat > test/claude/test-claude.sh << 'EOF' -#!/bin/bash -# Consolidated Claude test script -# Usage: ./test-claude.sh [direct|installation|no-firewall|response] - -set -e - -TEST_TYPE=${1:-direct} - -case "$TEST_TYPE" in - direct) - echo "Testing direct Claude integration..." - # Direct Claude test logic from test-claude-direct.sh - docker run --rm -it \ - -e REPO_FULL_NAME="owner/test-repo" \ - -e ISSUE_NUMBER="1" \ - -e IS_PULL_REQUEST="false" \ - -e COMMAND="echo 'Direct Claude test'" \ - -e GITHUB_TOKEN="${GITHUB_TOKEN:-test-token}" \ - -e ANTHROPIC_API_KEY="${ANTHROPIC_API_KEY:-test-key}" \ - claude-code-runner:latest - ;; - - installation) - echo "Testing Claude installation..." - # Installation test logic from test-claude-installation.sh and test-claude-version.sh - docker run --rm -it \ - -e REPO_FULL_NAME="owner/test-repo" \ - -e ISSUE_NUMBER="1" \ - -e IS_PULL_REQUEST="false" \ - -e COMMAND="claude-cli --version && claude --version" \ - -e GITHUB_TOKEN="${GITHUB_TOKEN:-test-token}" \ - claude-code-runner:latest - ;; - - no-firewall) - echo "Testing Claude without firewall..." - # Test logic from test-claude-no-firewall.sh - docker run --rm -it \ - -e REPO_FULL_NAME="owner/test-repo" \ - -e ISSUE_NUMBER="1" \ - -e IS_PULL_REQUEST="false" \ - -e COMMAND="echo 'Claude without firewall test'" \ - -e GITHUB_TOKEN="${GITHUB_TOKEN:-test-token}" \ - -e DISABLE_FIREWALL=true \ - claude-code-runner:latest - ;; - - response) - echo "Testing Claude response..." - # Test logic from test-claude-response.sh - docker run --rm -it \ - -e REPO_FULL_NAME="owner/test-repo" \ - -e ISSUE_NUMBER="1" \ - -e IS_PULL_REQUEST="false" \ - -e COMMAND="claude \"Tell me a joke\"" \ - -e GITHUB_TOKEN="${GITHUB_TOKEN:-test-token}" \ - -e ANTHROPIC_API_KEY="${ANTHROPIC_API_KEY:-test-key}" \ - claude-code-runner:latest - ;; - - *) - echo "Unknown test type: $TEST_TYPE" - echo "Usage: ./test-claude.sh [direct|installation|no-firewall|response]" - exit 1 - ;; -esac - -echo "Test complete!" -EOF -chmod +x test/claude/test-claude.sh - -# Create a consolidated build script -echo "Creating consolidated build script..." -cat > scripts/build/build.sh << 'EOF' -#!/bin/bash -# Consolidated build script -# Usage: ./build.sh [claude|claudecode|production] - -set -e - -BUILD_TYPE=${1:-claudecode} - -case "$BUILD_TYPE" in - claude) - echo "Building Claude container..." - docker build -f Dockerfile.claude -t claude-container:latest . - ;; - - claudecode) - echo "Building Claude Code runner Docker image..." - docker build -f Dockerfile.claudecode -t claude-code-runner:latest . - ;; - - production) - if [ ! -d "./claude-config" ]; then - echo "Error: claude-config directory not found." - echo "Please run ./scripts/setup/setup-claude-auth.sh first and copy the config." - exit 1 - fi - - echo "Building production image with pre-authenticated config..." - cp Dockerfile.claudecode Dockerfile.claudecode.backup - # Production build logic from update-production-image.sh - # ... (truncated for brevity) - docker build -f Dockerfile.claudecode -t claude-code-runner:production . - ;; - - *) - echo "Unknown build type: $BUILD_TYPE" - echo "Usage: ./build.sh [claude|claudecode|production]" - exit 1 - ;; -esac - -echo "Build complete!" -EOF -chmod +x scripts/build/build.sh - -# Update documentation to reflect the changes -echo "Updating documentation..." -sed -i 's|test-direct-claude.sh|test-claude.sh direct|g' SCRIPTS.md -sed -i 's|test-claude-direct.sh|test-claude.sh direct|g' SCRIPTS.md -sed -i 's|test-claude-version.sh|test-claude.sh installation|g' SCRIPTS.md -sed -i 's|test-claude-installation.sh|test-claude.sh installation|g' SCRIPTS.md -sed -i 's|test-claude-no-firewall.sh|test-claude.sh no-firewall|g' SCRIPTS.md -sed -i 's|test-claude-response.sh|test-claude.sh response|g' SCRIPTS.md - -sed -i 's|test-basic-container.sh|test-container.sh basic|g' SCRIPTS.md -sed -i 's|test-container-privileged.sh|test-container.sh privileged|g' SCRIPTS.md -sed -i 's|test-container-cleanup.sh|test-container.sh cleanup|g' SCRIPTS.md - -sed -i 's|build-claude-container.sh|build.sh claude|g' SCRIPTS.md -sed -i 's|build-claudecode.sh|build.sh claudecode|g' SCRIPTS.md -sed -i 's|update-production-image.sh|build.sh production|g' SCRIPTS.md - -# Create a final wrapper script for backward compatibility -cat > build-claudecode.sh << 'EOF' -#!/bin/bash -# Wrapper script for backward compatibility -echo "This script is now located at scripts/build/build.sh" -exec scripts/build/build.sh claudecode "$@" -EOF -chmod +x build-claudecode.sh - -# After all operations are complete, clean up this script too -echo "Script cleanup complete!" -echo -echo "Note: This script (cleanup-scripts.sh) has completed its job and can now be removed." -echo "After verifying the changes, you can remove it with:" -echo "rm cleanup-scripts.sh" -echo -echo "To commit these changes, run:" -echo "git add ." -echo "git commit -m \"Clean up redundant scripts and consolidate functionality\"" \ No newline at end of file diff --git a/scripts/archived/one-time/prepare-clean-repo.sh b/scripts/archived/one-time/prepare-clean-repo.sh deleted file mode 100755 index 13510ee..0000000 --- a/scripts/archived/one-time/prepare-clean-repo.sh +++ /dev/null @@ -1,87 +0,0 @@ -#!/bin/bash -# This script prepares a clean repository without sensitive files - -# Set directories -CURRENT_REPO="/home/jonflatt/n8n/claude-repo" -CLEAN_REPO="/tmp/clean-repo" - -# Create clean repo directory if it doesn't exist -mkdir -p "$CLEAN_REPO" - -# Files and patterns to exclude -EXCLUDES=( - ".git" - ".env" - ".env.backup" - "node_modules" - "coverage" - "\\" -) - -# Build rsync exclude arguments -EXCLUDE_ARGS="" -for pattern in "${EXCLUDES[@]}"; do - EXCLUDE_ARGS="$EXCLUDE_ARGS --exclude='$pattern'" -done - -# Sync files to clean repo -echo "Copying files to clean repository..." -eval "rsync -av $EXCLUDE_ARGS $CURRENT_REPO/ $CLEAN_REPO/" - -# Create a new .gitignore if it doesn't exist -if [ ! -f "$CLEAN_REPO/.gitignore" ]; then - echo "Creating .gitignore..." - cat > "$CLEAN_REPO/.gitignore" << EOF -# Node.js -node_modules/ -npm-debug.log -yarn-debug.log -yarn-error.log - -# Environment variables -.env -.env.local -.env.development.local -.env.test.local -.env.production.local -.env.backup - -# Coverage reports -coverage/ - -# Temp directory -tmp/ - -# Test results -test-results/ - -# IDE -.idea/ -.vscode/ -*.swp -*.swo - -# OS -.DS_Store -Thumbs.db - -# Project specific -/response.txt -"\\" -EOF -fi - -echo "Clean repository prepared at $CLEAN_REPO" -echo "" -echo "Next steps:" -echo "1. Create a new GitHub repository" -echo "2. Initialize the clean repository with git:" -echo " cd $CLEAN_REPO" -echo " git init" -echo " git add ." -echo " git commit -m \"Initial commit\"" -echo "3. Set the remote origin and push:" -echo " git remote add origin " -echo " git push -u origin main" -echo "" -echo "Important: Make sure to review the files once more before committing to ensure no sensitive data is included." \ No newline at end of file diff --git a/scripts/archived/one-time/reorganize-scripts.sh b/scripts/archived/one-time/reorganize-scripts.sh deleted file mode 100755 index fa50fcd..0000000 --- a/scripts/archived/one-time/reorganize-scripts.sh +++ /dev/null @@ -1,135 +0,0 @@ -#!/bin/bash -set -e - -# Script to reorganize the script files according to the proposed structure -echo "Starting script reorganization..." - -# Create directory structure -echo "Creating directory structure..." -mkdir -p scripts/setup -mkdir -p scripts/build -mkdir -p scripts/aws -mkdir -p scripts/runtime -mkdir -p scripts/security -mkdir -p scripts/utils - -mkdir -p test/integration -mkdir -p test/aws -mkdir -p test/container -mkdir -p test/claude -mkdir -p test/security -mkdir -p test/utils - -# Move setup scripts -echo "Moving setup scripts..." -git mv scripts/setup.sh scripts/setup/ -git mv scripts/setup-precommit.sh scripts/setup/ -git mv setup-claude-auth.sh scripts/setup/ -git mv setup-new-repo.sh scripts/setup/ -git mv create-new-repo.sh scripts/setup/ - -# Move build scripts -echo "Moving build scripts..." -git mv build-claude-container.sh scripts/build/ -git mv build-claudecode.sh scripts/build/ -git mv update-production-image.sh scripts/build/ - -# Move AWS scripts -echo "Moving AWS scripts..." -git mv scripts/create-aws-profile.sh scripts/aws/ -git mv scripts/migrate-aws-credentials.sh scripts/aws/ -git mv scripts/setup-aws-profiles.sh scripts/aws/ -git mv update-aws-creds.sh scripts/aws/ - -# Move runtime scripts -echo "Moving runtime scripts..." -git mv start-api.sh scripts/runtime/ -git mv entrypoint.sh scripts/runtime/ -git mv claudecode-entrypoint.sh scripts/runtime/ -git mv startup.sh scripts/runtime/ -git mv claude-wrapper.sh scripts/runtime/ - -# Move security scripts -echo "Moving security scripts..." -git mv init-firewall.sh scripts/security/ -git mv accept-permissions.sh scripts/security/ -git mv fix-credential-references.sh scripts/security/ - -# Move utility scripts -echo "Moving utility scripts..." -git mv scripts/ensure-test-dirs.sh scripts/utils/ -git mv prepare-clean-repo.sh scripts/utils/ -git mv volume-test.sh scripts/utils/ - -# Move test scripts -echo "Moving test scripts..." -git mv test/test-full-flow.sh test/integration/ -git mv test/test-claudecode-docker.sh test/integration/ - -git mv test/test-aws-profile.sh test/aws/ -git mv test/test-aws-mount.sh test/aws/ - -git mv test/test-basic-container.sh test/container/ -git mv test/test-container-cleanup.sh test/container/ -git mv test/test-container-privileged.sh test/container/ - -git mv test/test-claude-direct.sh test/claude/ -git mv test/test-claude-no-firewall.sh test/claude/ -git mv test/test-claude-installation.sh test/claude/ -git mv test/test-claude-version.sh test/claude/ -git mv test/test-claude-response.sh test/claude/ -git mv test/test-direct-claude.sh test/claude/ - -git mv test/test-firewall.sh test/security/ -git mv test/test-with-auth.sh test/security/ -git mv test/test-github-token.sh test/security/ - -# Create wrapper scripts for backward compatibility -echo "Creating wrapper scripts for backward compatibility..." - -cat > setup-claude-auth.sh << 'EOF' -#!/bin/bash -# Wrapper script for backward compatibility -echo "This script is now located at scripts/setup/setup-claude-auth.sh" -exec scripts/setup/setup-claude-auth.sh "$@" -EOF -chmod +x setup-claude-auth.sh - -cat > build-claudecode.sh << 'EOF' -#!/bin/bash -# Wrapper script for backward compatibility -echo "This script is now located at scripts/build/build-claudecode.sh" -exec scripts/build/build-claudecode.sh "$@" -EOF -chmod +x build-claudecode.sh - -cat > start-api.sh << 'EOF' -#!/bin/bash -# Wrapper script for backward compatibility -echo "This script is now located at scripts/runtime/start-api.sh" -exec scripts/runtime/start-api.sh "$@" -EOF -chmod +x start-api.sh - -# Update docker-compose.yml file if it references specific script paths -echo "Checking for docker-compose.yml updates..." -if [ -f docker-compose.yml ]; then - sed -i 's#./claudecode-entrypoint.sh#./scripts/runtime/claudecode-entrypoint.sh#g' docker-compose.yml - sed -i 's#./entrypoint.sh#./scripts/runtime/entrypoint.sh#g' docker-compose.yml -fi - -# Update Dockerfile.claudecode if it references specific script paths -echo "Checking for Dockerfile.claudecode updates..." -if [ -f Dockerfile.claudecode ]; then - sed -i 's#COPY init-firewall.sh#COPY scripts/security/init-firewall.sh#g' Dockerfile.claudecode - sed -i 's#COPY claudecode-entrypoint.sh#COPY scripts/runtime/claudecode-entrypoint.sh#g' Dockerfile.claudecode -fi - -echo "Script reorganization complete!" -echo -echo "Please review the changes and test that all scripts still work properly." -echo "You may need to update additional references in other files or scripts." -echo -echo "To commit these changes, run:" -echo "git add ." -echo "git commit -m \"Reorganize scripts into a more structured directory layout\"" \ No newline at end of file diff --git a/scripts/archived/one-time/script-organization.md b/scripts/archived/one-time/script-organization.md deleted file mode 100644 index 0c1f10f..0000000 --- a/scripts/archived/one-time/script-organization.md +++ /dev/null @@ -1,128 +0,0 @@ -# Script Organization Proposal - -## Categories of Scripts - -### 1. Setup and Installation -- `scripts/setup.sh` - Main setup script for the project -- `scripts/setup-precommit.sh` - Sets up pre-commit hooks -- `setup-claude-auth.sh` - Sets up Claude authentication -- `setup-new-repo.sh` - Sets up a new clean repository -- `create-new-repo.sh` - Creates a new repository - -### 2. Build Scripts -- `build-claude-container.sh` - Builds the Claude container -- `build-claudecode.sh` - Builds the Claude Code runner Docker image -- `update-production-image.sh` - Updates the production Docker image - -### 3. AWS Configuration and Credentials -- `scripts/create-aws-profile.sh` - Creates AWS profiles programmatically -- `scripts/migrate-aws-credentials.sh` - Migrates AWS credentials -- `scripts/setup-aws-profiles.sh` - Sets up AWS profiles -- `update-aws-creds.sh` - Updates AWS credentials - -### 4. Runtime and Execution -- `start-api.sh` - Starts the API server -- `entrypoint.sh` - Container entrypoint script -- `claudecode-entrypoint.sh` - Claude Code container entrypoint -- `startup.sh` - Startup script -- `claude-wrapper.sh` - Wrapper for Claude CLI - -### 5. Network and Security -- `init-firewall.sh` - Initializes firewall for containers -- `accept-permissions.sh` - Handles permission acceptance -- `fix-credential-references.sh` - Fixes credential references - -### 6. Testing -- `test/test-full-flow.sh` - Tests the full workflow -- `test/test-claudecode-docker.sh` - Tests Claude Code Docker setup -- `test/test-github-token.sh` - Tests GitHub token -- `test/test-aws-profile.sh` - Tests AWS profile -- `test/test-basic-container.sh` - Tests basic container functionality -- `test/test-claude-direct.sh` - Tests direct Claude integration -- `test/test-firewall.sh` - Tests firewall configuration -- `test/test-direct-claude.sh` - Tests direct Claude access -- `test/test-claude-no-firewall.sh` - Tests Claude without firewall -- `test/test-claude-installation.sh` - Tests Claude installation -- `test/test-aws-mount.sh` - Tests AWS mount functionality -- `test/test-claude-version.sh` - Tests Claude version -- `test/test-container-cleanup.sh` - Tests container cleanup -- `test/test-claude-response.sh` - Tests Claude response -- `test/test-container-privileged.sh` - Tests container privileged mode -- `test/test-with-auth.sh` - Tests with authentication - -### 7. Utility Scripts -- `scripts/ensure-test-dirs.sh` - Ensures test directories exist -- `prepare-clean-repo.sh` - Prepares a clean repository -- `volume-test.sh` - Tests volume mounting - -## Proposed Directory Structure - -``` -/claude-repo -├── scripts/ -│ ├── setup/ -│ │ ├── setup.sh -│ │ ├── setup-precommit.sh -│ │ ├── setup-claude-auth.sh -│ │ ├── setup-new-repo.sh -│ │ └── create-new-repo.sh -│ ├── build/ -│ │ ├── build-claude-container.sh -│ │ ├── build-claudecode.sh -│ │ └── update-production-image.sh -│ ├── aws/ -│ │ ├── create-aws-profile.sh -│ │ ├── migrate-aws-credentials.sh -│ │ ├── setup-aws-profiles.sh -│ │ └── update-aws-creds.sh -│ ├── runtime/ -│ │ ├── start-api.sh -│ │ ├── entrypoint.sh -│ │ ├── claudecode-entrypoint.sh -│ │ ├── startup.sh -│ │ └── claude-wrapper.sh -│ ├── security/ -│ │ ├── init-firewall.sh -│ │ ├── accept-permissions.sh -│ │ └── fix-credential-references.sh -│ └── utils/ -│ ├── ensure-test-dirs.sh -│ ├── prepare-clean-repo.sh -│ └── volume-test.sh -├── test/ -│ ├── integration/ -│ │ ├── test-full-flow.sh -│ │ ├── test-claudecode-docker.sh -│ │ └── ... -│ ├── aws/ -│ │ ├── test-aws-profile.sh -│ │ ├── test-aws-mount.sh -│ │ └── ... -│ ├── container/ -│ │ ├── test-basic-container.sh -│ │ ├── test-container-cleanup.sh -│ │ ├── test-container-privileged.sh -│ │ └── ... -│ ├── claude/ -│ │ ├── test-claude-direct.sh -│ │ ├── test-claude-no-firewall.sh -│ │ ├── test-claude-installation.sh -│ │ ├── test-claude-version.sh -│ │ ├── test-claude-response.sh -│ │ └── ... -│ ├── security/ -│ │ ├── test-firewall.sh -│ │ ├── test-with-auth.sh -│ │ └── test-github-token.sh -│ └── utils/ -│ └── ... -└── ... -``` - -## Implementation Plan - -1. Create the new directory structure -2. Move scripts to their appropriate categories -3. Update references in scripts to point to new locations -4. Update documentation to reflect new organization -5. Create wrapper scripts if needed to maintain backward compatibility \ No newline at end of file diff --git a/scripts/archived/test-claude-version.sh b/scripts/archived/test-claude-version.sh deleted file mode 100755 index 263f455..0000000 --- a/scripts/archived/test-claude-version.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -echo "Testing if Claude executable runs..." - -docker run --rm \ - --entrypoint /bin/bash \ - claude-code-runner:latest \ - -c "cd /workspace && /usr/local/share/npm-global/bin/claude --version 2>&1 || echo 'Exit code: $?'" \ No newline at end of file diff --git a/scripts/archived/test-direct-claude.sh b/scripts/archived/test-direct-claude.sh deleted file mode 100755 index 5ab7dc6..0000000 --- a/scripts/archived/test-direct-claude.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -echo "Testing Claude directly without entrypoint..." - -docker run --rm \ - --privileged \ - -v $HOME/.aws:/home/node/.aws:ro \ - --entrypoint /bin/bash \ - claude-code-runner:latest \ - -c "cd /workspace && export HOME=/home/node && export PATH=/usr/local/share/npm-global/bin:\$PATH && export AWS_PROFILE=claude-webhook && export AWS_REGION=us-east-2 && export AWS_CONFIG_FILE=/home/node/.aws/config && export AWS_SHARED_CREDENTIALS_FILE=/home/node/.aws/credentials && export CLAUDE_CODE_USE_BEDROCK=1 && export ANTHROPIC_MODEL=us.anthropic.claude-3-7-sonnet-20250219-v1:0 && /usr/local/bin/init-firewall.sh && claude --print 'Hello world' 2>&1" \ No newline at end of file diff --git a/scripts/archived/update-aws-creds.sh b/scripts/archived/update-aws-creds.sh deleted file mode 100755 index 02062bb..0000000 --- a/scripts/archived/update-aws-creds.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash - -# Update AWS credentials in the environment -export AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY_ID:-dummy-access-key}" -export AWS_SECRET_ACCESS_KEY="${AWS_SECRET_ACCESS_KEY:-dummy-secret-key}" - -# Create or update .env file with the new credentials -if [ -f .env ]; then - # Update existing .env file - sed -i "s/^AWS_ACCESS_KEY_ID=.*/AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID/" .env - sed -i "s/^AWS_SECRET_ACCESS_KEY=.*/AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY/" .env -else - # Create new .env file from example - cp .env.example .env - sed -i "s/^AWS_ACCESS_KEY_ID=.*/AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID/" .env - sed -i "s/^AWS_SECRET_ACCESS_KEY=.*/AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY/" .env -fi - -echo "AWS credentials updated successfully." -echo "AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID" -echo "AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY:0:3}...${AWS_SECRET_ACCESS_KEY:(-3)}" - -# Export the credentials for current session -export AWS_ACCESS_KEY_ID -export AWS_SECRET_ACCESS_KEY -echo "Credentials exported to current shell environment." \ No newline at end of file diff --git a/scripts/aws/migrate-aws-credentials.sh b/scripts/aws/migrate-aws-credentials.sh deleted file mode 100755 index 5e1ef03..0000000 --- a/scripts/aws/migrate-aws-credentials.sh +++ /dev/null @@ -1,119 +0,0 @@ -#!/bin/bash - -# Migration script to transition from static AWS credentials to best practices - -echo "AWS Credential Migration Script" -echo "==============================" -echo - -# Function to check if running on EC2 -check_ec2() { - if curl -s -m 1 http://169.254.169.254/latest/meta-data/ > /dev/null 2>&1; then - echo "✅ Running on EC2 instance" - return 0 - else - echo "❌ Not running on EC2 instance" - return 1 - fi -} - -# Function to check if running in ECS -check_ecs() { - if [ -n "${AWS_CONTAINER_CREDENTIALS_RELATIVE_URI}" ]; then - echo "✅ Running in ECS with task role" - return 0 - else - echo "❌ Not running in ECS" - return 1 - fi -} - -# Function to check for static credentials -check_static_credentials() { - if [ -n "${AWS_ACCESS_KEY_ID}" ] && [ -n "${AWS_SECRET_ACCESS_KEY}" ]; then - echo "⚠️ Found static AWS credentials in environment" - return 0 - else - echo "✅ No static credentials in environment" - return 1 - fi -} - -# Function to update .env file -update_env_file() { - if [ -f .env ]; then - echo "Updating .env file..." - - # Comment out static credentials - sed -i 's/^AWS_ACCESS_KEY_ID=/#AWS_ACCESS_KEY_ID=/' .env - sed -i 's/^AWS_SECRET_ACCESS_KEY=/#AWS_SECRET_ACCESS_KEY=/' .env - - # Add migration notes - echo "" >> .env - echo "# AWS Credentials migrated to use IAM roles/instance profiles" >> .env - echo "# See docs/aws-authentication-best-practices.md for details" >> .env - echo "" >> .env - - echo "✅ Updated .env file" - fi -} - -# Main migration process -echo "1. Checking current environment..." -echo - -if check_ec2; then - echo " Recommendation: Use IAM instance profile" - echo " The application will automatically use instance metadata" -elif check_ecs; then - echo " Recommendation: Use ECS task role" - echo " The application will automatically use task credentials" -else - echo " Recommendation: Use temporary credentials with STS AssumeRole" -fi - -echo -echo "2. Checking for static credentials..." -echo - -if check_static_credentials; then - echo " ⚠️ WARNING: Static credentials should be replaced with temporary credentials" - echo - read -p " Do you want to disable static credentials? (y/n) " -n 1 -r - echo - if [[ $REPLY =~ ^[Yy]$ ]]; then - update_env_file - echo - echo " To use temporary credentials, configure:" - echo " - AWS_ROLE_ARN: The IAM role to assume" - echo " - Or use AWS CLI profiles with assume role" - fi -fi - -echo -echo "3. Testing new credential provider..." -echo - -# Test the credential provider -node test/test-aws-credential-provider.js - -echo -echo "Migration complete!" -echo -echo "Next steps:" -echo "1. Review docs/aws-authentication-best-practices.md" -echo "2. Update your deployment configuration" -echo "3. Test the application with new credential provider" -echo "4. Remove update-aws-creds.sh script (no longer needed)" -echo - -# Check if update-aws-creds.sh exists and suggest removal -if [ -f update-aws-creds.sh ]; then - echo "⚠️ Found update-aws-creds.sh - this script is no longer needed" - read -p "Do you want to remove it? (y/n) " -n 1 -r - echo - if [[ $REPLY =~ ^[Yy]$ ]]; then - rm update-aws-creds.sh - echo "✅ Removed update-aws-creds.sh" - fi -fi \ No newline at end of file diff --git a/scripts/build/build-claude-container.sh b/scripts/build/build-claude-container.sh deleted file mode 100755 index d57419b..0000000 --- a/scripts/build/build-claude-container.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -# Build the Claude Code container -echo "Building Claude Code container..." -docker build -t claudecode:latest -f Dockerfile.claude . - -echo "Container built successfully. You can run it with:" -echo "docker run --rm claudecode:latest \"claude --help\"" - -# Enable container mode in the .env file if it's not already set -if ! grep -q "CLAUDE_USE_CONTAINERS=1" .env 2>/dev/null; then - echo "" - echo "Enabling container mode in .env file..." - echo "CLAUDE_USE_CONTAINERS=1" >> .env - echo "CLAUDE_CONTAINER_IMAGE=claudecode:latest" >> .env - echo "Container mode enabled in .env file" -fi - -echo "" -echo "Done! You can now use the Claude API with container mode." -echo "To test it, run:" -echo "node test-claude-api.js owner/repo container \"Your command here\"" \ No newline at end of file diff --git a/scripts/build/build-claudecode.sh b/scripts/build/build-claudecode.sh deleted file mode 100755 index e38f81b..0000000 --- a/scripts/build/build-claudecode.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -# Build the Claude Code runner Docker image - -echo "Building Claude Code runner Docker image..." -docker build -f Dockerfile.claudecode -t claudecode:latest . - -# Also tag it with the old name for backward compatibility -docker tag claudecode:latest claude-code-runner:latest - -echo "Build complete!" -echo "Image tagged as:" -echo " - claudecode:latest (primary)" -echo " - claude-code-runner:latest (backward compatibility)" \ No newline at end of file diff --git a/scripts/build/update-production-image.sh b/scripts/build/update-production-image.sh deleted file mode 100755 index 4519e0a..0000000 --- a/scripts/build/update-production-image.sh +++ /dev/null @@ -1,106 +0,0 @@ -#!/bin/bash -if [ ! -d "./claude-config" ]; then - echo "Error: claude-config directory not found." - echo "Please run ./setup-claude-auth.sh first and copy the config." - exit 1 -fi - -echo "Updating Dockerfile.claudecode to include pre-authenticated config..." - -# Create a backup of the original Dockerfile -cp Dockerfile.claudecode Dockerfile.claudecode.backup - -# Update the Dockerfile to copy the claude config -cat > Dockerfile.claudecode.tmp << 'EOF' -FROM node:20 - -# Install dependencies -RUN apt update && apt install -y less \ - git \ - procps \ - sudo \ - fzf \ - zsh \ - man-db \ - unzip \ - gnupg2 \ - gh \ - iptables \ - ipset \ - iproute2 \ - dnsutils \ - aggregate \ - jq - -# Set up npm global directory -RUN mkdir -p /usr/local/share/npm-global && \ - chown -R node:node /usr/local/share - -# Configure zsh and command history -ENV USERNAME=node -RUN SNIPPET="export PROMPT_COMMAND='history -a' && export HISTFILE=/commandhistory/.bash_history" \ - && mkdir /commandhistory \ - && touch /commandhistory/.bash_history \ - && chown -R $USERNAME /commandhistory - -# Create workspace and config directories -RUN mkdir -p /workspace /home/node/.claude && \ - chown -R node:node /workspace /home/node/.claude - -# Switch to node user temporarily for npm install -USER node -ENV NPM_CONFIG_PREFIX=/usr/local/share/npm-global -ENV PATH=$PATH:/usr/local/share/npm-global/bin - -# Install Claude Code -RUN npm install -g @anthropic-ai/claude-code - -# Switch back to root -USER root - -# Copy the pre-authenticated Claude config -COPY claude-config /root/.claude - -# Copy the rest of the setup -WORKDIR /workspace - -# Install delta and zsh -RUN ARCH=$(dpkg --print-architecture) && \ - wget "https://github.com/dandavison/delta/releases/download/0.18.2/git-delta_0.18.2_${ARCH}.deb" && \ - sudo dpkg -i "git-delta_0.18.2_${ARCH}.deb" && \ - rm "git-delta_0.18.2_${ARCH}.deb" - -RUN sh -c "$(wget -O- https://github.com/deluan/zsh-in-docker/releases/download/v1.2.0/zsh-in-docker.sh)" -- \ - -p git \ - -p fzf \ - -a "source /usr/share/doc/fzf/examples/key-bindings.zsh" \ - -a "source /usr/share/doc/fzf/examples/completion.zsh" \ - -a "export PROMPT_COMMAND='history -a' && export HISTFILE=/commandhistory/.bash_history" \ - -x - -# Copy firewall and entrypoint scripts -COPY init-firewall.sh /usr/local/bin/ -RUN chmod +x /usr/local/bin/init-firewall.sh && \ - echo "node ALL=(root) NOPASSWD: /usr/local/bin/init-firewall.sh" > /etc/sudoers.d/node-firewall && \ - chmod 0440 /etc/sudoers.d/node-firewall - -COPY claudecode-entrypoint.sh /usr/local/bin/entrypoint.sh -RUN chmod +x /usr/local/bin/entrypoint.sh - -# Set the default shell to bash -ENV SHELL /bin/zsh -ENV DEVCONTAINER=true - -# Run as root to allow permission management -USER root - -# Use the custom entrypoint -ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] -EOF - -mv Dockerfile.claudecode.tmp Dockerfile.claudecode - -echo "Building new production image..." -docker build -f Dockerfile.claudecode -t claude-code-runner:latest . - -echo "Production image updated successfully!" \ No newline at end of file diff --git a/scripts/security/fix-credential-references.sh b/scripts/security/fix-credential-references.sh deleted file mode 100755 index 4595cf9..0000000 --- a/scripts/security/fix-credential-references.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash -# Script to fix potential credential references in the clean repository - -CLEAN_REPO="/tmp/clean-repo" -cd "$CLEAN_REPO" || exit 1 - -echo "Fixing potential credential references..." - -# 1. Fix test files with example tokens -echo "Updating test-credential-leak.js..." -sed -i 's/ghp_verySecretGitHubToken123456789/github_token_example_1234567890/g' test-credential-leak.js - -echo "Updating test-logger-redaction.js..." -sed -i 's/ghp_verySecretGitHubToken123456789/github_token_example_1234567890/g' test/test-logger-redaction.js -sed -i 's/ghp_nestedSecretToken/github_token_example_nested/g' test/test-logger-redaction.js -sed -i 's/ghp_inCommand/github_token_example_command/g' test/test-logger-redaction.js -sed -i 's/ghp_errorToken/github_token_example_error/g' test/test-logger-redaction.js -sed -i 's/AKIAIOSFODNN7NESTED/EXAMPLE_NESTED_KEY_ID/g' test/test-logger-redaction.js - -echo "Updating test-secrets.js..." -sed -i 's/ghp_1234567890abcdefghijklmnopqrstuvwxy/github_token_example_1234567890/g' test/test-secrets.js - -# 2. Fix references in documentation -echo "Updating docs/container-setup.md..." -sed -i 's/GITHUB_TOKEN=ghp_yourgithubtoken/GITHUB_TOKEN=your_github_token/g' docs/container-setup.md - -echo "Updating docs/complete-workflow.md..." -sed -i 's/`ghp_xxxxx`/`your_github_token`/g' docs/complete-workflow.md -sed -i 's/`AKIA...`/`your_access_key_id`/g' docs/complete-workflow.md - -# 3. Update AWS profile references in scripts -echo "Updating aws profile scripts..." -sed -i 's/aws_secret_access_key/aws_secret_key/g' scripts/create-aws-profile.sh -sed -i 's/aws_secret_access_key/aws_secret_key/g' scripts/setup-aws-profiles.sh - -# 4. Make awsCredentialProvider test use clearly labeled example values -echo "Updating unit test files..." -sed -i 's/aws_secret_access_key = default-secret-key/aws_secret_key = example-default-secret-key/g' test/unit/utils/awsCredentialProvider.test.js -sed -i 's/aws_secret_access_key = test-secret-key/aws_secret_key = example-test-secret-key/g' test/unit/utils/awsCredentialProvider.test.js - -echo "Updates completed. Running check again..." - -# Check if any sensitive patterns remain (excluding clearly labeled examples) -SENSITIVE_FILES=$(grep -r "ghp_\|AKIA\|aws_secret_access_key" --include="*.js" --include="*.sh" --include="*.json" --include="*.md" . | grep -v "EXAMPLE\|example\|REDACTED\|dummy\|\${\|ENV\|process.env\|context.env\|mock\|pattern" || echo "No sensitive data found") - -if [ -n "$SENSITIVE_FILES" ] && [ "$SENSITIVE_FILES" != "No sensitive data found" ]; then - echo "⚠️ Some potential sensitive patterns remain:" - echo "$SENSITIVE_FILES" - echo "Please review manually." -else - echo "✅ No sensitive patterns found. The repository is ready!" -fi \ No newline at end of file diff --git a/scripts/setup/create-new-repo.sh b/scripts/setup/create-new-repo.sh deleted file mode 100755 index cd90316..0000000 --- a/scripts/setup/create-new-repo.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/bash -# Script to prepare, clean, and set up a new repository - -CURRENT_REPO="/home/jonflatt/n8n/claude-repo" -CLEAN_REPO="/tmp/clean-repo" - -echo "=== STEP 1: Preparing clean repository ===" -# Run the prepare script -bash "$CURRENT_REPO/prepare-clean-repo.sh" - -echo "" -echo "=== STEP 2: Fixing credential references ===" -# Fix credential references -bash "$CURRENT_REPO/fix-credential-references.sh" - -echo "" -echo "=== STEP 3: Setting up git repository ===" -# Change to the clean repository -cd "$CLEAN_REPO" || exit 1 - -# Initialize git repository -git init - -# Add all files -git add . - -# Check if there are any files to commit -if ! git diff --cached --quiet; then - # Create initial commit - git commit -m "Initial commit - Clean repository" - - echo "" - echo "=== Repository ready! ===" - echo "The clean repository has been created at: $CLEAN_REPO" - echo "" - echo "Next steps:" - echo "1. Create a new GitHub repository at https://github.com/new" - echo "2. Connect this repository to GitHub:" - echo " cd $CLEAN_REPO" - echo " git remote add origin " - echo " git branch -M main" - echo " git push -u origin main" -else - echo "No files to commit. Something went wrong with the file preparation." - exit 1 -fi \ No newline at end of file diff --git a/scripts/setup/setup-claude-backup-cron.sh b/scripts/setup/setup-claude-backup-cron.sh deleted file mode 100755 index f6be0fc..0000000 --- a/scripts/setup/setup-claude-backup-cron.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash -# Setup cron job for Claude CLI database backups - -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -BACKUP_SCRIPT="${SCRIPT_DIR}/../utils/backup-claude-db.sh" - -# First ensure backup directories exist with proper permissions -echo "Ensuring backup directories exist..." -if [ ! -d "/backup/claude-cli" ]; then - echo "Creating backup directories (requires sudo)..." - sudo mkdir -p /backup/claude-cli/daily /backup/claude-cli/weekly - sudo chown -R $USER:$USER /backup/claude-cli -fi - -# Ensure backup script exists and is executable -if [ ! -f "${BACKUP_SCRIPT}" ]; then - echo "Error: Backup script not found at ${BACKUP_SCRIPT}" - exit 1 -fi - -# Make sure backup script is executable -chmod +x "${BACKUP_SCRIPT}" - -# Add cron job (daily at 2 AM) -CRON_JOB="0 2 * * * ${BACKUP_SCRIPT} >> /var/log/claude-backup.log 2>&1" - -# Check if cron job already exists -if crontab -l 2>/dev/null | grep -q "backup-claude-db.sh"; then - echo "Claude backup cron job already exists" -else - # Add the cron job - (crontab -l 2>/dev/null; echo "${CRON_JOB}") | crontab - - echo "Claude backup cron job added: ${CRON_JOB}" -fi - -# Create log file with proper permissions -sudo touch /var/log/claude-backup.log -sudo chown $USER:$USER /var/log/claude-backup.log - -echo "Setup complete. Backups will run daily at 2 AM." -echo "Logs will be written to /var/log/claude-backup.log" \ No newline at end of file diff --git a/scripts/setup/setup-github-runner.sh b/scripts/setup/setup-github-runner.sh deleted file mode 100755 index 133251f..0000000 --- a/scripts/setup/setup-github-runner.sh +++ /dev/null @@ -1,91 +0,0 @@ -#!/bin/bash - -# Setup GitHub Actions self-hosted runner for claude-github-webhook - -set -e - -# Configuration -RUNNER_DIR="/home/jonflatt/github-actions-runner" -RUNNER_VERSION="2.324.0" -REPO_URL="https://github.com/intelligence-assist/claude-github-webhook" -RUNNER_NAME="claude-webhook-runner" -RUNNER_LABELS="self-hosted,linux,x64,claude-webhook" - -echo "🚀 Setting up GitHub Actions self-hosted runner..." - -# Create runner directory -mkdir -p "$RUNNER_DIR" -cd "$RUNNER_DIR" - -# Download runner if not exists -if [ ! -f "actions-runner-linux-x64-${RUNNER_VERSION}.tar.gz" ]; then - echo "📦 Downloading runner v${RUNNER_VERSION}..." - curl -o "actions-runner-linux-x64-${RUNNER_VERSION}.tar.gz" -L \ - "https://github.com/actions/runner/releases/download/v${RUNNER_VERSION}/actions-runner-linux-x64-${RUNNER_VERSION}.tar.gz" -fi - -# Extract runner -echo "📂 Extracting runner..." -tar xzf "./actions-runner-linux-x64-${RUNNER_VERSION}.tar.gz" - -# Install dependencies if needed -echo "🔧 Installing dependencies..." -sudo ./bin/installdependencies.sh || true - -echo "" -echo "⚠️ IMPORTANT: You need to get a runner registration token from GitHub!" -echo "" -echo "1. Go to: https://github.com/intelligence-assist/claude-github-webhook/settings/actions/runners/new" -echo "2. Copy the registration token" -echo "3. Run the configuration command below with your token:" -echo "" -echo "cd $RUNNER_DIR" -echo "./config.sh --url $REPO_URL --token YOUR_TOKEN_HERE --name $RUNNER_NAME --labels $RUNNER_LABELS --unattended --replace" -echo "" -echo "4. After configuration, install as a service:" -echo "sudo ./svc.sh install" -echo "sudo ./svc.sh start" -echo "" -echo "5. Check status:" -echo "sudo ./svc.sh status" -echo "" - -# Create systemd service file for the runner -cat > "$RUNNER_DIR/actions.runner.service" << 'EOF' -[Unit] -Description=GitHub Actions Runner (claude-webhook-runner) -After=network-online.target - -[Service] -Type=simple -User=jonflatt -WorkingDirectory=/home/jonflatt/github-actions-runner -ExecStart=/home/jonflatt/github-actions-runner/run.sh -Restart=on-failure -RestartSec=5 -KillMode=process -KillSignal=SIGTERM -StandardOutput=journal -StandardError=journal -SyslogIdentifier=github-runner - -# Security settings -NoNewPrivileges=true -PrivateTmp=true -ProtectSystem=strict -ProtectHome=read-only -ReadWritePaths=/home/jonflatt/github-actions-runner -ReadWritePaths=/home/jonflatt/n8n/claude-repo -ReadWritePaths=/var/run/docker.sock - -[Install] -WantedBy=multi-user.target -EOF - -echo "📄 Systemd service file created at: $RUNNER_DIR/actions.runner.service" -echo "" -echo "Alternative: Use systemd directly instead of ./svc.sh:" -echo "sudo cp $RUNNER_DIR/actions.runner.service /etc/systemd/system/github-runner-claude.service" -echo "sudo systemctl daemon-reload" -echo "sudo systemctl enable github-runner-claude" -echo "sudo systemctl start github-runner-claude" \ No newline at end of file diff --git a/scripts/setup/setup-new-repo.sh b/scripts/setup/setup-new-repo.sh deleted file mode 100755 index 7c4c2c6..0000000 --- a/scripts/setup/setup-new-repo.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/bash -# Script to set up the new clean repository - -CLEAN_REPO="/tmp/clean-repo" - -# Change to the clean repository -cd "$CLEAN_REPO" || exit 1 -echo "Changed to directory: $(pwd)" - -# Initialize git repository -echo "Initializing git repository..." -git init - -# Configure git if needed (optional) -# git config user.name "Your Name" -# git config user.email "your.email@example.com" - -# Add all files -echo "Adding files to git..." -git add . - -# First checking for any remaining sensitive data -echo "Checking for potential sensitive data..." -SENSITIVE_FILES=$(grep -r "ghp_\|AKIA\|aws_secret\|github_token" --include="*.js" --include="*.sh" --include="*.json" --include="*.md" . | grep -v "EXAMPLE\|REDACTED\|dummy\|\${\|ENV\|process.env\|context.env\|mock" || echo "No sensitive data found") - -if [ -n "$SENSITIVE_FILES" ]; then - echo "⚠️ Potential sensitive data found:" - echo "$SENSITIVE_FILES" - echo "" - echo "Please review the above files and remove any real credentials before continuing." - echo "After fixing, run this script again." - exit 1 -fi - -# Commit the code -echo "Creating initial commit..." -git commit -m "Initial commit - Clean repository" || exit 1 - -echo "" -echo "✅ Repository setup complete!" -echo "" -echo "Next steps:" -echo "1. Create a new GitHub repository at https://github.com/new" -echo "2. Connect and push this repository with:" -echo " git remote add origin " -echo " git branch -M main" -echo " git push -u origin main" -echo "" -echo "Important: The repository is ready at $CLEAN_REPO" \ No newline at end of file diff --git a/scripts/utils/backup-claude-db.sh b/scripts/utils/backup-claude-db.sh deleted file mode 100755 index ba9a0e6..0000000 --- a/scripts/utils/backup-claude-db.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/bash -# Backup Claude CLI database to prevent corruption - -# Use SUDO_USER if running with sudo, otherwise use current user -ACTUAL_USER="${SUDO_USER:-$USER}" -ACTUAL_HOME=$(eval echo ~$ACTUAL_USER) - -CLAUDE_DIR="${ACTUAL_HOME}/.claude" -DB_FILE="${CLAUDE_DIR}/__store.db" -BACKUP_ROOT="/backup/claude-cli" -BACKUP_DIR="${BACKUP_ROOT}/daily" -WEEKLY_DIR="${BACKUP_ROOT}/weekly" - -# Create backup directories if they don't exist (may need sudo) -if [ ! -d "${BACKUP_ROOT}" ]; then - if [ -w "/backup" ]; then - mkdir -p "${BACKUP_DIR}" "${WEEKLY_DIR}" - else - echo "Error: Cannot create backup directories in /backup" - echo "Please run: sudo mkdir -p ${BACKUP_DIR} ${WEEKLY_DIR}" - echo "Then run: sudo chown -R $USER:$USER ${BACKUP_ROOT}" - exit 1 - fi -else - mkdir -p "${BACKUP_DIR}" "${WEEKLY_DIR}" -fi - -# Generate timestamp for backup -TIMESTAMP=$(date +%Y%m%d_%H%M%S) -DAY_OF_WEEK=$(date +%u) # 1=Monday, 6=Saturday -DATE_ONLY=$(date +%Y%m%d) - -# Create backup if database exists -if [ -f "${DB_FILE}" ]; then - echo "Backing up Claude database..." - - # Daily backup - DAILY_BACKUP="${BACKUP_DIR}/store_${TIMESTAMP}.db" - cp "${DB_FILE}" "${DAILY_BACKUP}" - echo "Daily backup created: ${DAILY_BACKUP}" - - # Weekly backup on Saturdays - if [ "${DAY_OF_WEEK}" -eq "6" ]; then - WEEKLY_BACKUP="${WEEKLY_DIR}/store_saturday_${DATE_ONLY}.db" - cp "${DB_FILE}" "${WEEKLY_BACKUP}" - echo "Weekly Saturday backup created: ${WEEKLY_BACKUP}" - fi - - # Clean up old daily backups (keep last 7 days) - find "${BACKUP_DIR}" -name "store_*.db" -type f -mtime +7 -delete - - # Clean up old weekly backups (keep last 52 weeks) - find "${WEEKLY_DIR}" -name "store_saturday_*.db" -type f -mtime +364 -delete - -else - echo "No Claude database found at ${DB_FILE}" -fi \ No newline at end of file