Implement automatic page scaling feature with viewport adjustments
This commit is contained in:
27
chromium-setup/emmc-provisioning/network-client/README.md
Normal file
27
chromium-setup/emmc-provisioning/network-client/README.md
Normal file
@@ -0,0 +1,27 @@
|
||||
# Network provisioning client
|
||||
|
||||
When a reTerminal (or any Pi) has **network boot** enabled and boots over the network, it can register with the provisioning dashboard and then perform **Deploy** (pull golden image and write to eMMC) or **Backup** (read eMMC and upload to the server) when you choose the action in the dashboard.
|
||||
|
||||
## Flow
|
||||
|
||||
1. Device boots (e.g. from NFS or a minimal netboot root).
|
||||
2. Run **provisioning-client.sh** with `PROVISIONING_SERVER` set to the dashboard URL (e.g. `http://<LXC-IP>:5000`).
|
||||
3. The script registers (MAC + IP) and polls `GET /api/device-action-poll?mac=...`.
|
||||
4. In the dashboard, the device appears under "Device detected (Network)". You click **Backup** or **Deploy**.
|
||||
5. The device gets the action from the next poll: **Deploy** → it downloads `GET /api/golden-image` and runs `dd of=/dev/mmcblk0`. **Backup** → it runs `dd if=/dev/mmcblk0` and POSTs to `POST /api/backup-upload?mac=...`.
|
||||
|
||||
## Usage on the device
|
||||
|
||||
```bash
|
||||
export PROVISIONING_SERVER=http://192.168.1.10:5000 # dashboard URL
|
||||
./provisioning-client.sh
|
||||
```
|
||||
|
||||
- **EMMC_DEV**: override eMMC block device (default `/dev/mmcblk0`).
|
||||
|
||||
The device must have network access to the dashboard and (for deploy) the dashboard must have `golden.img` in its provisioning directory.
|
||||
|
||||
## Integrating into a netboot environment
|
||||
|
||||
- Add this script to your netboot root (e.g. NFS-mounted filesystem or initramfs).
|
||||
- Run it from a first-boot or default login script so that when the device boots from the network it registers and waits for an action. Optionally run it as a systemd service that starts after network is up.
|
||||
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env bash
|
||||
# Run this script on a reTerminal that has booted over the network (or any Pi with network).
|
||||
# It registers with the provisioning dashboard and waits for Backup or Deploy, then performs the action.
|
||||
# Usage: PROVISIONING_SERVER=http://192.168.1.10:5000 ./provisioning-client.sh
|
||||
# Requires: curl, and for deploy/backup: enough space and write access to eMMC (e.g. /dev/mmcblk0).
|
||||
|
||||
set -e
|
||||
BASE_URL="${PROVISIONING_SERVER:-http://192.168.1.10:5000}"
|
||||
BASE_URL="${BASE_URL%/}"
|
||||
EMMC_DEV="${EMMC_DEV:-/dev/mmcblk0}"
|
||||
MAC=$(cat /sys/class/net/eth0/address 2>/dev/null || cat /sys/class/net/enp*/address 2>/dev/null | head -1 || echo "unknown")
|
||||
IP=$(hostname -I 2>/dev/null | awk '{print $1}' || echo "")
|
||||
|
||||
echo "Registering with $BASE_URL (MAC=$MAC IP=$IP)..."
|
||||
curl -s -X POST -H "Content-Type: application/json" -d "{\"mac\":\"$MAC\",\"ip\":\"$IP\"}" "$BASE_URL/api/register-device" || true
|
||||
|
||||
echo "Polling for action (Backup or Deploy)..."
|
||||
while true; do
|
||||
resp=$(curl -s "$BASE_URL/api/device-action-poll?mac=$MAC" 2>/dev/null || echo '{"action":"wait"}')
|
||||
action=$(echo "$resp" | grep -o '"action":"[^"]*"' | cut -d'"' -f4)
|
||||
url=$(echo "$resp" | grep -o '"url":"[^"]*"' | cut -d'"' -f4)
|
||||
upload_url=$(echo "$resp" | grep -o '"upload_url":"[^"]*"' | cut -d'"' -f4)
|
||||
|
||||
if [[ "$action" == "deploy" && -n "$url" ]]; then
|
||||
echo "Deploy: downloading image and writing to $EMMC_DEV..."
|
||||
if [[ ! -b "$EMMC_DEV" ]]; then
|
||||
echo "Error: $EMMC_DEV not found"
|
||||
sleep 10
|
||||
continue
|
||||
fi
|
||||
curl -sL "$url" | dd of="$EMMC_DEV" bs=4M status=progress conv=fsync
|
||||
echo "Deploy done. Reboot to run from eMMC."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ "$action" == "backup" && -n "$upload_url" ]]; then
|
||||
echo "Backup: reading $EMMC_DEV and uploading..."
|
||||
if [[ ! -b "$EMMC_DEV" ]]; then
|
||||
echo "Error: $EMMC_DEV not found"
|
||||
sleep 10
|
||||
continue
|
||||
fi
|
||||
dd if="$EMMC_DEV" bs=4M status=progress 2>/dev/null | curl -s -X POST -T - "$upload_url"
|
||||
echo "Backup done."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
sleep 5
|
||||
done
|
||||
Reference in New Issue
Block a user