stealth
This commit is contained in:
61
podman-run.sh
Executable file
61
podman-run.sh
Executable file
@@ -0,0 +1,61 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
# Podman helper for local-page-archiver with headful Chromium support.
|
||||
# Usage:
|
||||
# ./podman-run.sh archive <URL> [options]
|
||||
# ./podman-run.sh headful-archive <URL> [options]
|
||||
|
||||
IMAGE_NAME="local-page-archiver"
|
||||
ARCHIVE_DIR="${ARCHIVE_DIR:-$(pwd)/archives}"
|
||||
|
||||
build_image() {
|
||||
echo "Building ${IMAGE_NAME}..."
|
||||
podman build -t "${IMAGE_NAME}" .
|
||||
}
|
||||
|
||||
run_headless() {
|
||||
mkdir -p "${ARCHIVE_DIR}"
|
||||
podman run --rm \
|
||||
-e "ARCHIVE_PATH=/archives" \
|
||||
-v "${ARCHIVE_DIR}:/archives:Z" \
|
||||
"${IMAGE_NAME}" \
|
||||
"$@"
|
||||
}
|
||||
|
||||
run_headful() {
|
||||
mkdir -p "${ARCHIVE_DIR}"
|
||||
podman run --rm \
|
||||
--entrypoint sh \
|
||||
-e "ARCHIVE_PATH=/archives" \
|
||||
-e "DISPLAY=:99" \
|
||||
-v "${ARCHIVE_DIR}:/archives:Z" \
|
||||
-p "5901:5900" \
|
||||
"${IMAGE_NAME}" \
|
||||
-c "
|
||||
apt-get update -qq && apt-get install -y -qq x11vnc xvfb >/dev/null 2>&1 &&
|
||||
Xvfb :99 -screen 0 1366x768x24 >/dev/null 2>&1 &
|
||||
x11vnc -display :99 -nopw -forever >/dev/null 2>&1 &
|
||||
sleep 2 &&
|
||||
node src/cli.mjs $(printf '%q ' "$@")
|
||||
"
|
||||
}
|
||||
|
||||
if ! podman image exists "${IMAGE_NAME}"; then
|
||||
build_image
|
||||
fi
|
||||
|
||||
case "${1:-}" in
|
||||
headful-archive)
|
||||
shift
|
||||
# Prepend 'archive' so the user doesn't have to type it twice
|
||||
set -- archive "$@"
|
||||
run_headful "$@"
|
||||
;;
|
||||
archive|help)
|
||||
run_headless "$@"
|
||||
;;
|
||||
*)
|
||||
run_headless "$@"
|
||||
;;
|
||||
esac
|
||||
Reference in New Issue
Block a user