From 954cbebd75f732a4f22eb254de70ecbd5a9435cf Mon Sep 17 00:00:00 2001 From: kilyabin <65072190+kilyabin@users.noreply.github.com> Date: Mon, 6 Apr 2026 23:46:05 +0400 Subject: [PATCH] feat: auto-install script for Debian/RHEL --- README.md | 6 ++ scripts/README.md | 52 ++++++++++++++ scripts/install.sh | 171 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 229 insertions(+) create mode 100644 scripts/README.md create mode 100755 scripts/install.sh diff --git a/README.md b/README.md index 4038132b..c36cc5e4 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,12 @@ Navigate to the [Releases](https://github.com/Psychotoxical/psysonic/releases) p ### 🐧 Linux +**Quick Install (Recommended):** +```bash +curl -fsSL https://raw.githubusercontent.com/Psychotoxical/psysonic/main/scripts/install.sh | sudo bash +``` + +**Manual Installation:** - **Ubuntu / Debian**: `.deb` from GitHub Releases - **Fedora / RHEL**: `.rpm` from GitHub Releases diff --git a/scripts/README.md b/scripts/README.md new file mode 100644 index 00000000..0600d736 --- /dev/null +++ b/scripts/README.md @@ -0,0 +1,52 @@ +# Scripts + +## install.sh - Auto-Installer for Debian and RHEL-based Systems + +This script automatically downloads and installs the latest Psysonic release from GitHub Releases. + +### Supported Distributions + +- **Debian/Ubuntu**: Downloads and installs `.deb` package +- **RHEL/Fedora/CentOS**: Downloads and installs `.rpm` package + +### Usage + +#### Quick Install (Recommended) + +```bash +curl -fsSL https://raw.githubusercontent.com/Psychotoxical/psysonic/main/scripts/install.sh | sudo bash +``` + +#### Manual Installation + +```bash +# Download the script +wget https://raw.githubusercontent.com/Psychotoxical/psysonic/main/scripts/install.sh + +# Make it executable +chmod +x install.sh + +# Run with sudo +sudo ./install.sh +``` + +### What it does + +1. Detects your OS type (Debian or RHEL-based) +2. Fetches the latest release from GitHub +3. Downloads the appropriate package (.deb or .rpm) +4. Installs it using your system's package manager +5. Cleans up temporary files + +### Requirements + +- `curl` - for downloading packages +- `sudo` or root access +- Internet connection +- Supported package manager (apt-get, dnf, or yum) + +### Notes + +- If Psysonic is already installed, the script will ask if you want to reinstall +- The script automatically handles dependency installation for Debian systems +- After installation, you can launch Psysonic from your application menu or by running `psysonic` in the terminal diff --git a/scripts/install.sh b/scripts/install.sh new file mode 100755 index 00000000..f2da06ef --- /dev/null +++ b/scripts/install.sh @@ -0,0 +1,171 @@ +#!/bin/bash +set -e + +# Psysonic Auto-Installer +# Automatically detects your OS and installs the latest release from GitHub + +REPO="Psychotoxical/psysonic" +APP_NAME="psysonic" + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +NC='\033[0m' # No Color + +info() { + echo -e "${BLUE}[INFO]${NC} $1" +} + +success() { + echo -e "${GREEN}[SUCCESS]${NC} $1" +} + +warn() { + echo -e "${YELLOW}[WARN]${NC} $1" +} + +error() { + echo -e "${RED}[ERROR]${NC} $1" + exit 1 +} + +# Check if running as root +check_root() { + if [ "$EUID" -ne 0 ]; then + error "Please run this script as root (use sudo)" + fi +} + +# Detect package manager and OS type +detect_os() { + if command -v apt &> /dev/null; then + OS_TYPE="debian" + PACKAGE_MANAGER="apt" + info "Detected Debian/Ubuntu-based system (apt)" + elif command -v dnf &> /dev/null; then + OS_TYPE="rhel" + PACKAGE_MANAGER="dnf" + info "Detected RHEL/Fedora-based system (dnf)" + elif command -v yum &> /dev/null; then + OS_TYPE="rhel" + PACKAGE_MANAGER="yum" + info "Detected RHEL/CentOS-based system (yum)" + else + error "Unsupported package manager. This installer supports Debian/Ubuntu and RHEL/Fedora/CentOS systems." + fi +} + +# Get the latest release download URL for the specific package type +get_download_url() { + local api_url="https://api.github.com/repos/${REPO}/releases/latest" + + info "Fetching latest release information..." + + local release_info + release_info=$(curl -s "$api_url") + + if echo "$release_info" | grep -q "message.*Not Found"; then + error "Could not fetch release information. Please check your internet connection." + fi + + local tag_name + tag_name=$(echo "$release_info" | grep -o '"tag_name": *"[^"]*"' | head -1 | cut -d'"' -f4) + + if [ -z "$tag_name" ]; then + error "Could not determine latest release version." + fi + + info "Latest version: $tag_name" + + local download_url="" + + if [ "$OS_TYPE" = "debian" ]; then + download_url=$(echo "$release_info" | grep -o '"browser_download_url": *"[^"]*\.deb"' | head -1 | cut -d'"' -f4) + elif [ "$OS_TYPE" = "rhel" ]; then + download_url=$(echo "$release_info" | grep -o '"browser_download_url": *"[^"]*\.rpm"' | head -1 | cut -d'"' -f4) + fi + + if [ -z "$download_url" ]; then + error "Could not find download URL for $OS_TYPE package." + fi + + echo "$download_url" +} + +# Install the package +install_package() { + local download_url="$1" + local temp_dir + temp_dir=$(mktemp -d) + local package_file="$temp_dir/${APP_NAME}_latest" + + info "Downloading package..." + + if [ "$OS_TYPE" = "debian" ]; then + package_file="${package_file}.deb" + curl -L -o "$package_file" "$download_url" + + info "Installing package..." + $PACKAGE_MANAGER install -y "$package_file" || { + warn "Trying to fix broken dependencies..." + $PACKAGE_MANAGER install -f -y + } + elif [ "$OS_TYPE" = "rhel" ]; then + package_file="${package_file}.rpm" + curl -L -o "$package_file" "$download_url" + + info "Installing package..." + $PACKAGE_MANAGER install -y "$package_file" + fi + + # Cleanup + rm -rf "$temp_dir" +} + +# Check if app is already installed +check_installed() { + if command -v $APP_NAME &> /dev/null || command -v ${APP_NAME^} &> /dev/null; then + warn "${APP_NAME} appears to be already installed." + read -p "Do you want to reinstall? (y/N): " -n 1 -r + echo + if [[ ! $REPLY =~ ^[Yy]$ ]]; then + info "Installation cancelled." + exit 0 + fi + fi +} + +# Main installation flow +main() { + echo -e "${GREEN}" + echo "╔══════════════════════════════════════════════════════════╗" + echo "║ Psysonic Auto-Installer ║" + echo "║ Install the latest release from GitHub Releases ║" + echo "╚══════════════════════════════════════════════════════════╝" + echo -e "${NC}" + + check_root + detect_os + check_installed + + local download_url + download_url=$(get_download_url) + + if [ -z "$download_url" ]; then + error "Failed to get download URL." + fi + + info "Download URL: $download_url" + + install_package "$download_url" + + echo "" + success "Psysonic has been installed successfully!" + echo -e "${BLUE}You can launch it from your application menu or by running:${NC} psysonic" + echo "" +} + +# Run main function +main