mirror of
https://github.com/Equicord/Equicord.git
synced 2025-02-24 17:19:00 -05:00
update(script): rewrite (#161)
* Update README.md Custom URLs for the install script * Update README.md Mirrors because running the script from github is giving me problems (ratelimit or something i have no clue) * Update install.sh * Update README.md Mirror note * Update README.md * Update README.md * Update install.sh * Update README.md * Rewrite install.sh * Remove Mirror from Readme.md Would be nice if I could just keep that mirror in the PRs --------- Co-authored-by: PhoenixAceVFX <syndcatefan@gmail.com>
This commit is contained in:
parent
403fbeeac7
commit
cf0f4d4a63
2 changed files with 108 additions and 42 deletions
|
@ -190,7 +190,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
|
||||
|
|
148
misc/install.sh
148
misc/install.sh
|
@ -1,50 +1,116 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
# Constants
|
||||
# Configuration
|
||||
INSTALLER_PATH="$HOME/.equilotl"
|
||||
GITHUB_URL="https://github.com/Equicord/Equilotl/releases/latest/download/EquilotlCli-Linux"
|
||||
PRIVILEGE_CMDS=("sudo" "doas")
|
||||
DEBUG=false
|
||||
LOG_FILE="$(dirname "$(realpath "$0")")/equicordinstalldebug.log"
|
||||
|
||||
# Check for root
|
||||
if [ "$(id -u)" -eq 0 ]; then
|
||||
echo "Run me as a normal user, not root!"
|
||||
exit 1
|
||||
fi
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
download_installer() {
|
||||
curl -sSL "$GITHUB_URL" --output "$INSTALLER_PATH"
|
||||
chmod +x "$INSTALLER_PATH"
|
||||
# Debug logging
|
||||
debug_log() {
|
||||
if $DEBUG; then
|
||||
local timestamp
|
||||
timestamp=$(date +"%Y-%m-%d %T")
|
||||
echo -e "[$timestamp] $1" | tee -a "$LOG_FILE"
|
||||
fi
|
||||
}
|
||||
|
||||
echo "Checking if the installer needs updating..."
|
||||
|
||||
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)
|
||||
|
||||
if [ "$local_modified" = "$latest_modified" ]; then
|
||||
echo "The installer is up-to-date."
|
||||
else
|
||||
echo "The installer is outdated. Downloading the latest version..."
|
||||
download_installer
|
||||
fi
|
||||
else
|
||||
echo "Installer not found. Downloading it..."
|
||||
download_installer
|
||||
fi
|
||||
|
||||
# Try to run the installer with sudo or doas
|
||||
if command -v sudo >/dev/null; then
|
||||
echo "Running installer with sudo..."
|
||||
sudo "$INSTALLER_PATH"
|
||||
elif command -v doas >/dev/null; then
|
||||
echo "Running installer with doas..."
|
||||
doas "$INSTALLER_PATH"
|
||||
else
|
||||
echo "Neither sudo nor doas were found. Please install one to proceed."
|
||||
# Error handling
|
||||
error() {
|
||||
echo -e "${RED}Error: $1${NC}" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Credits
|
||||
echo "Original script forked from Vencord"
|
||||
echo "Modified by PhoenixAceVFX & Crxaw for Equicord Updater"
|
||||
# Check for root
|
||||
check_root() {
|
||||
if [ "$(id -u)" -eq 0 ]; then
|
||||
error "This script should not be run as root. Please run as a normal user."
|
||||
fi
|
||||
}
|
||||
|
||||
# Download the installer
|
||||
download_installer() {
|
||||
echo -e "${YELLOW}Downloading installer...${NC}"
|
||||
if ! curl -sSL "$GITHUB_URL" --output "$INSTALLER_PATH"; then
|
||||
error "Failed to download installer from GitHub"
|
||||
fi
|
||||
chmod +x "$INSTALLER_PATH" || error "Failed to make installer executable"
|
||||
}
|
||||
|
||||
# Check if installer needs update
|
||||
check_for_updates() {
|
||||
if [ ! -f "$INSTALLER_PATH" ]; then
|
||||
echo -e "${YELLOW}Installer not found. Downloading...${NC}"
|
||||
download_installer
|
||||
return
|
||||
fi
|
||||
|
||||
local latest_modified local_modified
|
||||
if ! latest_modified=$(curl -sI "$GITHUB_URL" | grep -i "last-modified" | cut -d' ' -f2-); then
|
||||
echo -e "${YELLOW}Warning: Could not fetch last modified date from GitHub. Using existing installer.${NC}"
|
||||
return
|
||||
fi
|
||||
|
||||
local_modified=$(stat -c "%y" "$INSTALLER_PATH" | cut -d' ' -f1-2) || error "Failed to get local modified date"
|
||||
|
||||
if [ "$local_modified" != "$latest_modified" ]; then
|
||||
echo -e "${YELLOW}Installer is outdated. Updating...${NC}"
|
||||
download_installer
|
||||
else
|
||||
echo -e "${GREEN}Installer is up-to-date.${NC}"
|
||||
fi
|
||||
}
|
||||
|
||||
# Find privilege escalation command
|
||||
find_privilege_cmd() {
|
||||
for cmd in "${PRIVILEGE_CMDS[@]}"; do
|
||||
if command -v "$cmd" >/dev/null; then
|
||||
echo "$cmd"
|
||||
return
|
||||
fi
|
||||
done
|
||||
error "Neither sudo nor doas found. Please install one to proceed."
|
||||
}
|
||||
|
||||
# Main execution
|
||||
main() {
|
||||
# Check for debug flag
|
||||
if [[ "${1:-}" == "-debug" ]]; then
|
||||
DEBUG=true
|
||||
> "$LOG_FILE" # Clear previous log
|
||||
debug_log "Debug mode enabled"
|
||||
fi
|
||||
|
||||
debug_log "Starting installation process"
|
||||
check_root
|
||||
check_for_updates
|
||||
|
||||
local priv_cmd
|
||||
priv_cmd=$(find_privilege_cmd)
|
||||
debug_log "Using privilege command: $priv_cmd"
|
||||
|
||||
echo -e "${YELLOW}Running installer with $priv_cmd...${NC}"
|
||||
debug_log "Executing installer: $priv_cmd $INSTALLER_PATH"
|
||||
if ! "$priv_cmd" "$INSTALLER_PATH"; then
|
||||
debug_log "Installer failed"
|
||||
error "Installer failed to run"
|
||||
fi
|
||||
|
||||
debug_log "Installation completed successfully"
|
||||
echo -e "\n${GREEN}Installation completed successfully!${NC}"
|
||||
echo -e "\nCredits:"
|
||||
echo "Original script forked from Vencord"
|
||||
echo "Modified by PhoenixAceVFX & Crxaw for Equicord Updater"
|
||||
echo "Rewrite by PhoenixAceVFX"
|
||||
}
|
||||
|
||||
# Pass arguments to main
|
||||
main "$@"
|
||||
|
|
Loading…
Add table
Reference in a new issue