mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2025-09-07 14:58:56 +00:00
Add universal installer scripts and update README
This commit is contained in:
24
README.md
24
README.md
@@ -59,6 +59,30 @@ SeedPass now uses the `portalocker` library for cross-platform file locking. No
|
||||
|
||||
## Installation
|
||||
|
||||
|
||||
### Quick Installer
|
||||
|
||||
Use the automated installer to download SeedPass and its dependencies in one step.
|
||||
|
||||
**Linux and macOS:**
|
||||
```bash
|
||||
bash -c "$(curl -sSL https://raw.githubusercontent.com/PR0M3TH3AN/SeedPass/main/scripts/install.sh)"
|
||||
```
|
||||
*Install the beta branch:*
|
||||
```bash
|
||||
bash -c "$(curl -sSL https://raw.githubusercontent.com/PR0M3TH3AN/SeedPass/main/scripts/install.sh)" _ -b beta
|
||||
```
|
||||
|
||||
**Windows (PowerShell):**
|
||||
```powershell
|
||||
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; $scriptContent = (New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/PR0M3TH3AN/SeedPass/main/scripts/install.ps1'); & ([scriptblock]::create($scriptContent))
|
||||
```
|
||||
*Install the beta branch:*
|
||||
```powershell
|
||||
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; $scriptContent = (New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/PR0M3TH3AN/SeedPass/main/scripts/install.ps1'); & ([scriptblock]::create($scriptContent)) -Branch beta
|
||||
```
|
||||
|
||||
### Manual Setup
|
||||
Follow these steps to set up SeedPass on your local machine.
|
||||
|
||||
### 1. Clone the Repository
|
||||
|
99
scripts/install.ps1
Normal file
99
scripts/install.ps1
Normal file
@@ -0,0 +1,99 @@
|
||||
#
|
||||
# SeedPass Universal Installer for Windows
|
||||
#
|
||||
# Supports installing from a specific branch using the -Branch parameter.
|
||||
# Example: .\install.ps1 -Branch beta
|
||||
|
||||
param(
|
||||
[string]$Branch = "main" # The git branch to install from
|
||||
)
|
||||
|
||||
# --- Configuration ---
|
||||
$RepoUrl = "https://github.com/PR0M3TH3AN/SeedPass.git"
|
||||
$AppRootDir = Join-Path $env:USERPROFILE ".seedpass"
|
||||
$InstallDir = Join-Path $AppRootDir "app"
|
||||
$VenvDir = Join-Path $InstallDir "venv"
|
||||
$LauncherDir = Join-Path $InstallDir "bin"
|
||||
$LauncherName = "seedpass.cmd"
|
||||
|
||||
# --- Helper Functions ---
|
||||
function Write-Info { param([string]$Message) Write-Host "[INFO] $Message" -ForegroundColor Cyan }
|
||||
function Write-Success { param([string]$Message) Write-Host "[SUCCESS] $Message" -ForegroundColor Green }
|
||||
function Write-Warning { param([string]$Message) Write-Host "[WARNING] $Message" -ForegroundColor Yellow }
|
||||
function Write-Error {
|
||||
param([string]$Message)
|
||||
Write-Host "[ERROR] $Message" -ForegroundColor Red
|
||||
Read-Host "Press Enter to exit"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# --- Main Script ---
|
||||
|
||||
# 1. Check for prerequisites
|
||||
Write-Info "Installing SeedPass from branch: '$Branch'"
|
||||
Write-Info "Checking for prerequisites..."
|
||||
if (-not (Get-Command git -ErrorAction SilentlyContinue)) { Write-Error "Git is not installed. Please install it from https://git-scm.com/ and ensure it's in your PATH." }
|
||||
$pythonExe = Get-Command python -ErrorAction SilentlyContinue
|
||||
if (-not $pythonExe) { Write-Error "Python 3 is not installed or not in your PATH. Please install it from https://www.python.org/" }
|
||||
|
||||
# 2. Clone or update the repository
|
||||
if (Test-Path (Join-Path $InstallDir ".git")) {
|
||||
Write-Info "SeedPass directory found. Fetching updates and switching to '$Branch' branch..."
|
||||
try {
|
||||
Set-Location $InstallDir
|
||||
git fetch origin
|
||||
git checkout $Branch
|
||||
git pull origin $Branch --ff-only
|
||||
} catch { Write-Error "Failed to update repository. Error: $_" }
|
||||
} else {
|
||||
Write-Info "Cloning SeedPass '$Branch' branch..."
|
||||
try {
|
||||
if (-not(Test-Path $AppRootDir)) { New-Item -ItemType Directory -Path $AppRootDir | Out-Null }
|
||||
git clone --branch $Branch $RepoUrl $InstallDir
|
||||
Set-Location $InstallDir
|
||||
} catch { Write-Error "Failed to clone repository. Error: $_" }
|
||||
}
|
||||
|
||||
# 3. Set up Python virtual environment
|
||||
Write-Info "Setting up Python virtual environment..."
|
||||
if (-not (Test-Path $VenvDir)) {
|
||||
try { python -m venv $VenvDir } catch { Write-Error "Failed to create virtual environment. Error: $_" }
|
||||
}
|
||||
|
||||
# 4. Install/Update Python dependencies
|
||||
Write-Info "Installing/updating Python dependencies..."
|
||||
try {
|
||||
& "$VenvDir\Scripts\pip.exe" install --upgrade pip
|
||||
& "$VenvDir\Scripts\pip.exe" install -r "src\requirements.txt"
|
||||
} catch {
|
||||
Write-Warning "Failed to install Python dependencies. If errors mention C++, install Microsoft C++ Build Tools: https://visualstudio.microsoft.com/visual-cpp-build-tools/"
|
||||
Write-Error "Dependency installation failed. Error: $_"
|
||||
}
|
||||
|
||||
# 5. Create launcher script
|
||||
Write-Info "Creating launcher script..."
|
||||
if (-not (Test-Path $LauncherDir)) { New-Item -ItemType Directory -Path $LauncherDir | Out-Null }
|
||||
$LauncherPath = Join-Path $LauncherDir $LauncherName
|
||||
$LauncherContent = @"
|
||||
@echo off
|
||||
setlocal
|
||||
call "%~dp0..\venv\Scripts\activate.bat"
|
||||
python "%~dp0..\src\main.py" %*
|
||||
endlocal
|
||||
"@
|
||||
Set-Content -Path $LauncherPath -Value $LauncherContent -Force
|
||||
|
||||
# 6. Add launcher directory to User's PATH if needed
|
||||
Write-Info "Checking if '$LauncherDir' is in your PATH..."
|
||||
$UserPath = [System.Environment]::GetEnvironmentVariable("Path", "User")
|
||||
if (($UserPath -split ';') -notcontains $LauncherDir) {
|
||||
Write-Info "Adding '$LauncherDir' to your user PATH."
|
||||
$NewPath = "$LauncherDir;$UserPath".Trim(";")
|
||||
[System.Environment]::SetEnvironmentVariable("Path", $NewPath, "User")
|
||||
Write-Warning "PATH has been updated. You MUST open a new terminal for the 'seedpass' command to be available."
|
||||
} else {
|
||||
Write-Info "'$LauncherDir' is already in your user PATH."
|
||||
}
|
||||
|
||||
Write-Success "Installation/update complete!"
|
||||
Write-Info "To run the application, please open a NEW terminal window and type: seedpass"
|
129
scripts/install.sh
Executable file
129
scripts/install.sh
Executable file
@@ -0,0 +1,129 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# SeedPass Universal Installer for Linux and macOS
|
||||
#
|
||||
# Supports installing from a specific branch using the -b or --branch flag.
|
||||
# Example: ./install.sh -b beta
|
||||
|
||||
set -e
|
||||
|
||||
# --- Configuration ---
|
||||
REPO_URL="https://github.com/PR0M3TH3AN/SeedPass.git"
|
||||
APP_ROOT_DIR="$HOME/.seedpass"
|
||||
INSTALL_DIR="$APP_ROOT_DIR/app"
|
||||
VENV_DIR="$INSTALL_DIR/venv"
|
||||
LAUNCHER_DIR="$HOME/.local/bin"
|
||||
LAUNCHER_PATH="$LAUNCHER_DIR/seedpass"
|
||||
BRANCH="main" # Default branch
|
||||
|
||||
# --- Helper Functions ---
|
||||
print_info() { echo -e "\033[1;34m[INFO]\033[0m $1"; }
|
||||
print_success() { echo -e "\033[1;32m[SUCCESS]\033[0m $1"; }
|
||||
print_warning() { echo -e "\033[1;33m[WARNING]\033[0m $1"; }
|
||||
print_error() { echo -e "\033[1;31m[ERROR]\033[0m $1" >&2; exit 1; }
|
||||
usage() {
|
||||
echo "Usage: $0 [-b | --branch <branch_name>] [-h | --help]"
|
||||
echo " -b, --branch Specify the git branch to install (default: main)"
|
||||
echo " -h, --help Display this help message"
|
||||
exit 0
|
||||
}
|
||||
|
||||
# --- Main Script ---
|
||||
main() {
|
||||
# Parse command-line arguments
|
||||
while [[ "$#" -gt 0 ]]; do
|
||||
case "$1" in
|
||||
-b|--branch)
|
||||
if [ -n "$2" ]; then
|
||||
BRANCH="$2"
|
||||
shift 2
|
||||
else
|
||||
print_error "Error: --branch requires a non-empty option argument."
|
||||
fi
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
;;
|
||||
*)
|
||||
print_error "Unknown parameter passed: $1"; usage
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# 1. Detect OS
|
||||
OS_NAME=$(uname -s)
|
||||
print_info "Installing SeedPass from branch: '$BRANCH'"
|
||||
print_info "Detected Operating System: $OS_NAME"
|
||||
|
||||
# 2. Check for prerequisites
|
||||
print_info "Checking for prerequisites (git, python3, pip)..."
|
||||
if ! command -v git &> /dev/null; then print_error "Git is not installed. Please install it."; fi
|
||||
if ! command -v python3 &> /dev/null; then print_error "Python 3 is not installed. Please install it."; fi
|
||||
if ! python3 -m ensurepip --default-pip &> /dev/null && ! command -v pip3 &> /dev/null; then print_error "pip for Python 3 is not available. Please install it."; fi
|
||||
if ! python3 -c "import venv" &> /dev/null; then
|
||||
print_warning "Python 'venv' module not found. Attempting to install..."
|
||||
if [ "$OS_NAME" = "Linux" ]; then
|
||||
if command -v apt-get &> /dev/null; then sudo apt-get update && sudo apt-get install -y python3-venv;
|
||||
elif command -v dnf &> /dev/null; then sudo dnf install -y python3-virtualenv;
|
||||
else print_error "Could not auto-install python3-venv. Please install it for your distribution."; fi
|
||||
else print_error "Python 'venv' module is missing."; fi
|
||||
fi
|
||||
|
||||
# 3. Install OS-specific dependencies
|
||||
print_info "Checking for build dependencies..."
|
||||
if [ "$OS_NAME" = "Linux" ]; then
|
||||
if command -v apt-get &> /dev/null; then sudo apt-get update && sudo apt-get install -y build-essential pkg-config xclip;
|
||||
elif command -v dnf &> /dev/null; then sudo dnf groupinstall -y "Development Tools" && sudo dnf install -y pkg-config xclip;
|
||||
elif command -v pacman &> /dev/null; then sudo pacman -Syu --noconfirm base-devel pkg-config xclip;
|
||||
else print_warning "Could not detect package manager. Ensure build tools and pkg-config are installed."; fi
|
||||
elif [ "$OS_NAME" = "Darwin" ]; then
|
||||
if ! command -v brew &> /dev/null; then print_error "Homebrew not installed. See https://brew.sh/"; fi
|
||||
brew install pkg-config
|
||||
fi
|
||||
|
||||
# 4. Clone or update the repository
|
||||
if [ -d "$INSTALL_DIR/.git" ]; then
|
||||
print_info "SeedPass directory found. Fetching updates and switching to '$BRANCH' branch..."
|
||||
cd "$INSTALL_DIR"
|
||||
git fetch origin
|
||||
git checkout "$BRANCH"
|
||||
git pull origin "$BRANCH" --ff-only
|
||||
else
|
||||
print_info "Cloning SeedPass '$BRANCH' branch to '$INSTALL_DIR'..."
|
||||
mkdir -p "$APP_ROOT_DIR"
|
||||
git clone --branch "$BRANCH" "$REPO_URL" "$INSTALL_DIR"
|
||||
cd "$INSTALL_DIR"
|
||||
fi
|
||||
|
||||
# 5. Set up Python virtual environment
|
||||
print_info "Setting up Python virtual environment in '$VENV_DIR'..."
|
||||
if [ ! -d "$VENV_DIR" ]; then python3 -m venv "$VENV_DIR"; fi
|
||||
# shellcheck source=/dev/null
|
||||
source "$VENV_DIR/bin/activate"
|
||||
|
||||
# 6. Install/Update Python dependencies
|
||||
print_info "Installing/updating Python dependencies from src/requirements.txt..."
|
||||
pip install --upgrade pip
|
||||
pip install -r src/requirements.txt
|
||||
deactivate
|
||||
|
||||
# 7. Create launcher script
|
||||
print_info "Creating launcher script at '$LAUNCHER_PATH'..."
|
||||
mkdir -p "$LAUNCHER_DIR"
|
||||
cat > "$LAUNCHER_PATH" << EOF2
|
||||
#!/bin/bash
|
||||
source "$VENV_DIR/bin/activate"
|
||||
exec python3 "$INSTALL_DIR/src/main.py" "\$@"
|
||||
EOF2
|
||||
chmod +x "$LAUNCHER_PATH"
|
||||
|
||||
# 8. Final instructions
|
||||
print_success "Installation/update complete!"
|
||||
print_info "You can now run the application by typing: seedpass"
|
||||
if [[ ":$PATH:" != *":$LAUNCHER_DIR:"* ]]; then
|
||||
print_warning "Directory '$LAUNCHER_DIR' is not in your PATH."
|
||||
print_warning "Please add 'export PATH=\"$HOME/.local/bin:$PATH\"' to your shell's config file (e.g., ~/.bashrc, ~/.zshrc) and restart your terminal."
|
||||
fi
|
||||
}
|
||||
|
||||
main "$@"
|
Reference in New Issue
Block a user