Initial commit: Socktop WebTerm with k3s deployment
- Multi-architecture Docker image (ARM64 + AMD64) - Kubernetes manifests for 3-replica deployment - Traefik ingress configuration - NGINX Proxy Manager integration - ConfigMap-based configuration - Automated build and deployment scripts - Session monitoring tools
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Entrypoint script for socktop webterm container
|
||||
# This script handles initialization and starts services
|
||||
|
||||
echo "==================================="
|
||||
echo "Starting socktop webterm container"
|
||||
echo "==================================="
|
||||
|
||||
# Function to verify config files are mounted correctly
|
||||
copy_config_files() {
|
||||
echo "Checking for configuration files..."
|
||||
|
||||
# Verify Alacritty configuration
|
||||
if [ -f "/home/socktop/.config/alacritty/alacritty.toml" ]; then
|
||||
echo " ✓ alacritty.toml is mounted"
|
||||
else
|
||||
echo " WARNING: alacritty.toml not found"
|
||||
fi
|
||||
|
||||
# Verify Catppuccin Frappe theme
|
||||
if [ -f "/home/socktop/.config/alacritty/catppuccin-frappe.toml" ]; then
|
||||
echo " ✓ catppuccin-frappe.toml is mounted"
|
||||
else
|
||||
echo " WARNING: catppuccin-frappe.toml not found"
|
||||
fi
|
||||
|
||||
# Verify socktop profiles.json
|
||||
if [ -f "/home/socktop/.config/socktop/profiles.json" ]; then
|
||||
echo " ✓ profiles.json is mounted"
|
||||
else
|
||||
echo " WARNING: profiles.json not found"
|
||||
fi
|
||||
|
||||
# Check for TLS certificates
|
||||
echo "Checking for TLS certificates..."
|
||||
for key in rpi-master.pem rpi-worker-1.pem rpi-worker-2.pem rpi-worker-3.pem; do
|
||||
if [ -f "/home/socktop/.config/socktop/certs/$key" ]; then
|
||||
echo " ✓ $key found"
|
||||
else
|
||||
echo " - $key not found (optional)"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# Set up Alacritty as default terminal
|
||||
setup_alacritty() {
|
||||
echo "Setting up Alacritty as default terminal..."
|
||||
|
||||
# Set TERM environment variable (already set in deployment env)
|
||||
export TERM=alacritty
|
||||
|
||||
echo "Alacritty setup complete"
|
||||
}
|
||||
|
||||
# Start socktop agent
|
||||
start_socktop_agent() {
|
||||
echo "Starting socktop-agent on port 3000..."
|
||||
|
||||
# Don't start the agent here - supervisor will handle it
|
||||
echo "socktop-agent will be started by supervisor"
|
||||
}
|
||||
|
||||
# Main initialization
|
||||
main() {
|
||||
echo "Running initialization..."
|
||||
|
||||
# Copy configuration files
|
||||
copy_config_files
|
||||
|
||||
# Set up Alacritty
|
||||
setup_alacritty
|
||||
|
||||
# Start socktop agent
|
||||
start_socktop_agent
|
||||
|
||||
echo ""
|
||||
echo "==================================="
|
||||
echo "Initialization complete!"
|
||||
echo "==================================="
|
||||
echo ""
|
||||
echo "Services:"
|
||||
echo " - Webterm: http://localhost:8082"
|
||||
echo " - Socktop Agent: localhost:3001"
|
||||
echo ""
|
||||
|
||||
# Execute the main command
|
||||
exec "$@"
|
||||
}
|
||||
|
||||
# Run main function
|
||||
main "$@"
|
||||
@@ -0,0 +1,178 @@
|
||||
#!/bin/bash
|
||||
# Restricted shell for socktop webterm
|
||||
# Only allows 'socktop' and 'help' commands
|
||||
|
||||
# Colors for output
|
||||
BLUE='\033[0;34m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
RED='\033[0;31m'
|
||||
MAGENTA='\033[0;35m'
|
||||
CYAN='\033[0;36m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# History file
|
||||
HISTFILE="/home/socktop/.socktop_history"
|
||||
HISTSIZE=1000
|
||||
|
||||
# Load history from file
|
||||
load_history() {
|
||||
if [ -f "$HISTFILE" ]; then
|
||||
history -r "$HISTFILE"
|
||||
fi
|
||||
}
|
||||
|
||||
# Save history to file
|
||||
save_history() {
|
||||
history -w "$HISTFILE"
|
||||
}
|
||||
|
||||
# Welcome message
|
||||
show_welcome() {
|
||||
echo -e "${MAGENTA}"
|
||||
cat << "EOF"
|
||||
╔═══════════════════════════════════════════════════════════╗
|
||||
║ Welcome to socktop ║
|
||||
║ A TUI-first Remote System Monitor ║
|
||||
╚═══════════════════════════════════════════════════════════╝
|
||||
EOF
|
||||
echo -e "${NC}"
|
||||
echo -e "${CYAN}Available commands:${NC}"
|
||||
echo -e " ${GREEN}socktop${NC} - Launch the socktop TUI"
|
||||
echo -e " ${GREEN}help${NC} - Show this help message"
|
||||
echo ""
|
||||
echo -e "${YELLOW}Type 'help' for more information${NC}"
|
||||
echo ""
|
||||
}
|
||||
|
||||
# Help message
|
||||
show_help() {
|
||||
echo -e "${BLUE}╔═══════════════════════════════════════════════════════════╗${NC}"
|
||||
echo -e "${BLUE}║${NC} socktop Help ${BLUE}║${NC}"
|
||||
echo -e "${BLUE}╚═══════════════════════════════════════════════════════════╝${NC}"
|
||||
echo ""
|
||||
echo -e "${CYAN}What is socktop?${NC}"
|
||||
echo " socktop is a beautiful, TUI-first system monitor built with Rust."
|
||||
echo " It allows you to monitor local and remote Linux systems in real-time"
|
||||
echo " with an elegant terminal interface."
|
||||
echo ""
|
||||
echo -e "${CYAN}Available Commands:${NC}"
|
||||
echo ""
|
||||
echo -e " ${GREEN}socktop${NC}"
|
||||
echo " Launch socktop with the local profile (monitors this container)"
|
||||
echo ""
|
||||
echo -e " ${GREEN}socktop -P <profile>${NC}"
|
||||
echo " Launch socktop with a specific profile from profiles.json"
|
||||
echo " Example: socktop -P rpi-master"
|
||||
echo ""
|
||||
echo -e " ${GREEN}socktop <websocket_url>${NC}"
|
||||
echo " Connect to a remote socktop-agent directly"
|
||||
echo " Example: socktop ws://192.168.1.100:3000"
|
||||
echo ""
|
||||
echo -e " ${GREEN}help${NC}"
|
||||
echo " Show this help message"
|
||||
echo ""
|
||||
echo -e "${CYAN}Available Profiles:${NC}"
|
||||
echo " • local - Monitor this container (localhost:3000)"
|
||||
echo " • rpi-master - Raspberry Pi Master node"
|
||||
echo " • rpi-worker-1 - Raspberry Pi Worker 1"
|
||||
echo " • rpi-worker-2 - Raspberry Pi Worker 2"
|
||||
echo " • rpi-worker-3 - Raspberry Pi Worker 3"
|
||||
echo ""
|
||||
echo -e "${CYAN}Keyboard Shortcuts (inside socktop):${NC}"
|
||||
echo " q - Quit socktop"
|
||||
echo " Tab - Switch between views"
|
||||
echo " ↑/↓ - Navigate lists"
|
||||
echo " PageUp/Down - Scroll faster"
|
||||
echo ""
|
||||
echo -e "${CYAN}Features:${NC}"
|
||||
echo " ✓ Real-time CPU, memory, disk, and network monitoring"
|
||||
echo " ✓ Process list with sorting and filtering"
|
||||
echo " ✓ Remote monitoring via SSH"
|
||||
echo " ✓ Beautiful Catppuccin Frappe theme"
|
||||
echo " ✓ Lightweight and fast"
|
||||
echo ""
|
||||
echo -e "${CYAN}Links:${NC}"
|
||||
echo " GitHub: https://github.com/jasonwitty/socktop"
|
||||
echo " Documentation: https://jasonwitty.github.io/socktop/"
|
||||
echo " Crates.io: https://crates.io/crates/socktop"
|
||||
echo ""
|
||||
echo -e "${YELLOW}Ready to monitor? Type: ${GREEN}socktop${NC}"
|
||||
echo ""
|
||||
}
|
||||
|
||||
# Main restricted shell loop
|
||||
main() {
|
||||
# Load command history
|
||||
load_history
|
||||
|
||||
# Show welcome on first run
|
||||
if [ ! -f /tmp/.socktop_welcome_shown ]; then
|
||||
show_welcome
|
||||
touch /tmp/.socktop_welcome_shown
|
||||
fi
|
||||
|
||||
while true; do
|
||||
# Display prompt
|
||||
echo -ne "${GREEN}socktop${NC}@${BLUE}demo${NC} ${YELLOW}▶${NC} "
|
||||
|
||||
# Read user input with readline support (enables arrow keys, history, etc.)
|
||||
read -e -r input
|
||||
|
||||
# Add non-empty commands to history
|
||||
if [ -n "$input" ]; then
|
||||
history -s "$input"
|
||||
save_history
|
||||
fi
|
||||
|
||||
# Trim whitespace
|
||||
input=$(echo "$input" | xargs)
|
||||
|
||||
# Skip empty input
|
||||
if [ -z "$input" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
# Parse command (first word)
|
||||
cmd=$(echo "$input" | awk '{print $1}')
|
||||
args=$(echo "$input" | cut -d' ' -f2-)
|
||||
|
||||
case "$cmd" in
|
||||
socktop)
|
||||
# Allow socktop with any arguments
|
||||
if [ "$cmd" = "$input" ]; then
|
||||
# No arguments, use default (local profile)
|
||||
/usr/bin/socktop -P local
|
||||
else
|
||||
# Pass arguments to socktop
|
||||
/usr/bin/socktop $args
|
||||
fi
|
||||
;;
|
||||
help|--help|-h)
|
||||
show_help
|
||||
;;
|
||||
exit|quit|logout)
|
||||
echo -e "${YELLOW}Use Ctrl+D to exit the shell${NC}"
|
||||
;;
|
||||
clear|cls)
|
||||
clear
|
||||
echo -e "${YELLOW}Screen cleared. Type 'help' for available commands.${NC}"
|
||||
;;
|
||||
"")
|
||||
# Empty command, do nothing
|
||||
;;
|
||||
*)
|
||||
# Unknown command
|
||||
echo -e "${RED}Error:${NC} Command '$cmd' is not allowed"
|
||||
echo -e "${YELLOW}Available commands:${NC} ${GREEN}socktop${NC}, ${GREEN}help${NC}"
|
||||
echo -e "Type ${GREEN}help${NC} for more information"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
# Handle Ctrl+C gracefully
|
||||
trap 'echo -e "\n${YELLOW}Use Ctrl+D to exit${NC}"; continue' INT
|
||||
|
||||
# Run main loop
|
||||
main
|
||||
@@ -0,0 +1,39 @@
|
||||
[supervisord]
|
||||
nodaemon=true
|
||||
user=root
|
||||
logfile=/var/log/supervisor/supervisord.log
|
||||
pidfile=/var/run/supervisord.pid
|
||||
childlogdir=/var/log/supervisor
|
||||
|
||||
[program:socktop-agent]
|
||||
command=/usr/bin/socktop_agent --port 3001
|
||||
directory=/home/socktop
|
||||
user=root
|
||||
autostart=true
|
||||
autorestart=true
|
||||
startretries=3
|
||||
stderr_logfile=/var/log/supervisor/socktop-agent.err.log
|
||||
stdout_logfile=/var/log/supervisor/socktop-agent.out.log
|
||||
priority=100
|
||||
|
||||
[program:webterm]
|
||||
command=/app/target/release/webterm-server --host 0.0.0.0 --port 8082 --command /usr/local/bin/restricted-shell
|
||||
directory=/app
|
||||
user=root
|
||||
autostart=true
|
||||
autorestart=true
|
||||
startretries=3
|
||||
stderr_logfile=/var/log/supervisor/webterm.err.log
|
||||
stdout_logfile=/var/log/supervisor/webterm.out.log
|
||||
priority=200
|
||||
environment=HOME="/home/socktop",USER="root",TERM="xterm-256color"
|
||||
|
||||
[unix_http_server]
|
||||
file=/var/run/supervisor.sock
|
||||
chmod=0700
|
||||
|
||||
[supervisorctl]
|
||||
serverurl=unix:///var/run/supervisor.sock
|
||||
|
||||
[rpcinterface:supervisor]
|
||||
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
|
||||
Reference in New Issue
Block a user