-
Notifications
You must be signed in to change notification settings - Fork 0
Scripts
This guide covers the utility scripts provided with Chat Linux Client for installation, running, and building.
- Overview
- Installation Script
- Run Script
- AppImage Build Script
- Custom Scripts
- Troubleshooting Scripts
Chat Linux Client includes several utility scripts in the scripts/ directory:
-
install.sh- Automated installation -
run.sh- Application launcher -
build_appimage.sh- AppImage builder
These scripts simplify common tasks and ensure consistency across different systems.
scripts/install.sh
Automates the installation process including:
- Python version check
- Virtual environment creation
- Dependency installation
- Directory setup
- Permission configuration
./scripts/install.sh-
Checks Python version
python_version=$(python3 --version 2>&1 | awk '{print $2}') # Verifies Python 3.8+
-
Creates virtual environment
python3 -m venv venv source venv/bin/activate -
Installs dependencies
pip install --upgrade pip pip install -r requirements.txt
-
Sets up directories
mkdir -p ~/.config/chat-linux-client mkdir -p ~/.local/share/chat-linux-client/logs
-
Sets permissions
chmod +x scripts/*.sh
The script can be customized with environment variables:
# Skip Python version check
SKIP_PYTHON_CHECK=1 ./scripts/install.sh
# Use custom Python version
PYTHON_CMD=python3.9 ./scripts/install.sh
# Install to custom location
INSTALL_DIR=/custom/path ./scripts/install.shPython version too old
# Install newer Python
sudo apt install python3.9Permission denied
# Make script executable
chmod +x scripts/install.shDependency installation fails
# Update pip first
pip install --upgrade pipscripts/run.sh
Simple launcher for the application that:
- Activates virtual environment
- Runs the application
- Handles errors gracefully
./scripts/run.sh-
Activates virtual environment
source venv/bin/activate -
Runs the application
python main.py "$@" -
Passes arguments Any command-line arguments are passed to the application:
./scripts/run.sh --check-system ./scripts/run.sh --help
Pass arguments to the application:
# Run with system checks
./scripts/run.sh --check-system
# Run in debug mode
DEBUG=true ./scripts/run.sh
# Run with custom log level
LOG_LEVEL=DEBUG ./scripts/run.shCreate a desktop entry that uses the run script:
[Desktop Entry]
Version=1.0
Type=Application
Name=Chat Linux Client
Exec=/path/to/chat-linux-client/scripts/run.sh
Icon=/path/to/chat-linux-client/assets/icon.png
Terminal=false
Categories=Utility;scripts/build_appimage.sh
Builds a distributable AppImage package that:
- Includes all dependencies
- Works on most Linux distributions
- Requires no installation
- Is self-contained
./scripts/build_appimage.sh-
Checks dependencies
- AppImage tools
- Python
- Required packages
-
Creates build directory
mkdir -p build cd build -
Copies application files
cp -r ../core . cp -r ../ui . cp -r ../storage . cp -r ../utils . cp main.py . cp requirements.txt .
-
Installs dependencies
pip install --target=./usr/lib/python3.9/site-packages -r requirements.txt
-
Creates AppImage
appimage-builder --recipe ../packaging/AppImageBuilder.yml
-
Signs AppImage (optional)
gpg --output Chat-Linux-Client.AppImage.sig --detach-sign Chat-Linux-Client.AppImage
The script requires:
appimage-builderpatchelfdesktop-file-validatezsyncmake
Install on Ubuntu/Debian:
sudo apt install appimage-builder patchelf desktop-file-utils zsyncmake# Build specific version
VERSION=1.0.0 ./scripts/build_appimage.sh
# Skip signing
SKIP_SIGNING=1 ./scripts/build_appimage.sh
# Custom output directory
OUTPUT_DIR=/custom/path ./scripts/build_appimage.shThe script produces:
-
Chat-Linux-Client-VERSION-x86_64.AppImage- The AppImage file -
Chat-Linux-Client-VERSION-x86_64.AppImage.sig- Signature (if signing enabled) -
Chat-Linux-Client-VERSION-x86_64.AppImage.zsync- Update info (for delta updates)
# Make executable
chmod +x Chat-Linux-Client-VERSION-x86_64.AppImage
# Run
./Chat-Linux-Client-VERSION-x86_64.AppImageMissing appimage-builder
pip install appimage-builderBuild fails with dependency errors
# Install system dependencies
sudo apt install build-essential libssl-dev libffi-dev python3-devAppImage won't run
# Extract to debug
./Chat-Linux-Client.AppImage --appimage-extract
./squashfs-root/AppRunCreate a custom system check script:
#!/bin/bash
# scripts/check_system.sh
echo "Checking Chat Linux Client system requirements..."
# Check Python
python3 --version
if [ $? -ne 0 ]; then
echo "Error: Python 3 not found"
exit 1
fi
# Check PyQt6
python3 -c "import PyQt6" 2>/dev/null
if [ $? -ne 0 ]; then
echo "Error: PyQt6 not installed"
exit 1
fi
# Check Ollama (optional)
ollama --version 2>/dev/null
if [ $? -eq 0 ]; then
echo "Ollama: Installed"
else
echo "Ollama: Not installed (optional)"
fi
echo "System check complete!"Create a backup script for configuration and data:
#!/bin/bash
# scripts/backup.sh
BACKUP_DIR="$HOME/chat-linux-client-backup-$(date +%Y%m%d)"
mkdir -p "$BACKUP_DIR"
# Backup configuration
cp -r ~/.config/chat-linux-client "$BACKUP_DIR/"
# Backup data
cp -r ~/.local/share/chat-linux-client "$BACKUP_DIR/"
echo "Backup created at: $BACKUP_DIR"Create a cleanup script to remove old data:
#!/bin/bash
# scripts/cleanup.sh
echo "Cleaning up Chat Linux Client data..."
# Clear logs
rm -rf ~/.local/share/chat-linux-client/logs/*
# Clear old chats (older than 30 days)
find ~/.local/share/chat-linux-client -name "*.db" -mtime +30 -delete
echo "Cleanup complete!"If scripts won't run:
chmod +x scripts/*.shIf script complains about Python version:
# Check Python version
python3 --version
# Install newer Python
sudo apt install python3.9
# Or specify Python in script
PYTHON_CMD=python3.9 ./scripts/install.shIf virtual environment has problems:
# Remove and recreate
rm -rf venv
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txtIf dependencies won't install:
# Update pip
pip install --upgrade pip
# Try installing individually
pip install PyQt6
pip install aiohttp
pip install cryptography-
Use shebang:
#!/bin/bash -
Set permissions:
chmod +x script.sh - Check dependencies: Verify required tools
-
Handle errors: Use
set -efor error handling - Log actions: Echo what's happening
- Clean up: Remove temporary files
- Use variables: Make scripts configurable
#!/bin/bash
set -e # Exit on error
# Configuration
APP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
VENV_DIR="$APP_DIR/venv"
# Functions
log() {
echo "[$(date)] $1"
}
error() {
echo "ERROR: $1" >&2
exit 1
}
# Main script
log "Starting script..."
# Your code here
log "Script complete!"