Add update scripts
This commit is contained in:
@@ -0,0 +1,49 @@
|
|||||||
|
@echo off
|
||||||
|
setlocal EnableDelayedExpansion
|
||||||
|
|
||||||
|
set "REPO_URL=https://zerolands.duckdns.org/git/D3SXX/Minecraft-Server-1.21.1-Mods.git"
|
||||||
|
set "BRANCH=main"
|
||||||
|
|
||||||
|
:: ─── Check / install git ─────────────────────────────────────────────────────
|
||||||
|
where git >nul 2>&1
|
||||||
|
if %errorlevel% neq 0 (
|
||||||
|
echo git not found. Installing via winget...
|
||||||
|
winget install --id Git.Git -e --source winget
|
||||||
|
if %errorlevel% neq 0 (
|
||||||
|
echo ERROR: winget failed to install git. Install git manually and re-run.
|
||||||
|
pause
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
:: Reload PATH so git is available in the same session
|
||||||
|
for /f "tokens=*" %%i in ('where git 2^>nul') do set "GIT_EXE=%%i"
|
||||||
|
if "!GIT_EXE!"=="" (
|
||||||
|
echo git was installed but is not yet on PATH. Please restart this script.
|
||||||
|
pause
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
:: ─── Move to the directory containing this script ────────────────────────────
|
||||||
|
cd /d "%~dp0"
|
||||||
|
|
||||||
|
:: ─── Initialise repo if .git is missing ──────────────────────────────────────
|
||||||
|
if not exist ".git\" (
|
||||||
|
echo Initialising git repository...
|
||||||
|
git init
|
||||||
|
git remote add origin "%REPO_URL%"
|
||||||
|
) else (
|
||||||
|
git remote set-url origin "%REPO_URL%" 2>nul || git remote add origin "%REPO_URL%"
|
||||||
|
)
|
||||||
|
|
||||||
|
:: ─── Full reset ────────────────────────────────
|
||||||
|
echo Fetching latest mods from %REPO_URL% ...
|
||||||
|
git fetch --all --prune
|
||||||
|
|
||||||
|
echo Resetting to origin/%BRANCH% ...
|
||||||
|
git checkout -B "%BRANCH%" "origin/%BRANCH%" --
|
||||||
|
git reset --hard "origin/%BRANCH%"
|
||||||
|
git clean -fd
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo Mods updated successfully.
|
||||||
|
pause
|
||||||
Executable
+57
@@ -0,0 +1,57 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
REPO_URL="https://zerolands.duckdns.org/git/D3SXX/Minecraft-Server-1.21.1-Mods.git"
|
||||||
|
BRANCH="main"
|
||||||
|
|
||||||
|
# ─── Install git if missing ───────────────────────────────────────────────────
|
||||||
|
install_git() {
|
||||||
|
if command -v apt-get &>/dev/null; then
|
||||||
|
sudo apt-get update -qq && sudo apt-get install -y git
|
||||||
|
elif command -v dnf &>/dev/null; then
|
||||||
|
sudo dnf install -y git
|
||||||
|
elif command -v yum &>/dev/null; then
|
||||||
|
sudo yum install -y git
|
||||||
|
elif command -v pacman &>/dev/null; then
|
||||||
|
sudo pacman -Sy --noconfirm git
|
||||||
|
elif command -v zypper &>/dev/null; then
|
||||||
|
sudo zypper install -y git
|
||||||
|
elif command -v apk &>/dev/null; then
|
||||||
|
sudo apk add --no-cache git
|
||||||
|
elif command -v brew &>/dev/null; then
|
||||||
|
brew install git
|
||||||
|
else
|
||||||
|
echo "ERROR: Could not detect a supported package manager. Install git manually."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
if ! command -v git &>/dev/null; then
|
||||||
|
echo "git not found. Attempting to install..."
|
||||||
|
install_git
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ─── Move to the directory containing this script ────────────────────────────
|
||||||
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
cd "$SCRIPT_DIR"
|
||||||
|
|
||||||
|
# ─── Initialise repo if .git is missing ──────────────────────────────────────
|
||||||
|
if [ ! -d ".git" ]; then
|
||||||
|
echo "Initialising git repository..."
|
||||||
|
git init
|
||||||
|
git remote add origin "$REPO_URL"
|
||||||
|
else
|
||||||
|
# Ensure remote URL is correct
|
||||||
|
git remote set-url origin "$REPO_URL" 2>/dev/null || git remote add origin "$REPO_URL"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ─── Full reset ────────────────────────────────
|
||||||
|
echo "Fetching latest mods from $REPO_URL ..."
|
||||||
|
git fetch --all --prune
|
||||||
|
|
||||||
|
echo "Resetting to origin/$BRANCH ..."
|
||||||
|
git checkout -B "$BRANCH" "origin/$BRANCH" --
|
||||||
|
git reset --hard "origin/$BRANCH"
|
||||||
|
git clean -fd
|
||||||
|
|
||||||
|
echo "Mods updated successfully."
|
||||||
Reference in New Issue
Block a user