This commit is contained in:
Zane V
2025-10-01 00:15:14 -04:00
committed by GitHub
parent 7d18e7a13e
commit a628056d6f
3 changed files with 258 additions and 11 deletions

View File

@@ -1,7 +1,10 @@
#!/bin/bash
#
# ZDTT Terminal Installer
# Installs ZDTT Terminal and sets up the zdtt command
# Downloads and installs ZDTT Terminal from zdtt-sources.zane.org
#
# Quick Install:
# curl -O https://zdtt-sources.zane.org/install.sh && chmod +x install.sh && ./install.sh
#
set -e # Exit on error
@@ -141,18 +144,100 @@ echo ""
# Create directories if they don't exist
mkdir -p "$INSTALL_DIR"
mkdir -p "$BIN_DIR"
mkdir -p "$HOME/.zdtt/plugins"
echo "Installing ZDTT Terminal..."
echo "Downloading files from zdtt-sources.zane.org..."
echo ""
# Copy the terminal.py, install.sh, and version.txt to the installation directory
# Base URL for ZDTT sources
BASE_URL="https://zdtt-sources.zane.org"
# Files to download
declare -a FILES=("terminal.py" "version.txt")
# Download files
DOWNLOAD_SUCCESS=true
for file in "${FILES[@]}"; do
echo "Downloading $file..."
if command -v wget &> /dev/null; then
if wget -q "$BASE_URL/$file" -O "$INSTALL_DIR/$file" 2>/dev/null; then
echo -e "${GREEN}${NC} $file downloaded"
else
echo -e "${RED}${NC} Failed to download $file"
DOWNLOAD_SUCCESS=false
break
fi
elif command -v curl &> /dev/null; then
if curl -sSL "$BASE_URL/$file" -o "$INSTALL_DIR/$file" 2>/dev/null; then
echo -e "${GREEN}${NC} $file downloaded"
else
echo -e "${RED}${NC} Failed to download $file"
DOWNLOAD_SUCCESS=false
break
fi
else
echo -e "${RED}${NC} Neither wget nor curl found"
echo "Please install wget or curl to proceed"
echo ""
echo "Press any key to exit..."
read -n 1 -s -r
exit 1
fi
done
if [ "$DOWNLOAD_SUCCESS" = false ]; then
echo ""
echo -e "${RED}Installation failed - unable to download required files${NC}"
echo "Please check your internet connection and try again."
echo ""
echo "Press any key to exit..."
read -n 1 -s -r
exit 1
fi
# Copy this installer to the installation directory for future use
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cp "$SCRIPT_DIR/terminal.py" "$INSTALL_DIR/terminal.py"
cp "$SCRIPT_DIR/install.sh" "$INSTALL_DIR/install.sh"
cp "$SCRIPT_DIR/version.txt" "$INSTALL_DIR/version.txt"
cp "$0" "$INSTALL_DIR/install.sh"
# Set executable permissions
chmod +x "$INSTALL_DIR/terminal.py"
chmod +x "$INSTALL_DIR/install.sh"
echo -e "${GREEN}${NC} ZDTT Terminal files copied to $INSTALL_DIR"
echo ""
echo -e "${GREEN}${NC} ZDTT Terminal files installed to $INSTALL_DIR"
# Download and install example plugin
echo ""
echo "Installing example plugin..."
EXAMPLE_PLUGIN_URL="https://plugins.zane.org/example_plugin.py"
PLUGIN_DEST="$HOME/.zdtt/plugins/example_plugin.py"
# Try wget first (more reliable), then curl
PLUGIN_DOWNLOADED=false
if command -v wget &> /dev/null; then
if wget -q "$EXAMPLE_PLUGIN_URL" -O "$PLUGIN_DEST" 2>/dev/null; then
echo -e "${GREEN}${NC} Example plugin installed from plugins.zane.org"
PLUGIN_DOWNLOADED=true
fi
fi
if [ "$PLUGIN_DOWNLOADED" = false ] && command -v curl &> /dev/null; then
# Suppress curl snap warnings and try download
if curl -sSL "$EXAMPLE_PLUGIN_URL" -o "$PLUGIN_DEST" 2>/dev/null; then
echo -e "${GREEN}${NC} Example plugin installed from plugins.zane.org"
PLUGIN_DOWNLOADED=true
fi
fi
if [ "$PLUGIN_DOWNLOADED" = false ]; then
echo -e "${YELLOW}${NC} Could not download example plugin"
echo " You can install it later with: zps install $EXAMPLE_PLUGIN_URL"
# Don't exit - continue with installation
fi
# Create the zdtt wrapper script
cat > "$BIN_DIR/zdtt" << 'EOF'
@@ -169,6 +254,60 @@ case "$1" in
clear
python3 "$ZDTT_DIR/terminal.py"
;;
update)
echo "Checking for updates..."
# Get current version
if [ -f "$ZDTT_DIR/version.txt" ]; then
CURRENT_VERSION=$(cat "$ZDTT_DIR/version.txt")
else
CURRENT_VERSION="unknown"
fi
# Get remote version
if command -v curl &> /dev/null; then
REMOTE_VERSION=$(curl -sSL https://zdtt-sources.zane.org/version.txt 2>/dev/null)
elif command -v wget &> /dev/null; then
REMOTE_VERSION=$(wget -qO- https://zdtt-sources.zane.org/version.txt 2>/dev/null)
else
echo "Error: Neither curl nor wget found"
exit 1
fi
if [ -z "$REMOTE_VERSION" ]; then
echo "Error: Could not fetch remote version"
exit 1
fi
echo "Current version: $CURRENT_VERSION"
echo "Latest version: $REMOTE_VERSION"
echo ""
if [ "$CURRENT_VERSION" = "$REMOTE_VERSION" ]; then
echo "✓ You're already running the latest version!"
else
echo "Update available!"
read -p "Do you want to update now? (yes/no): " -r
if [[ $REPLY =~ ^[Yy][Ee][Ss]$ ]]; then
# Run the installer
if [ -f "$ZDTT_DIR/install.sh" ]; then
bash "$ZDTT_DIR/install.sh"
else
echo "Downloading installer..."
TEMP_INSTALLER="/tmp/zdtt_install.sh"
if command -v curl &> /dev/null; then
curl -sSL https://zdtt-sources.zane.org/install.sh -o "$TEMP_INSTALLER"
else
wget -qO "$TEMP_INSTALLER" https://zdtt-sources.zane.org/install.sh
fi
bash "$TEMP_INSTALLER"
rm -f "$TEMP_INSTALLER"
fi
else
echo "Update cancelled."
fi
fi
;;
installer|install|reinstall)
# Run the installer for reinstalling/updating
if [ -f "$ZDTT_DIR/install.sh" ]; then
@@ -205,6 +344,7 @@ case "$1" in
echo ""
echo "Usage:"
echo " zdtt start - Start the ZDTT Terminal"
echo " zdtt update - Check for and install updates"
echo " zdtt installer - Run installer (for updates/reinstall)"
echo " zdtt version - Display version information"
echo " zdtt uninstall - Uninstall ZDTT Terminal"