#!/bin/bash # TV Garden Installer for Enigma2 # wget -q --no-check-certificate "https://raw.githubusercontent.com/Belfagor2005/TVGarden/main/installer.sh" -O - | /bin/sh version='1.5' changelog = ( 'New option: "Export ALL Database (Multi-File)"\n' 'Retained: "Export ALL Database (Single File)" for compatibility\n' 'Choice: User decides between speed (multi-file) or simplicity (single-file)\n' 'Limitation: Max 500 channels per file\n' 'Advantage: Enigma2 loads each file quickly\n' 'Navigation: Intuitive hierarchical structure\n' ) TMPPATH=/tmp/TVGarden-install FILEPATH=/tmp/TVGarden-main.tar.gz echo "Starting TVGarden installation..." if [ ! -d /usr/lib64 ]; then PLUGINPATH=/usr/lib/enigma2/python/Plugins/Extensions/TVGarden else PLUGINPATH=/usr/lib64/enigma2/python/Plugins/Extensions/TVGarden fi cleanup() { echo "Cleaning up temporary files..." [ -d "$TMPPATH" ] && rm -rf "$TMPPATH" [ -f "$FILEPATH" ] && rm -f "$FILEPATH" [ -d "/tmp/TVGarden-main" ] && rm -rf "/tmp/TVGarden-main" } detect_os() { if [ -f /var/lib/dpkg/status ]; then OSTYPE="DreamOs" STATUS="/var/lib/dpkg/status" elif [ -f /etc/opkg/opkg.conf ] || [ -f /var/lib/opkg/status ]; then OSTYPE="OE" STATUS="/var/lib/opkg/status" else OSTYPE="Unknown" STATUS="" fi echo "Detected OS type: $OSTYPE" } detect_os cleanup mkdir -p "$TMPPATH" if ! command -v wget >/dev/null 2>&1; then echo "Installing wget..." case "$OSTYPE" in "DreamOs") apt-get update && apt-get install -y wget || { echo "Failed to install wget"; exit 1; } ;; "OE") opkg update && opkg install wget || { echo "Failed to install wget"; exit 1; } ;; *) echo "Unsupported OS type. Cannot install wget." exit 1 ;; esac fi if python --version 2>&1 | grep -q '^Python 3\.'; then echo "Python3 image detected" PYTHON="PY3" Packagesix="python3-six" # Packagerequests="python3-requests" else echo "Python2 image detected" PYTHON="PY2" # Packagerequests="python-requests" Packagesix="python-six" fi install_pkg() { local pkg=$1 if [ -z "$STATUS" ] || ! grep -qs "Package: $pkg" "$STATUS" 2>/dev/null; then echo "Installing $pkg..." case "$OSTYPE" in "DreamOs") apt-get update && apt-get install -y "$pkg" || { echo "Could not install $pkg, continuing anyway..."; } ;; "OE") opkg update && opkg install "$pkg" || { echo "Could not install $pkg, continuing anyway..."; } ;; *) echo "Cannot install $pkg on unknown OS type, continuing..." ;; esac else echo "$pkg already installed" fi } if [ "$PYTHON" = "PY3" ]; then install_pkg "$Packagesix" fi # install_pkg "$Packagerequests" [ -e "/usr/bin/python3" ] && PY="python3" || PY="python"; opkg update; opkg install "${PY}-requests" if [ "$OSTYPE" = "OE" ]; then echo "Installing additional multimedia packages..." for pkg in ffmpeg gstplayer exteplayer3 enigma2-plugin-systemplugins-serviceapp; do install_pkg "$pkg" done fi echo "Downloading TVGarden..." wget --no-check-certificate 'https://github.com/Belfagor2005/TVGarden/archive/refs/heads/main.tar.gz' -O "$FILEPATH" if [ $? -ne 0 ]; then echo "Failed to download TVGarden package!" cleanup exit 1 fi echo "Extracting package..." tar -xzf "$FILEPATH" -C "$TMPPATH" if [ $? -ne 0 ]; then echo "Failed to extract TVGarden package!" cleanup exit 1 fi echo "Installing plugin files..." mkdir -p "$PLUGINPATH" # TROVA E COPIA IL CONTENUTO CORRETTO - METODO ROBUSTO SOURCE_DIR="" # Cerca il contenuto del plugin in vari percorsi possibili for search_path in \ "$TMPPATH/TVGarden-main/TVGarden" \ "$TMPPATH/TVGarden-main" \ "$TMPPATH/TVGarden-main/usr/lib/enigma2/python/Plugins/Extensions/TVGarden" \ "$TMPPATH/TVGarden-main/usr/lib64/enigma2/python/Plugins/Extensions/TVGarden" do if [ -d "$search_path" ] && [ -f "$search_path/plugin.py" ]; then SOURCE_DIR="$search_path" echo "Found plugin source at: $SOURCE_DIR" break fi done if [ -n "$SOURCE_DIR" ]; then # Copia tutto il contenuto della directory trovata echo "Copying plugin files from $SOURCE_DIR to $PLUGINPATH" cp -r "$SOURCE_DIR"/* "$PLUGINPATH/" 2>/dev/null # Verifica che i file critici siano stati copiati if [ $? -eq 0 ] && [ -f "$PLUGINPATH/plugin.py" ]; then echo "Successfully copied plugin files" # Imposta i permessi corretti chmod -R 755 "$PLUGINPATH" find "$PLUGINPATH" -name "*.py" -exec chmod 644 {} \; find "$PLUGINPATH" -name "*.sh" -exec chmod 755 {} \; else echo "Error: Failed to copy plugin files!" echo "Attempting fallback method..." # Fallback: estrai direttamente nella destinazione tar -xzf "$FILEPATH" --strip-components=1 -C "$PLUGINPATH" --wildcards "*TVGarden/*" 2>/dev/null fi else echo "Could not find plugin files in extracted archive!" echo "Available directories:" find "$TMPPATH" -type f -name "*.py" | head -10 cleanup exit 1 fi sync echo "Verifying installation..." if [ -f "$PLUGINPATH/plugin.py" ] && [ -f "$PLUGINPATH/__init__.py" ]; then echo "Plugin successfully installed: $PLUGINPATH" echo "Main files:" ls -la "$PLUGINPATH/plugin.py" "$PLUGINPATH/__init__.py" 2>/dev/null else echo "ERROR: Plugin installation failed!" echo "Missing critical files in: $PLUGINPATH" echo "Directory contents:" ls -la "$PLUGINPATH/" 2>/dev/null cleanup exit 1 fi cleanup sync FILE="/etc/image-version" box_type=$(head -n 1 /etc/hostname 2>/dev/null || echo "Unknown") distro_value=$(grep '^distro=' "$FILE" 2>/dev/null | awk -F '=' '{print $2}') distro_version=$(grep '^version=' "$FILE" 2>/dev/null | awk -F '=' '{print $2}') python_vers=$(python --version 2>&1) cat </dev/null 2>&1; then # systemctl restart enigma2 # elif command -v init >/dev/null 2>&1; then # init 4 && sleep 2 && init 3 # else # killall -9 enigma2 # fi exit 0