Files
2026-05-17 14:32:43 +03:00

39 lines
1.1 KiB
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# Каталог репозитория (package.json + по возможности .git)
# Переопределение: SHOP_ROOT=/opt/shop/shop10
_resolve_shop_root() {
local d
for d in \
"${SHOP_ROOT:-}" \
"$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" \
"/opt/shop" \
"/opt/shop/app"; do
[ -z "$d" ] && continue
[ -f "${d}/package.json" ] && [ -d "${d}/.git" ] && SHOP_ROOT="$d" && return 0
done
for d in \
"${SHOP_ROOT:-}" \
"$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" \
"/opt/shop" \
"/opt/shop/app"; do
[ -z "$d" ] && continue
[ -f "${d}/package.json" ] && SHOP_ROOT="$d" && return 0
done
return 1
}
if ! _resolve_shop_root; then
echo "Ошибка: не найден каталог Shop (нет package.json)."
echo " export SHOP_ROOT=/opt/shop # каталог с package.json"
echo " git clone <URL-репозитория> \"\$SHOP_ROOT\""
echo " SHOP_ROOT=\$SHOP_ROOT bash scripts/server-update.sh"
exit 1
fi
export SHOP_ROOT
cd "$SHOP_ROOT"
if [ -d "$SHOP_ROOT/.git" ]; then
git config --global --add safe.directory "$SHOP_ROOT" 2>/dev/null || true
fi