192 lines
5.9 KiB
Bash
Executable file
192 lines
5.9 KiB
Bash
Executable file
#!/bin/bash
|
|
##############################################################################
|
|
# install_via_openclaw.sh
|
|
#
|
|
# Automated Orto Skills installation script for OpenClaw
|
|
# Designed to be executed by AgentePotente (OpenClaw agent) via chat
|
|
#
|
|
# Usage:
|
|
# ./install_via_openclaw.sh /path/to/orto-skills-v1.0-dist.tar.gz
|
|
#
|
|
# Output:
|
|
# - Extracts 9 .skill files to ~/.openclaw/skills/orto-suite/
|
|
# - Verifies installation
|
|
# - Logs to /tmp/install_orto_*.log
|
|
# - Returns exit code 0 if success, 1 if failed
|
|
##############################################################################
|
|
|
|
set -e # Exit on first error
|
|
|
|
# Configuration
|
|
INSTALL_DIR="$HOME/.openclaw/skills/orto-suite"
|
|
LOG_FILE="/tmp/install_orto_$(date +%s).log"
|
|
EXPECTED_SKILLS=9
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
BLUE='\033[0;34m'
|
|
NC='\033[0m' # No Color
|
|
|
|
# Logging function
|
|
log() {
|
|
echo -e "${BLUE}[$(date +'%Y-%m-%d %H:%M:%S')]${NC} $1" | tee -a "$LOG_FILE"
|
|
}
|
|
|
|
error() {
|
|
echo -e "${RED}[ERROR]${NC} $1" | tee -a "$LOG_FILE" >&2
|
|
}
|
|
|
|
success() {
|
|
echo -e "${GREEN}[✓]${NC} $1" | tee -a "$LOG_FILE"
|
|
}
|
|
|
|
warning() {
|
|
echo -e "${YELLOW}[⚠]${NC} $1" | tee -a "$LOG_FILE"
|
|
}
|
|
|
|
##############################################################################
|
|
# PHASE 1: VALIDATION
|
|
##############################################################################
|
|
|
|
log "=== ORTO SKILLS INSTALLATION (OpenClaw Edition) ==="
|
|
log "Installation directory: $INSTALL_DIR"
|
|
log "Log file: $LOG_FILE"
|
|
|
|
# Check arguments
|
|
if [ $# -ne 1 ]; then
|
|
error "Usage: $0 <path_to_orto-skills-v1.0-dist.tar.gz>"
|
|
exit 1
|
|
fi
|
|
|
|
TAR_PATH="$1"
|
|
|
|
# Verify tar.gz exists
|
|
if [ ! -f "$TAR_PATH" ]; then
|
|
error "File not found: $TAR_PATH"
|
|
exit 1
|
|
fi
|
|
|
|
log "Package path: $TAR_PATH"
|
|
|
|
# Verify it's a tar.gz
|
|
if ! file "$TAR_PATH" | grep -q "gzip compressed data"; then
|
|
error "File is not a valid tar.gz: $TAR_PATH"
|
|
exit 1
|
|
fi
|
|
|
|
success "Package verified as valid tar.gz"
|
|
|
|
##############################################################################
|
|
# PHASE 2: EXTRACTION
|
|
##############################################################################
|
|
|
|
log "Phase 2: Extracting package..."
|
|
|
|
# Create install directory
|
|
if [ ! -d "$INSTALL_DIR" ]; then
|
|
mkdir -p "$INSTALL_DIR" 2>&1 | tee -a "$LOG_FILE"
|
|
success "Created directory: $INSTALL_DIR"
|
|
else
|
|
log "Directory exists: $INSTALL_DIR"
|
|
# Backup existing (optional)
|
|
if [ "$(ls -A $INSTALL_DIR)" ]; then
|
|
BACKUP_DIR="$INSTALL_DIR.backup.$(date +%s)"
|
|
log "Backing up existing installation to: $BACKUP_DIR"
|
|
mv "$INSTALL_DIR" "$BACKUP_DIR" 2>&1 | tee -a "$LOG_FILE"
|
|
mkdir -p "$INSTALL_DIR"
|
|
fi
|
|
fi
|
|
|
|
# Extract tar.gz
|
|
log "Extracting files..."
|
|
if tar -xzf "$TAR_PATH" -C "$INSTALL_DIR" --strip-components=2 2>&1 | tee -a "$LOG_FILE"; then
|
|
success "Files extracted successfully"
|
|
else
|
|
error "Extraction failed"
|
|
exit 1
|
|
fi
|
|
|
|
##############################################################################
|
|
# PHASE 3: VERIFICATION
|
|
##############################################################################
|
|
|
|
log "Phase 3: Verifying installation..."
|
|
|
|
# Count SKILL.md files
|
|
SKILL_COUNT=$(find "$INSTALL_DIR" -name "SKILL.md" -type f | wc -l)
|
|
log "Found $SKILL_COUNT SKILL.md files"
|
|
|
|
if [ "$SKILL_COUNT" -ne "$EXPECTED_SKILLS" ]; then
|
|
warning "Expected $EXPECTED_SKILLS skills, found $SKILL_COUNT"
|
|
# Don't exit; continue verification
|
|
fi
|
|
|
|
# Check each skill directory
|
|
log "Verifying skill directories..."
|
|
SKILLS_VERIFIED=0
|
|
for skill_dir in "$INSTALL_DIR"/orto-*/; do
|
|
if [ -d "$skill_dir" ]; then
|
|
SKILL_NAME=$(basename "$skill_dir")
|
|
|
|
if [ ! -f "$skill_dir/SKILL.md" ]; then
|
|
error "Missing SKILL.md in $SKILL_NAME"
|
|
exit 1
|
|
fi
|
|
|
|
if [ ! -r "$skill_dir/SKILL.md" ]; then
|
|
error "SKILL.md not readable in $SKILL_NAME"
|
|
exit 1
|
|
fi
|
|
|
|
SKILLS_VERIFIED=$((SKILLS_VERIFIED + 1))
|
|
fi
|
|
done
|
|
|
|
success "Verified $SKILLS_VERIFIED skill directories"
|
|
|
|
if [ "$SKILLS_VERIFIED" -lt 5 ]; then
|
|
error "Too few skills verified ($SKILLS_VERIFIED < 5)"
|
|
exit 1
|
|
fi
|
|
|
|
##############################################################################
|
|
# PHASE 4: METADATA CHECK
|
|
##############################################################################
|
|
|
|
log "Phase 4: Checking metadata..."
|
|
|
|
# List installed skills
|
|
echo "" | tee -a "$LOG_FILE"
|
|
echo "=== INSTALLED SKILLS ===" | tee -a "$LOG_FILE"
|
|
find "$INSTALL_DIR" -maxdepth 2 -name "SKILL.md" -type f | sort | while read skillmd; do
|
|
skilldir=$(dirname "$skillmd")
|
|
skillname=$(basename "$skilldir")
|
|
echo " ✓ $skillname" | tee -a "$LOG_FILE"
|
|
done
|
|
|
|
##############################################################################
|
|
# PHASE 5: SUCCESS SUMMARY
|
|
##############################################################################
|
|
|
|
log "Phase 5: Installation summary"
|
|
|
|
echo "" | tee -a "$LOG_FILE"
|
|
echo "╔════════════════════════════════════════════════════════════╗" | tee -a "$LOG_FILE"
|
|
echo "║ ✅ INSTALLATION COMPLETED SUCCESSFULLY ║" | tee -a "$LOG_FILE"
|
|
echo "╚════════════════════════════════════════════════════════════╝" | tee -a "$LOG_FILE"
|
|
|
|
success "Skills installed: $SKILLS_VERIFIED"
|
|
success "Installation directory: $INSTALL_DIR"
|
|
success "Log file: $LOG_FILE"
|
|
|
|
echo "" | tee -a "$LOG_FILE"
|
|
echo "=== NEXT STEPS ===" | tee -a "$LOG_FILE"
|
|
echo "1. Create your first garden (orto-init)" | tee -a "$LOG_FILE"
|
|
echo "2. Answer onboarding questions (orto-onboarding)" | tee -a "$LOG_FILE"
|
|
echo "3. Generate complete plan (orto-orchestratore)" | tee -a "$LOG_FILE"
|
|
echo "4. Receive weekly briefing (orto-meteo-decisioni)" | tee -a "$LOG_FILE"
|
|
|
|
echo "" | tee -a "$LOG_FILE"
|
|
echo "For help, ask: 'Come uso le skill orto?'" | tee -a "$LOG_FILE"
|
|
|
|
exit 0
|