(refactor) Remove obsolete source-copy deploy script
Delete the old scripts/deploy path that installed pobsync into /opt/pobsync/lib with a standalone /opt/pobsync/bin wrapper. Production deployment is now owned by the native systemd installer and updater, so keeping the legacy deploy script would make the supported install story less clear and easier to misuse.
This commit is contained in:
@@ -1,97 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Deploy pobsync runtime into /opt/pobsync without pip/venv.
|
||||
# Copies python package sources into /opt/pobsync/lib and installs a stable entrypoint in /opt/pobsync/bin.
|
||||
|
||||
set -eu
|
||||
|
||||
PREFIX="/opt/pobsync"
|
||||
|
||||
usage() {
|
||||
echo "Usage: $0 [--prefix /opt/pobsync]" >&2
|
||||
exit 2
|
||||
}
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
--prefix)
|
||||
[ $# -ge 2 ] || usage
|
||||
PREFIX="$2"
|
||||
shift 2
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
;;
|
||||
*)
|
||||
echo "Unknown arg: $1" >&2
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Determine repo root from this script location
|
||||
SCRIPT_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)"
|
||||
REPO_ROOT="$(CDPATH= cd -- "${SCRIPT_DIR}/.." && pwd)"
|
||||
|
||||
SRC_PKG="${REPO_ROOT}/src/pobsync"
|
||||
if [ ! -d "${SRC_PKG}" ]; then
|
||||
echo "ERROR: expected python package at ${SRC_PKG}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
BIN_DIR="${PREFIX}/bin"
|
||||
LIB_DIR="${PREFIX}/lib"
|
||||
DST_PKG="${LIB_DIR}/pobsync"
|
||||
BUILD_FILE="${DST_PKG}/_build.txt"
|
||||
|
||||
mkdir -p "${BIN_DIR}" "${LIB_DIR}"
|
||||
|
||||
# Copy code into /opt/pobsync/lib/pobsync
|
||||
# We use rsync if available (clean updates with --delete), otherwise fall back to cp -a.
|
||||
if command -v rsync >/dev/null 2>&1; then
|
||||
rsync -a --delete \
|
||||
--exclude '__pycache__/' \
|
||||
--exclude '*.pyc' \
|
||||
--exclude '*.pyo' \
|
||||
--exclude '*.pyd' \
|
||||
"${SRC_PKG}/" "${DST_PKG}/"
|
||||
else
|
||||
# Fallback: wipe + copy
|
||||
rm -rf "${DST_PKG}"
|
||||
mkdir -p "${DST_PKG}"
|
||||
cp -a "${SRC_PKG}/." "${DST_PKG}/"
|
||||
fi
|
||||
|
||||
# Write build info (best-effort)
|
||||
GIT_SHA="unknown"
|
||||
if command -v git >/dev/null 2>&1 && [ -d "${REPO_ROOT}/.git" ]; then
|
||||
GIT_SHA="$(cd "${REPO_ROOT}" && git rev-parse HEAD 2>/dev/null || echo unknown)"
|
||||
fi
|
||||
|
||||
NOW_UTC="$(date -u +"%Y-%m-%dT%H:%M:%SZ" 2>/dev/null || echo unknown)"
|
||||
{
|
||||
echo "deployed_at_utc=${NOW_UTC}"
|
||||
echo "git_sha=${GIT_SHA}"
|
||||
echo "repo_root=${REPO_ROOT}"
|
||||
} > "${BUILD_FILE}"
|
||||
|
||||
# Install stable entrypoint that always runs code from /opt/pobsync/lib
|
||||
WRAPPER="${BIN_DIR}/pobsync"
|
||||
cat > "${WRAPPER}" <<EOF
|
||||
#!/bin/sh
|
||||
# managed-by=pobsync deploy
|
||||
set -eu
|
||||
|
||||
PREFIX="${PREFIX}"
|
||||
export PYTHONPATH="\${PREFIX}/lib"
|
||||
export PYTHONUNBUFFERED=1
|
||||
|
||||
exec /usr/bin/python3 -m pobsync "\$@"
|
||||
EOF
|
||||
|
||||
chmod 0755 "${WRAPPER}"
|
||||
|
||||
echo "OK"
|
||||
echo "- deployed package to ${DST_PKG}"
|
||||
echo "- wrote build info ${BUILD_FILE}"
|
||||
echo "- installed entrypoint ${WRAPPER}"
|
||||
|
||||
Reference in New Issue
Block a user