From 60718b360e8421ccb03207a083c2aafaa6bd0c13 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 3 Aug 2026 03:48:33 -0400 Subject: [PATCH] feat: integrate precompiled hotspot binaries from x64_bin/ via pos network hotspot --- DOC/AGENT_Context_Project.md | 16 +++++-- DOC/POS.md | 13 ++++++ DOC/SCRIPTS.md | 29 +++++++++++- README.md | 1 + bin/pos | 3 +- bin/pos-network-hotspot | 91 ++++++++++++++++++++++++++++++++++++ install.sh | 17 +++++++ preinstall.sh | 2 + x64_bin/wihotspot | 2 +- 9 files changed, 167 insertions(+), 7 deletions(-) create mode 100755 bin/pos-network-hotspot diff --git a/DOC/AGENT_Context_Project.md b/DOC/AGENT_Context_Project.md index 7a8288e..f0c256a 100644 --- a/DOC/AGENT_Context_Project.md +++ b/DOC/AGENT_Context_Project.md @@ -45,6 +45,7 @@ Linux_post_install/ │ ├── pos-system-firewall # Interactive UFW manager (menu-driven, 284 lines) │ ├── pos-ssh-load-keys # Load SSH keys into ssh-agent │ ├── pos-vbox # Disposable Docker-based "VMs" +│ ├── pos-network-hotspot # Wi-Fi hotspot (create_ap + wihotspot-gui) │ ├── flag-reader # Inspect feature flags (list/status/--raw) │ ├── flag-set # Set a feature flag (optionally with a value) │ ├── flag-clear # Unset a feature flag @@ -55,6 +56,12 @@ Linux_post_install/ ├── features/ # User-customizable scripts (installed via --feature) │ └── autostart.sh # Boot-time script (via systemd, flag-gated) │ +├── x64_bin/ # Precompiled binaries, copied to /usr/local/bin on x86_64 +│ ├── create_ap # Wi-Fi AP CLI (bash script) +│ ├── wihotspot # Wrapper → wihotspot-gui +│ └── wihotspot-gui # GTK3 hotspot GUI (x86-64 ELF) +│ # future: arm64_bin/ picked up automatically on aarch64 +│ ├── apps/ # Optional desktop app installers (by category) │ ├── install.sh # Interactive picker / orchestrator │ ├── browsers/ @@ -123,6 +130,7 @@ User runs: ./install.sh [--apps|--full|--feature|--dry-run|--skip |--step ├─ Phase 2: install.sh (requires root) │ └─ Copies bin/* → /usr/local/bin/ (chmod 755) │ └─ Copies lib/common.sh + lib/flags.sh → /usr/local/bin/ (chmod 644) +│ └─ Copies x64_bin/* → /usr/local/bin/ on x86_64 (arm64_bin/ on aarch64) │ └─ [if --feature] Copies features/* → /usr/local/bin/ (asks before overwriting), │ then sets the matching feature flag │ @@ -425,8 +433,8 @@ Use conventional prefixes: `feat:`, `fix:`, `docs:`, `refactor:`, `chore:` | File | Lines | Purpose | |------|-------|---------| -| `install.sh` | 175 | Main orchestrator — 4 phases with CLI flags, `--feature` block | -| `preinstall.sh` | 52 | System packages + yt-dlp + fail2ban | +| `install.sh` | 192 | Main orchestrator — 4 phases with CLI flags, `--feature`, prebuilt arch bins | +| `preinstall.sh` | 54 | System packages + hotspot deps + yt-dlp + fail2ban | | `postinstall.sh` | 97 | fail2ban config, PATH, bash completion, systemd (flag-gated) | | `lib/common.sh` | 121 | Shared library | | `lib/flags.sh` | 60 | Feature flag store (set/clear/is_set/value/list/status) | @@ -434,12 +442,13 @@ Use conventional prefixes: `feat:`, `fix:`, `docs:`, `refactor:`, `chore:` | `bin/flag-set` | 21 | Set a flag (optionally with a value) | | `bin/flag-clear` | 21 | Unset a flag | | `features/autostart.sh` | 14 | Boot-time feature (moved from `bin/`, flag-gated service) | -| `bin/pos` | 145 | CLI dispatcher with smart arg matching + logging | +| `bin/pos` | 146 | CLI dispatcher with smart arg matching + logging | | `bin/pos-docker-compose` | 363 | Largest script — full compose management | | `bin/pos-system-firewall` | 284 | Interactive UFW manager | | `bin/pos-docker-ps` | 127 | Enhanced container overview | | `bin/pos-docker-health` | 109 | Quick health dashboard | | `bin/pos-vbox` | 156 | Docker-based disposable VMs (label-filtered, auto-enter prompt) | +| `bin/pos-network-hotspot` | 91 | Wi-Fi hotspot: `create_ap` (start with background prompt/`--foreground`, stop, status) + `wihotspot-gui` | | `completions/pos.bash` | 118 | Dynamic bash completion | | `apps/install.sh` | 171 | App install/uninstall picker/orchestrator | @@ -453,6 +462,7 @@ Use conventional prefixes: `feat:`, `fix:`, `docs:`, `refactor:`, `chore:` | Add a new app installer | Create `apps/.sh` (auto-discovered) | | Add a feature | Create `features/.sh` (installed on demand via `./install.sh --feature`) | | Add a systemd service | Create `systemd/.service` (auto-installed by postinstall; gate on a flag if it backs a feature) | +| Add a precompiled binary | Drop it in `x64_bin/` (or `arm64_bin/` later) — auto-copied by Phase 2 | | Inspect/set feature flags | `flag-reader`, `flag-set`, `flag-clear` (or source `lib/flags.sh`) | | Modify package list | Edit `PACKAGES` array in `preinstall.sh` | | Change PATH or bash config | Edit `postinstall.sh` | diff --git a/DOC/POS.md b/DOC/POS.md index 99d1f42..cee0265 100644 --- a/DOC/POS.md +++ b/DOC/POS.md @@ -53,6 +53,7 @@ Every non-interactive `pos` invocation logs to `~/.local/share/linux_post_instal | `pos network ip` | `bin/pos-network-ip` | Show interfaces, default route, public IP | None. Public IP via `https://ifconfig.me` (5s timeout) | | `pos network checkport ` | `bin/pos-network-checkport` | Check if a TCP port is open | None. Uses `/dev/tcp` with a 2s timeout; exit 0/1 via OPEN/CLOSED | | `pos network scan [--full] [--retries N]` | `bin/pos-network-scan` | Two-phase nmap scan | See below | +| `pos network hotspot [cmd]` | `bin/pos-network-hotspot` | Wi-Fi hotspot via `create_ap` (CLI) or `wihotspot-gui` (GUI) | Uses the precompiled binaries from `x64_bin/`; see below | **`pos network scan` in detail:** @@ -62,6 +63,18 @@ Every non-interactive `pos` invocation logs to `~/.local/share/linux_post_instal - Auto-raises to `sudo nmap` when possible (root, passwordless sudo, or an interactive terminal with `--full`). - `--retries N` tunes discovery retries (default 1). +**`pos network hotspot` in detail:** + +Backed by the precompiled binaries shipped in `x64_bin/` (see [SCRIPTS.md → x64_bin/](SCRIPTS.md#x64_bin--precompiled-binaries)). Needs root for the CLI commands (uses `sudo`): + +| Command | Behavior | +|---------|----------| +| `pos network hotspot` | Launches the `wihotspot-gui` (GTK3 GUI) | +| `pos network hotspot start [] []` | Asks whether to run in the background; `y` starts `create_ap --daemon` (logs to `/var/log/linux_post_install_hotspot.log`), `n` runs in the foreground (blocks until Ctrl+C) | +| `pos network hotspot start --foreground [] []` | Skips the prompt, runs in the foreground | +| `pos network hotspot stop []` | Stops the running access point via `create_ap --stop`; `` is an interface name or PID, auto-detected if omitted | +| `pos network hotspot status` | Runs `create_ap --list-running` | + ### docker | Command | File | Purpose | Configuration | diff --git a/DOC/SCRIPTS.md b/DOC/SCRIPTS.md index 94292da..dfe23f3 100644 --- a/DOC/SCRIPTS.md +++ b/DOC/SCRIPTS.md @@ -12,6 +12,7 @@ Everything that runs during the bootstrap install: `install.sh`, `preinstall.sh` - [lib/common.sh — shared library](#libcommonsh--shared-library) - [lib/flags.sh — feature flags](#libflagssh--feature-flags) - [features/autostart.sh — boot-time feature](#featuresautostartsh--boot-time-feature) +- [x64_bin/ — precompiled binaries](#x64_bin--precompiled-binaries) --- @@ -35,11 +36,13 @@ The phases: | # | Phase | Script/action | |---|-------|----------------| | 1 | preinstall | `preinstall.sh` — apt packages + yt-dlp | -| 2 | scripts | Copies `bin/*` → `/usr/local/bin/` (755), `lib/common.sh` + `lib/flags.sh` → `/usr/local/bin/` (644). With `--feature`: also installs `features/*` (see below) | +| 2 | scripts | Copies `bin/*` → `/usr/local/bin/` (755), `lib/common.sh` + `lib/flags.sh` → `/usr/local/bin/` (644). Copies precompiled arch binaries from `x64_bin/` (or `arm64_bin/`) → `/usr/local/bin/`. With `--feature`: also installs `features/*` (see below) | | 3 | postinstall | `postinstall.sh` — PATH, completion, SSH keys, systemd | | 4 | scalepoint | Shallow-clones ScaleTail templates to `/usr/local/share/linux_post_install/scale-tail` | | 5 (opt) | apps | `apps/install.sh` when `--apps` (interactive) or `--full` (all, non-interactive) | +**Precompiled arch binaries (Phase 2):** `install.sh` picks the source folder from the machine architecture — `x86_64` → `x64_bin/`, `aarch64`/`arm64` → `arm64_bin/` (added later) — and copies every file in it to `/usr/local/bin/` (755). These are manually-compiled tools not available as internet builds (currently `create_ap`, `wihotspot`, `wihotspot-gui`). Dropping an `arm64_bin/` folder later needs no code change. + **Feature block (Phase 2, only with `--feature`):** for every file in `features/` it copies it to `/usr/local/bin/`. If the destination already exists it asks **"Overwrite existing …? [y/N]"** (default keeps your file), then always sets the feature flag via `flag_set` (name derived as ``). ### Configuration @@ -82,12 +85,14 @@ PACKAGES=( unzip zip rsync htop btop telnet net-tools iputils-ping traceroute tcpdump nmap openssh-client openssh-server ufw fail2ban + hostapd dnsmasq iptables iw ca-certificates gnupg lsb-release python3 python3-pip rclone + libqrencode4 libgtk-3-0 ) ``` -Add or remove package names here. `nmap` and `fail2ban` are used later by `pos network scan` and `postinstall.sh`. +Add or remove package names here. `nmap` and `fail2ban` are used later by `pos network scan` and `postinstall.sh`; `hostapd`, `dnsmasq`, `iptables`, `iw` and the GTK/Qr libs support the precompiled hotspot tools (see [x64_bin/ — precompiled binaries](#x64_bin--precompiled-binaries)). --- @@ -186,3 +191,23 @@ Appends timestamped lines to `~/.autostart.log`: - Log file: `$HOME/.autostart.log` (edit the `LOG` variable at the top). - The script is the one you're *most* likely to customize — this is exactly why it lives in `features/` instead of `bin/`: a plain reinstall never overwrites your edits. + +--- + +## x64_bin/ — precompiled binaries + +**Folder:** `x64_bin/` (future: `arm64_bin/`) +**Purpose:** manually-compiled tools that are **not available as prebuilt binaries on the internet**. `install.sh` copies them verbatim into `/usr/local/bin/` on the matching architecture (see [install.sh — the orchestrator](#installsh--the-orchestrator)). + +### Contents + +| File | Type | Purpose | Runtime deps | +|------|------|---------|--------------| +| `create_ap` | bash script | Create a Wi-Fi access point from the CLI (NAT/Internet sharing) | `hostapd`, `dnsmasq`, `iptables`, `iw` (in `preinstall.sh`) | +| `wihotspot` | POSIX wrapper | Launches `wihotspot-gui` (path points at `/usr/local/bin/`) | — | +| `wihotspot-gui` | ELF x86-64 | GTK3 GUI for the hotspot (QR code via libqrencode) | `libgtk-3-0`, `libqrencode4` | + +### Configuration + +- Managed through the `pos network hotspot` command (see [POS.md → network](POS.md#network)): `hotspot` launches the GUI; `start`/`stop`/`status` wrap `create_ap`. +- Add a future `arm64_bin/` folder with the same filenames and it is installed automatically on `aarch64` machines — no `install.sh` change needed. diff --git a/README.md b/README.md index ea456d5..d109403 100755 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ It is a **personal toolkit** — a bootstrap script, a unified `pos` CLI for eve - 25+ system packages installed automatically - The `pos` CLI: network, Docker, media, system, SSH, and vbox tools +- Wi-Fi hotspot tools (`create_ap`, `wihotspot-gui`) via `pos network hotspot` - 15 optional desktop apps (VS Code, Brave, OBS, Tailscale, …) — pick what you want - 119+ self-hosted services with Tailscale access (Jellyfin, Home Assistant, …) - systemd services for SSH agent and boot-time automation diff --git a/bin/pos b/bin/pos index 78bc185..c5245ba 100755 --- a/bin/pos +++ b/bin/pos @@ -37,7 +37,7 @@ USAGE pos [args] CATEGORIES - network ip | checkport | scan + network ip | checkport | scan | hotspot docker ps | compose media mp3 | mp4 system firewall @@ -48,6 +48,7 @@ EXAMPLES pos network ip Show interfaces, routes, public IP pos network checkport 10.0.0.1:80 Check if a TCP port is open pos network scan 192.168.1.0/24 Fast parallel ping sweep + pos network hotspot Launch wihotspot-gui pos docker ps List containers (health, IPs, ports) pos docker compose ls List available ScaleTail services diff --git a/bin/pos-network-hotspot b/bin/pos-network-hotspot new file mode 100755 index 0000000..0d26aae --- /dev/null +++ b/bin/pos-network-hotspot @@ -0,0 +1,91 @@ +#!/usr/bin/env bash +set -euo pipefail + +LOGFILE=/var/log/linux_post_install_hotspot.log + +usage() { + cat < [] [] + Create an access point; asks whether to run in the + background. Use --foreground to skip the prompt + and block until Ctrl+C. + stop [] Stop the running access point. is an interface + name or PID; if omitted it is detected automatically. + status List running access points + +Examples: + pos network hotspot + pos network hotspot start wlan0 eth0 MyNet mypass + pos network hotspot start --foreground wlan0 eth0 MyNet mypass + pos network hotspot stop + pos network hotspot status + +Background logs: $LOGFILE +EOF + exit 0 +} + +cmd="${1:-}" + +case "$cmd" in + -h|--help) usage ;; + "") exec wihotspot-gui ;; + start) + shift + fg=0 + bg=0 + if [ "${1:-}" = "--foreground" ]; then + fg=1 + shift + fi + [ $# -ge 2 ] || usage + if [ $fg -eq 0 ]; then + read -rp "Run in background? [y/N]: " bg + case "$bg" in + [yY]*) bg=1 ;; + *) bg=0 ;; + esac + fi + if [ $bg -eq 1 ]; then + sudo create_ap --daemon --logfile "$LOGFILE" "$@" + echo "[+] Hotspot started in background" + echo " Log : $LOGFILE" + echo " Status: pos network hotspot status" + echo " Stop : pos network hotspot stop" + else + exec sudo create_ap "$@" + fi + ;; + stop) + shift + id="${1:-}" + if [ -z "$id" ]; then + ids=$(sudo create_ap --list-running | awk 'NF { print $2 }') + if [ -z "$ids" ]; then + echo "No hotspot running." + exit 0 + fi + for id in $ids; do + sudo create_ap --stop "$id" + done + else + sudo create_ap --stop "$id" + fi + ;; + status) + exec sudo create_ap --list-running + ;; + *) + echo "ERROR: Unknown hotspot command '$cmd'" + echo "Run 'pos network hotspot --help' for usage." + exit 1 + ;; +esac diff --git a/install.sh b/install.sh index 86a7c64..1b671fc 100755 --- a/install.sh +++ b/install.sh @@ -114,6 +114,23 @@ if should_run 2 scripts; then run sudo install -m 644 lib/common.sh /usr/local/bin/common.sh run sudo install -m 644 lib/flags.sh /usr/local/bin/flags.sh + # ── Precompiled architecture binaries ───────────────────── + # Manually-compiled binaries (not available on the internet), + # copied straight into /usr/local/bin for the matching arch. + # Drop an arm64_bin/ folder later — it is picked up automatically. + case "$(uname -m)" in + x86_64) prebuilt_dir="x64_bin" ;; + aarch64|arm64) prebuilt_dir="arm64_bin" ;; + *) prebuilt_dir="" ;; + esac + if [ -n "$prebuilt_dir" ] && [ -d "$prebuilt_dir" ]; then + for f in "$prebuilt_dir"/*; do + [ -f "$f" ] || continue + run sudo install -m 755 "$f" /usr/local/bin/ + done + ok "$prebuilt_dir binaries -> /usr/local/bin" + fi + # ── Optional features ────────────────────────────────────── if [ "$RUN_FEATURES" -eq 1 ]; then for f in features/*; do diff --git a/preinstall.sh b/preinstall.sh index 612663e..127d3f2 100755 --- a/preinstall.sh +++ b/preinstall.sh @@ -30,8 +30,10 @@ PACKAGES=( unzip zip rsync htop btop telnet net-tools iputils-ping traceroute tcpdump nmap openssh-client openssh-server ufw fail2ban + hostapd dnsmasq iptables iw ca-certificates gnupg lsb-release python3 python3-pip rclone + libqrencode4 libgtk-3-0 ) spawn "apt update" sudo apt update diff --git a/x64_bin/wihotspot b/x64_bin/wihotspot index 689b2ea..d192842 100755 --- a/x64_bin/wihotspot +++ b/x64_bin/wihotspot @@ -1,4 +1,4 @@ #!/bin/sh # Start wihotspot-gui -/usr/bin/wihotspot-gui +/usr/local/bin/wihotspot-gui