JupyterManager/install.sh
saymrwulf d191344eb5 Initial commit: jupyter-hub cross-project Jupyter manager
CLI tool that discovers and manages JupyterLab instances across
multiple projects. Prevents port conflicts, finds orphan processes,
provides unified status and stop-all functionality.

Includes:
- bin/jupyter-hub: the CLI (status, ports, stop-all, orphans, which, config)
- config/defaults.sh: default scan dirs and port range
- docs/LIFECYCLE_SPEC.md: client project requirements
- docs/AGENT_PROMPT.md: prompt for coding agents to align projects
- install.sh: symlink installer to ~/bin
- tests/test_jupyter_hub.sh: 15 functional tests

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-16 09:07:43 +02:00

82 lines
2.9 KiB
Bash
Executable file

#!/usr/bin/env bash
# ──────────────────────────────────────────────────────────────────────
# install.sh — Install jupyter-hub to ~/bin via symlink
#
# Usage:
# bash install.sh Install (symlink to ~/bin/jupyter-hub)
# bash install.sh --remove Remove the symlink
# ──────────────────────────────────────────────────────────────────────
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
TARGET="$HOME/bin/jupyter-hub"
SOURCE="$SCRIPT_DIR/bin/jupyter-hub"
CONFIG_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/jupyter-hub"
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BOLD='\033[1m'
NC='\033[0m'
if [[ "${1:-}" == "--remove" ]]; then
if [[ -L "$TARGET" ]]; then
rm "$TARGET"
echo -e "${GREEN}Removed${NC} $TARGET"
elif [[ -f "$TARGET" ]]; then
echo -e "${YELLOW}Warning:${NC} $TARGET is not a symlink (may be a standalone copy)"
echo " Remove manually: rm $TARGET"
else
echo "Nothing to remove — $TARGET does not exist."
fi
exit 0
fi
# Create ~/bin if needed
mkdir -p "$(dirname "$TARGET")"
# Remove old standalone copy if present (from before this project existed)
if [[ -f "$TARGET" && ! -L "$TARGET" ]]; then
echo -e "${YELLOW}Replacing standalone ~/bin/jupyter-hub with symlink${NC}"
rm "$TARGET"
fi
# Create symlink
ln -sf "$SOURCE" "$TARGET"
echo -e "${GREEN}Installed${NC} $TARGET$SOURCE"
# Create default config if not present
if [[ ! -f "$CONFIG_DIR/config.sh" ]]; then
mkdir -p "$CONFIG_DIR"
cat > "$CONFIG_DIR/config.sh" << 'CONF'
# ──────────────────────────────────────────────────────────────────────
# jupyter-hub user configuration
#
# Override defaults here. Sourced by jupyter-hub on startup.
# ──────────────────────────────────────────────────────────────────────
# Port range to scan
# PORT_RANGE_START=8888
# PORT_RANGE_END=8899
# Directories to scan for Jupyter projects
# Uncomment and edit:
# SCAN_DIRS=(
# "$HOME/GitClone/ClaudeCodeProjects"
# "$HOME/GitClone/CodexProjects"
# "$HOME/Projects"
# )
CONF
echo -e "${GREEN}Created${NC} $CONFIG_DIR/config.sh"
fi
# Check PATH
if ! echo "$PATH" | tr ':' '\n' | grep -q "$HOME/bin"; then
echo ""
echo -e "${YELLOW}Note:${NC} ~/bin is not in your PATH."
echo " Add to your shell profile (~/.zshrc or ~/.bashrc):"
echo ' export PATH="$HOME/bin:$PATH"'
fi
echo ""
echo -e "${BOLD}Done.${NC} Run: jupyter-hub status"