Initial commit: Onebox v1.0.0
- Complete Deno-based architecture following nupst/spark patterns - SQLite database with full schema - Docker container management - Service orchestration (Docker + Nginx + DNS + SSL) - Registry authentication - Nginx reverse proxy configuration - Cloudflare DNS integration - Let's Encrypt SSL automation - Background daemon with metrics collection - HTTP API server - Comprehensive CLI - Cross-platform compilation setup - NPM distribution wrapper - Shell installer script Core features: - Deploy containers with single command - Automatic domain configuration - Automatic SSL certificates - Multi-registry support - Metrics and logging - Systemd integration Ready for Angular UI implementation and testing.
This commit is contained in:
192
install.sh
Executable file
192
install.sh
Executable file
@@ -0,0 +1,192 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Onebox installer script
|
||||
#
|
||||
|
||||
set -e
|
||||
|
||||
# Configuration
|
||||
REPO_URL="https://code.foss.global/serve.zone/onebox"
|
||||
INSTALL_DIR="/opt/onebox"
|
||||
BIN_LINK="/usr/local/bin/onebox"
|
||||
|
||||
# Colors
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Functions
|
||||
error() {
|
||||
echo -e "${RED}Error: $1${NC}" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
info() {
|
||||
echo -e "${GREEN}$1${NC}"
|
||||
}
|
||||
|
||||
warn() {
|
||||
echo -e "${YELLOW}$1${NC}"
|
||||
}
|
||||
|
||||
# Detect platform and architecture
|
||||
detect_platform() {
|
||||
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
|
||||
ARCH=$(uname -m)
|
||||
|
||||
case "$OS" in
|
||||
linux)
|
||||
PLATFORM="linux"
|
||||
;;
|
||||
darwin)
|
||||
PLATFORM="macos"
|
||||
;;
|
||||
*)
|
||||
error "Unsupported operating system: $OS"
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$ARCH" in
|
||||
x86_64|amd64)
|
||||
ARCH="x64"
|
||||
;;
|
||||
aarch64|arm64)
|
||||
ARCH="arm64"
|
||||
;;
|
||||
*)
|
||||
error "Unsupported architecture: $ARCH"
|
||||
;;
|
||||
esac
|
||||
|
||||
BINARY_NAME="onebox-${PLATFORM}-${ARCH}"
|
||||
}
|
||||
|
||||
# Get latest version from Gitea API
|
||||
get_latest_version() {
|
||||
info "Fetching latest version..."
|
||||
VERSION=$(curl -s "${REPO_URL}/releases" | grep -o '"tag_name":"v[^"]*' | head -1 | cut -d'"' -f4 | cut -c2-)
|
||||
|
||||
if [ -z "$VERSION" ]; then
|
||||
warn "Could not fetch latest version, using 'main' branch"
|
||||
VERSION="main"
|
||||
else
|
||||
info "Latest version: v${VERSION}"
|
||||
fi
|
||||
}
|
||||
|
||||
# Check if running as root
|
||||
check_root() {
|
||||
if [ "$EUID" -ne 0 ]; then
|
||||
error "This script must be run as root (use sudo)"
|
||||
fi
|
||||
}
|
||||
|
||||
# Download binary
|
||||
download_binary() {
|
||||
info "Downloading Onebox ${VERSION} for ${PLATFORM}-${ARCH}..."
|
||||
|
||||
# Create temp directory
|
||||
TMP_DIR=$(mktemp -d)
|
||||
TMP_FILE="${TMP_DIR}/${BINARY_NAME}"
|
||||
|
||||
# Try release download first
|
||||
if [ "$VERSION" != "main" ]; then
|
||||
DOWNLOAD_URL="${REPO_URL}/releases/download/v${VERSION}/${BINARY_NAME}"
|
||||
else
|
||||
DOWNLOAD_URL="${REPO_URL}/raw/branch/main/dist/binaries/${BINARY_NAME}"
|
||||
fi
|
||||
|
||||
if ! curl -L -f -o "$TMP_FILE" "$DOWNLOAD_URL"; then
|
||||
error "Failed to download binary from $DOWNLOAD_URL"
|
||||
fi
|
||||
|
||||
# Verify download
|
||||
if [ ! -f "$TMP_FILE" ] || [ ! -s "$TMP_FILE" ]; then
|
||||
error "Downloaded file is empty or missing"
|
||||
fi
|
||||
|
||||
info "✓ Download complete"
|
||||
}
|
||||
|
||||
# Install binary
|
||||
install_binary() {
|
||||
info "Installing Onebox to ${INSTALL_DIR}..."
|
||||
|
||||
# Create install directory
|
||||
mkdir -p "$INSTALL_DIR"
|
||||
|
||||
# Copy binary
|
||||
cp "$TMP_FILE" "${INSTALL_DIR}/onebox"
|
||||
chmod +x "${INSTALL_DIR}/onebox"
|
||||
|
||||
# Create symlink
|
||||
ln -sf "${INSTALL_DIR}/onebox" "$BIN_LINK"
|
||||
|
||||
# Cleanup temp files
|
||||
rm -rf "$TMP_DIR"
|
||||
|
||||
info "✓ Installation complete"
|
||||
}
|
||||
|
||||
# Initialize database and config
|
||||
initialize() {
|
||||
info "Initializing Onebox..."
|
||||
|
||||
# Create data directory
|
||||
mkdir -p /var/lib/onebox
|
||||
|
||||
# Create certbot directory for ACME challenges
|
||||
mkdir -p /var/www/certbot
|
||||
|
||||
info "✓ Initialization complete"
|
||||
}
|
||||
|
||||
# Print success message
|
||||
print_success() {
|
||||
echo ""
|
||||
info "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
info " Onebox installed successfully!"
|
||||
info "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
echo ""
|
||||
echo "Next steps:"
|
||||
echo ""
|
||||
echo "1. Configure Cloudflare (optional):"
|
||||
echo " onebox config set cloudflareAPIKey <key>"
|
||||
echo " onebox config set cloudflareEmail <email>"
|
||||
echo " onebox config set cloudflareZoneID <zone-id>"
|
||||
echo " onebox config set serverIP <your-server-ip>"
|
||||
echo ""
|
||||
echo "2. Configure ACME email:"
|
||||
echo " onebox config set acmeEmail <your@email.com>"
|
||||
echo ""
|
||||
echo "3. Install daemon:"
|
||||
echo " onebox daemon install"
|
||||
echo ""
|
||||
echo "4. Start daemon:"
|
||||
echo " onebox daemon start"
|
||||
echo ""
|
||||
echo "5. Deploy your first service:"
|
||||
echo " onebox service add myapp --image nginx:latest --domain app.example.com"
|
||||
echo ""
|
||||
echo "Web UI: http://localhost:3000"
|
||||
echo "Default credentials: admin / admin"
|
||||
echo ""
|
||||
}
|
||||
|
||||
# Main installation flow
|
||||
main() {
|
||||
info "Onebox Installer"
|
||||
echo ""
|
||||
|
||||
check_root
|
||||
detect_platform
|
||||
get_latest_version
|
||||
download_binary
|
||||
install_binary
|
||||
initialize
|
||||
print_success
|
||||
}
|
||||
|
||||
# Run main function
|
||||
main
|
||||
Reference in New Issue
Block a user