Files
omv-dijiang/bin/update
T
2026-03-05 13:33:05 +08:00

34 lines
844 B
Bash
Executable File

#!/bin/sh
set -e
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
ROOT="$(dirname "$SCRIPT_DIR")"
SING_BOX="$ROOT/works/sing-box"
# defaults
REPO_URL="git@git.inker.bot:arknights/sing-box.git"
UPSTREAM_BRANCH="main"
CONFIG="$ROOT/works/config"
if [ -f "$CONFIG" ]; then
. "$CONFIG"
fi
if [ -d "$SING_BOX/.git" ]; then
echo "Updating sing-box..."
git -C "$SING_BOX" fetch --all
if [ -n "$UPSTREAM_BRANCH" ]; then
git -C "$SING_BOX" checkout "$UPSTREAM_BRANCH"
fi
git -C "$SING_BOX" pull
else
echo "Cloning sing-box..."
if [ -n "$UPSTREAM_BRANCH" ]; then
git clone -b "$UPSTREAM_BRANCH" "$REPO_URL" "$SING_BOX"
else
git clone "$REPO_URL" "$SING_BOX"
fi
fi
echo "Done. Version: $(git -C "$SING_BOX" describe --tags --always 2>/dev/null || git -C "$SING_BOX" rev-parse --short HEAD)"