#!/usr/bin/env bash # Pathify one-shot installer for an Oracle Always-Free Ubuntu VM (ARM or x86). # Usage (on the VM): curl -sL | sudo bash -s -- YOUR_ACCESS_CODE set -euo pipefail PASSCODE="${1:-pathify123}" APP=/opt/pathify HF=https://huggingface.co/spaces/Shubhambhandari/Pathify echo "[pathify] 0/5 checking memory, adding swap on small boxes..." MEM_MB=$(free -m | awk '/^Mem:/{print $2}') if [ "${MEM_MB:-0}" -lt 4000 ] && [ ! -f /swapfile ]; then echo "[pathify] low RAM (${MEM_MB}MB) -> creating 4G swap" fallocate -l 4G /swapfile || dd if=/dev/zero of=/swapfile bs=1M count=4096 chmod 600 /swapfile && mkswap /swapfile && swapon /swapfile grep -q '/swapfile' /etc/fstab || echo '/swapfile none swap sw 0 0' >> /etc/fstab fi # On a small box, skip the demo cohort so boot is light. if [ "${MEM_MB:-0}" -lt 4000 ]; then CASES=0; SLIDES=0; else CASES=24; SLIDES=3; fi echo "[pathify] 1/5 installing system packages..." export DEBIAN_FRONTEND=noninteractive apt-get update -y apt-get install -y python3-pip python3-venv git curl iptables-persistent echo "[pathify] 2/5 fetching the app code from Hugging Face..." rm -rf /tmp/hf_src git clone --depth 1 "$HF" /tmp/hf_src mkdir -p "$APP" cp -r /tmp/hf_src/backend /tmp/hf_src/frontend /tmp/hf_src/pathqa "$APP"/ echo "[pathify] 3/5 downloading the trained model (44 MB)..." curl -L -o "$APP/model.pt" "$HF/resolve/main/model.pt" echo "[pathify] 4/5 building python env + torch (several minutes)..." python3 -m venv "$APP/venv" "$APP/venv/bin/pip" install --upgrade pip -q "$APP/venv/bin/pip" install -q torch torchvision pillow numpy h5py mkdir -p "$APP/data/feedback" echo "[pathify] 5/5 creating the service + opening the port..." cat >/etc/systemd/system/pathify.service <