From de1b74f6c7377324ae736c42cd52a3a14bc46700 Mon Sep 17 00:00:00 2001 From: PhoenixAceVFX Date: Sat, 25 Jan 2025 16:31:53 -0500 Subject: [PATCH] update(script): simplify (#126) --- README.md | 3 +-- misc/install.sh | 43 +++++++++++++++++++------------------------ 2 files changed, 20 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index af1628d7..0becfe08 100644 --- a/README.md +++ b/README.md @@ -189,8 +189,7 @@ Linux - [AUR](https://aur.archlinux.org/packages?O=0&K=equicord) ```shell sh -c "$(curl -sS https://raw.githubusercontent.com/Equicord/Equicord/refs/heads/main/misc/install.sh)" -``` - +``` ## Installing Equicord Devbuild ### Dependencies diff --git a/misc/install.sh b/misc/install.sh index 1ddcf677..6edd9cdb 100644 --- a/misc/install.sh +++ b/misc/install.sh @@ -1,55 +1,50 @@ #!/bin/sh - -# Exit immediately if a command exits with a non-zero status set -e -# Check if the script is run as root +# Constants +INSTALLER_PATH="$HOME/.equilotl" +GITHUB_URL="https://github.com/Equicord/Equilotl/releases/latest/download/EquilotlCli-Linux" + +# Check for root if [ "$(id -u)" -eq 0 ]; then - echo "Run this script as a normal user, not root!" + echo "Run me as a normal user, not root!" exit 1 fi -# Define variables -installer_path="$HOME/.equilotl" -github_url="https://github.com/Equicord/Equilotl/releases/latest/download/EquilotlCli-Linux" +download_installer() { + curl -sSL "$GITHUB_URL" --output "$INSTALLER_PATH" + chmod +x "$INSTALLER_PATH" +} -# Inform user about the update check echo "Checking if the installer needs updating..." -# Fetch the latest modified date from the server -latest_modified=$(curl -sI "$github_url" | grep -i "last-modified" | cut -d' ' -f2-) +if [ -f "$INSTALLER_PATH" ]; then + latest_modified=$(curl -sI "$GITHUB_URL" | grep -i "last-modified" | cut -d' ' -f2-) + local_modified=$(stat -c "%y" "$INSTALLER_PATH" | cut -d' ' -f1-2) -# Check if the installer exists locally -if [ -f "$installer_path" ]; then - # Get the local file's last modified date - local_modified=$(stat -c "%y" "$installer_path" | cut -d' ' -f1-2) - - # Compare the local file's date with the server's latest modified date if [ "$local_modified" = "$latest_modified" ]; then echo "The installer is up-to-date." else echo "The installer is outdated. Downloading the latest version..." - curl -sSL "$github_url" --output "$installer_path" - chmod +x "$installer_path" + download_installer fi else echo "Installer not found. Downloading it..." - curl -sSL "$github_url" --output "$installer_path" - chmod +x "$installer_path" + download_installer fi -# Check for sudo or doas availability to run the installer with elevated privileges +# Try to run the installer with sudo or doas if command -v sudo >/dev/null; then echo "Running installer with sudo..." - sudo "$installer_path" + sudo "$INSTALLER_PATH" elif command -v doas >/dev/null; then echo "Running installer with doas..." - doas "$installer_path" + doas "$INSTALLER_PATH" else echo "Neither sudo nor doas were found. Please install one to proceed." exit 1 fi -# Provide script attribution +# Credits echo "Original script forked from Vencord" echo "Modified by PhoenixAceVFX & Crxaw for Equicord Updater"