3x-ui/scripts/common.sh

20 lines
333 B
Bash
Executable file

#!/usr/bin/env bash
set -euo pipefail
require_cmd() {
local cmd="$1"
if ! command -v "${cmd}" >/dev/null 2>&1; then
echo "Error: ${cmd} is required but not installed."
exit 1
fi
}
script_dir() {
cd "$(dirname "${BASH_SOURCE[0]}")" && pwd
}
repo_root() {
local dir
dir="$(script_dir)"
cd "${dir}/.." && pwd
}