Install the extension from the update server during setup
Both installers ended by telling you to load the folder unpacked, which is the one install that can never update itself. They now offer the policy install as a last step instead, and only fall back to those instructions when it is declined or fails. Windows writes to the user's own policy hive rather than HKLM, so the step needs no elevation and no separate admin shell; -Scope Machine is still there for every-account installs. Linux gets the counterpart script — a managed policy file under /etc, which is root-only because Chrome reads policy from nowhere else on that platform. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
035f93d220
commit
b9da419ebc
@@ -132,14 +132,21 @@ pick it up from the server.
|
|||||||
select the `extension` folder.
|
select the `extension` folder.
|
||||||
|
|
||||||
That is the development install. On a machine that just runs trades, install it
|
That is the development install. On a machine that just runs trades, install it
|
||||||
from our own update server instead — one elevated command, and Chrome then keeps
|
from our own update server instead, and Chrome keeps it updated by itself — the
|
||||||
it updated by itself:
|
setup scripts offer this as their last step, and it can be run on its own at any
|
||||||
|
time:
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
powershell -NoProfile -ExecutionPolicy Bypass -File scripts\install-extension-policy.ps1
|
powershell -NoProfile -ExecutionPolicy Bypass -File scripts\install-extension-policy.ps1
|
||||||
```
|
```
|
||||||
|
|
||||||
See [deploy/README.md](deploy/README.md). Either way the extension notices when
|
```bash
|
||||||
|
sudo scripts/install-extension-policy.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
No administrator rights on Windows, where it goes into the user's own policy
|
||||||
|
hive; root on Linux, where Chrome only reads policy from `/etc`. See
|
||||||
|
[deploy/README.md](deploy/README.md). Either way the extension notices when
|
||||||
the dashboard is running newer code than it is: a policy install asks Chrome to
|
the dashboard is running newer code than it is: a policy install asks Chrome to
|
||||||
fetch the new CRX, an unpacked one reloads itself from disk. Clicking the reload
|
fetch the new CRX, an unpacked one reloads itself from disk. Clicking the reload
|
||||||
icon on its card still works and is the thing to try when something looks
|
icon on its card still works and is the thing to try when something looks
|
||||||
|
|||||||
+16
-4
@@ -81,15 +81,27 @@ version than the one it is running.
|
|||||||
|
|
||||||
## Installing it on a machine
|
## Installing it on a machine
|
||||||
|
|
||||||
From an elevated PowerShell on the Windows box:
|
`setup-windows.bat` and `setup-linux.sh` both offer this as their last step, so
|
||||||
|
a fresh instance needs nothing extra. To do it by hand, or on a machine that was
|
||||||
|
set up before this existed:
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
powershell -NoProfile -ExecutionPolicy Bypass -File scripts\install-extension-policy.ps1
|
powershell -NoProfile -ExecutionPolicy Bypass -File scripts\install-extension-policy.ps1
|
||||||
```
|
```
|
||||||
|
|
||||||
Then remove the unpacked copy from `chrome://extensions` — it now has the same
|
```bash
|
||||||
id, and Chrome will not load both — and restart Chrome. `-Remove` undoes it;
|
sudo scripts/install-extension-policy.sh
|
||||||
`-Browser Edge` or `-Browser Brave` writes the same entry for those instead.
|
```
|
||||||
|
|
||||||
|
The Windows script writes to the current user's policy hive and needs no
|
||||||
|
elevation; `-Scope Machine` covers every account on the box and does need an
|
||||||
|
elevated shell. Linux has no per-user equivalent — Chrome only reads managed
|
||||||
|
policy from `/etc` — so that one is root-only and machine-wide. Both take
|
||||||
|
`-Remove` / `--remove`, and the Windows one takes `-Browser Edge` or
|
||||||
|
`-Browser Brave`.
|
||||||
|
|
||||||
|
Afterwards, remove the unpacked copy from `chrome://extensions` — it now has the
|
||||||
|
same id, and Chrome will not load both — and restart the browser.
|
||||||
|
|
||||||
Development still works the old way: load `extension/` unpacked on a machine
|
Development still works the old way: load `extension/` unpacked on a machine
|
||||||
with no policy entry. It keeps the same id (that is what `key` in the manifest
|
with no policy entry. It keeps the same id (that is what `key` in the manifest
|
||||||
|
|||||||
@@ -3,29 +3,38 @@
|
|||||||
Install the AutoFirmer extension from our own update server, via policy.
|
Install the AutoFirmer extension from our own update server, via policy.
|
||||||
|
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
Chrome will not side-load an extension on Windows, and it will not update an
|
Chrome will not side-load an extension on Windows — dropping a CRX on
|
||||||
unpacked one. The supported way to run an extension you host yourself is an
|
chrome://extensions is refused — and it will not update an unpacked one. The
|
||||||
enterprise policy: ExtensionInstallForcelist names the extension id and the
|
supported way to run an extension you host yourself is a policy:
|
||||||
update manifest, and from then on Chrome installs it, keeps it updated on its
|
ExtensionInstallForcelist names the extension id and the update manifest, and
|
||||||
own schedule, and re-installs it if it goes missing.
|
from then on Chrome installs it, keeps it updated on its own schedule, and
|
||||||
|
re-installs it if it goes missing.
|
||||||
|
|
||||||
Needs an elevated PowerShell — the policy lives under HKLM.
|
Defaults to the current user's policy hive, which needs no elevation.
|
||||||
|
-Scope Machine writes to HKLM instead, for every account on the box; that
|
||||||
|
one does need an elevated shell. Where both exist, HKLM wins.
|
||||||
|
|
||||||
After this runs:
|
After this runs:
|
||||||
* Remove the unpacked copy from chrome://extensions. It has the same id
|
* Remove the unpacked copy from chrome://extensions. It has the same id
|
||||||
now, and Chrome will not load both.
|
now, and Chrome will not load both.
|
||||||
* Restart Chrome, or open chrome://policy and press "Reload policies".
|
* Restart Chrome, or open chrome://policy and press "Reload policies".
|
||||||
* A force-installed extension cannot be disabled or removed from the
|
* A force-installed extension cannot be disabled or removed from the
|
||||||
extensions page. Re-run this with -Remove to take it off.
|
extensions page. Re-run with -Remove to take it off.
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
powershell -NoProfile -ExecutionPolicy Bypass -File scripts\install-extension-policy.ps1
|
powershell -NoProfile -ExecutionPolicy Bypass -File scripts\install-extension-policy.ps1
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
powershell -NoProfile -ExecutionPolicy Bypass -File scripts\install-extension-policy.ps1 -Scope Machine -Browser Edge
|
||||||
#>
|
#>
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param(
|
param(
|
||||||
[ValidateSet('Chrome', 'Edge', 'Brave')]
|
[ValidateSet('Chrome', 'Edge', 'Brave')]
|
||||||
[string]$Browser = 'Chrome',
|
[string]$Browser = 'Chrome',
|
||||||
|
|
||||||
|
[ValidateSet('User', 'Machine')]
|
||||||
|
[string]$Scope = 'User',
|
||||||
|
|
||||||
# Derived from the signing key on the droplet. It only changes if the key does.
|
# Derived from the signing key on the droplet. It only changes if the key does.
|
||||||
[string]$Id = 'lkjbblagjjbldlkeaaffhiopdlhniaan',
|
[string]$Id = 'lkjbblagjjbldlkeaaffhiopdlhniaan',
|
||||||
|
|
||||||
@@ -36,23 +45,27 @@ param(
|
|||||||
|
|
||||||
$ErrorActionPreference = 'Stop'
|
$ErrorActionPreference = 'Stop'
|
||||||
|
|
||||||
$roots = @{
|
$vendors = @{
|
||||||
Chrome = 'HKLM:\SOFTWARE\Policies\Google\Chrome'
|
Chrome = 'Google\Chrome'
|
||||||
Edge = 'HKLM:\SOFTWARE\Policies\Microsoft\Edge'
|
Edge = 'Microsoft\Edge'
|
||||||
Brave = 'HKLM:\SOFTWARE\Policies\BraveSoftware\Brave'
|
Brave = 'BraveSoftware\Brave'
|
||||||
}
|
}
|
||||||
|
|
||||||
$identity = [Security.Principal.WindowsIdentity]::GetCurrent()
|
$hive = if ($Scope -eq 'Machine') { 'HKLM:' } else { 'HKCU:' }
|
||||||
if (-not ([Security.Principal.WindowsPrincipal]$identity).IsInRole(
|
|
||||||
[Security.Principal.WindowsBuiltInRole]::Administrator)) {
|
if ($Scope -eq 'Machine') {
|
||||||
throw 'Run this from an elevated PowerShell — the policy key is under HKLM.'
|
$identity = [Security.Principal.WindowsIdentity]::GetCurrent()
|
||||||
|
if (-not ([Security.Principal.WindowsPrincipal]$identity).IsInRole(
|
||||||
|
[Security.Principal.WindowsBuiltInRole]::Administrator)) {
|
||||||
|
throw 'Run this from an elevated PowerShell for -Scope Machine, or drop the flag to install it for this user only.'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$key = Join-Path $roots[$Browser] 'ExtensionInstallForcelist'
|
$key = "$hive\SOFTWARE\Policies\$($vendors[$Browser])\ExtensionInstallForcelist"
|
||||||
$entry = "$Id;$UpdateUrl"
|
$entry = "$Id;$UpdateUrl"
|
||||||
|
|
||||||
if ($Remove) {
|
if ($Remove) {
|
||||||
if (-not (Test-Path $key)) { Write-Host "Nothing to remove — no forcelist for $Browser."; exit 0 }
|
if (-not (Test-Path $key)) { Write-Host "Nothing to remove — no $Scope forcelist for $Browser."; exit 0 }
|
||||||
$props = Get-ItemProperty $key
|
$props = Get-ItemProperty $key
|
||||||
$found = $false
|
$found = $false
|
||||||
foreach ($name in ($props.PSObject.Properties.Name | Where-Object { $_ -notlike 'PS*' })) {
|
foreach ($name in ($props.PSObject.Properties.Name | Where-Object { $_ -notlike 'PS*' })) {
|
||||||
@@ -62,7 +75,7 @@ if ($Remove) {
|
|||||||
$found = $true
|
$found = $true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (-not $found) { Write-Host "Nothing to remove — $Id was not in the $Browser forcelist." }
|
if (-not $found) { Write-Host "Nothing to remove — $Id was not in the $Browser $Scope forcelist." }
|
||||||
Write-Host "`nRestart $Browser to let the change take effect."
|
Write-Host "`nRestart $Browser to let the change take effect."
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
@@ -78,15 +91,16 @@ $existing = $props.PSObject.Properties |
|
|||||||
|
|
||||||
if ($existing) {
|
if ($existing) {
|
||||||
Set-ItemProperty -Path $key -Name $existing.Name -Value $entry
|
Set-ItemProperty -Path $key -Name $existing.Name -Value $entry
|
||||||
Write-Host "Updated $Browser forcelist entry $($existing.Name):"
|
Write-Host "Updated the $Browser $Scope forcelist entry $($existing.Name):"
|
||||||
} else {
|
} else {
|
||||||
$used = $props.PSObject.Properties.Name |
|
$used = $props.PSObject.Properties.Name |
|
||||||
Where-Object { $_ -match '^\d+$' } | ForEach-Object { [int]$_ }
|
Where-Object { $_ -match '^\d+$' } | ForEach-Object { [int]$_ }
|
||||||
$slot = if ($used) { (($used | Measure-Object -Maximum).Maximum + 1) } else { 1 }
|
$slot = if ($used) { (($used | Measure-Object -Maximum).Maximum + 1) } else { 1 }
|
||||||
New-ItemProperty -Path $key -Name "$slot" -Value $entry -PropertyType String -Force | Out-Null
|
New-ItemProperty -Path $key -Name "$slot" -Value $entry -PropertyType String -Force | Out-Null
|
||||||
Write-Host "Added $Browser forcelist entry ${slot}:"
|
Write-Host "Added $Browser $Scope forcelist entry ${slot}:"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Write-Host " $key"
|
||||||
Write-Host " $entry"
|
Write-Host " $entry"
|
||||||
Write-Host @"
|
Write-Host @"
|
||||||
|
|
||||||
|
|||||||
Executable
+82
@@ -0,0 +1,82 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Install the AutoFirmer extension from our own update server, via policy.
|
||||||
|
#
|
||||||
|
# The Linux counterpart to install-extension-policy.ps1. Chrome reads managed
|
||||||
|
# policy from JSON files under /etc, so unlike Windows there is no per-user
|
||||||
|
# option here — it needs root, and it applies to everyone on the machine.
|
||||||
|
#
|
||||||
|
# sudo scripts/install-extension-policy.sh # install
|
||||||
|
# sudo scripts/install-extension-policy.sh --remove # take it back off
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
ID="${EXTENSION_ID:-lkjbblagjjbldlkeaaffhiopdlhniaan}"
|
||||||
|
UPDATE_URL="${EXTENSION_UPDATE_URL:-https://ext.juicerroom.com/updates.xml}"
|
||||||
|
FILE=autofirmer.json
|
||||||
|
|
||||||
|
REMOVE=0
|
||||||
|
[ "${1:-}" = "--remove" ] && REMOVE=1
|
||||||
|
|
||||||
|
info() { printf ' %s\n' "$1"; }
|
||||||
|
fail() { printf '\n\033[1;31mERROR: %s\033[0m\n' "$1" >&2; exit 1; }
|
||||||
|
|
||||||
|
[ "$(id -u)" -eq 0 ] || fail "run this with sudo — Chrome only reads policy from /etc"
|
||||||
|
|
||||||
|
# Every Chromium-family browser reads the same policy format from its own
|
||||||
|
# directory. Only the ones actually installed are touched: creating the
|
||||||
|
# directory for a browser that is not there would do nothing but confuse
|
||||||
|
# whoever finds it later.
|
||||||
|
CANDIDATES="
|
||||||
|
/etc/opt/chrome/policies/managed
|
||||||
|
/etc/chromium/policies/managed
|
||||||
|
/etc/chromium-browser/policies/managed
|
||||||
|
/etc/opt/edge/policies/managed
|
||||||
|
/etc/brave/policies/managed
|
||||||
|
"
|
||||||
|
|
||||||
|
touched=0
|
||||||
|
for dir in $CANDIDATES; do
|
||||||
|
parent=$(dirname "$(dirname "$dir")") # e.g. /etc/opt/chrome
|
||||||
|
[ -d "$parent" ] || [ -d "$dir" ] || continue
|
||||||
|
|
||||||
|
if [ "$REMOVE" -eq 1 ]; then
|
||||||
|
if [ -f "$dir/$FILE" ]; then
|
||||||
|
rm -f "$dir/$FILE"
|
||||||
|
info "removed $dir/$FILE"
|
||||||
|
touched=$((touched + 1))
|
||||||
|
fi
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p "$dir"
|
||||||
|
# Its own file rather than an edit of someone else's: Chrome merges every
|
||||||
|
# JSON in this directory, so a separate file cannot corrupt a policy set by
|
||||||
|
# something else. Two files setting ExtensionInstallForcelist would collide,
|
||||||
|
# which is worth knowing if this machine is centrally managed.
|
||||||
|
cat > "$dir/$FILE" <<JSON
|
||||||
|
{
|
||||||
|
"ExtensionInstallForcelist": ["$ID;$UPDATE_URL"]
|
||||||
|
}
|
||||||
|
JSON
|
||||||
|
chmod 644 "$dir/$FILE"
|
||||||
|
info "wrote $dir/$FILE"
|
||||||
|
touched=$((touched + 1))
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "$touched" -eq 0 ]; then
|
||||||
|
if [ "$REMOVE" -eq 1 ]; then
|
||||||
|
info "nothing to remove"
|
||||||
|
else
|
||||||
|
fail "found no Chrome, Chromium, Edge or Brave installation to configure"
|
||||||
|
fi
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo
|
||||||
|
if [ "$REMOVE" -eq 1 ]; then
|
||||||
|
info "Restart the browser to let the change take effect."
|
||||||
|
else
|
||||||
|
info "Next:"
|
||||||
|
info " 1. Remove any unpacked copy from chrome://extensions (same id — both cannot load)."
|
||||||
|
info " 2. Restart the browser, or open chrome://policy and press \"Reload policies\"."
|
||||||
|
info " 3. The card should read \"Installed by enterprise policy\"."
|
||||||
|
fi
|
||||||
+33
-9
@@ -86,34 +86,34 @@ echo
|
|||||||
# The branch is named explicitly: a bare clone follows the remote's default
|
# The branch is named explicitly: a bare clone follows the remote's default
|
||||||
# branch, which is not necessarily master.
|
# branch, which is not necessarily master.
|
||||||
if [ -d "$TARGET/.git" ]; then
|
if [ -d "$TARGET/.git" ]; then
|
||||||
info "[1/6] existing checkout - switching to master and pulling..."
|
info "[1/7] existing checkout - switching to master and pulling..."
|
||||||
git -C "$TARGET" fetch origin
|
git -C "$TARGET" fetch origin
|
||||||
git -C "$TARGET" checkout master
|
git -C "$TARGET" checkout master
|
||||||
git -C "$TARGET" pull --ff-only origin master
|
git -C "$TARGET" pull --ff-only origin master
|
||||||
else
|
else
|
||||||
info "[1/6] cloning $REPO_URL ..."
|
info "[1/7] cloning $REPO_URL ..."
|
||||||
git clone --branch master "$REPO_URL" "$TARGET"
|
git clone --branch master "$REPO_URL" "$TARGET"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd "$TARGET"
|
cd "$TARGET"
|
||||||
|
|
||||||
# ── 2. npm ──────────────────────────────────────────────────────────────────
|
# ── 2. npm ──────────────────────────────────────────────────────────────────
|
||||||
info "[2/6] installing npm dependencies (a few minutes on a Pi)..."
|
info "[2/7] installing npm dependencies (a few minutes on a Pi)..."
|
||||||
npm install
|
npm install
|
||||||
|
|
||||||
# ── 3. build ────────────────────────────────────────────────────────────────
|
# ── 3. build ────────────────────────────────────────────────────────────────
|
||||||
info "[3/6] building..."
|
info "[3/7] building..."
|
||||||
npm run build
|
npm run build
|
||||||
|
|
||||||
# ── 4. settings ─────────────────────────────────────────────────────────────
|
# ── 4. settings ─────────────────────────────────────────────────────────────
|
||||||
info "[4/6] writing instance settings..."
|
info "[4/7] writing instance settings..."
|
||||||
node scripts/seed-settings.js "$MASTER_URL" "$INSTANCE"
|
node scripts/seed-settings.js "$MASTER_URL" "$INSTANCE"
|
||||||
|
|
||||||
# ── 5. python ───────────────────────────────────────────────────────────────
|
# ── 5. python ───────────────────────────────────────────────────────────────
|
||||||
# A virtualenv rather than a system pip install: Raspberry Pi OS Bookworm
|
# A virtualenv rather than a system pip install: Raspberry Pi OS Bookworm
|
||||||
# enforces PEP 668, so pip into the system interpreter fails outright with
|
# enforces PEP 668, so pip into the system interpreter fails outright with
|
||||||
# "externally-managed-environment".
|
# "externally-managed-environment".
|
||||||
info "[5/6] installing clicker dependencies into a virtualenv..."
|
info "[5/7] installing clicker dependencies into a virtualenv..."
|
||||||
VENV="$TARGET/clicker/.venv"
|
VENV="$TARGET/clicker/.venv"
|
||||||
[ -d "$VENV" ] || python3 -m venv "$VENV"
|
[ -d "$VENV" ] || python3 -m venv "$VENV"
|
||||||
"$VENV/bin/python" -m pip install --quiet --upgrade pip
|
"$VENV/bin/python" -m pip install --quiet --upgrade pip
|
||||||
@@ -126,7 +126,7 @@ fi
|
|||||||
|
|
||||||
# ── 6. autostart ────────────────────────────────────────────────────────────
|
# ── 6. autostart ────────────────────────────────────────────────────────────
|
||||||
echo
|
echo
|
||||||
info "[6/6] Auto-start and auto-update"
|
info "[6/7] Auto-start and auto-update"
|
||||||
info " Starts AutoFirmer and the clicker at login, and checks master every"
|
info " Starts AutoFirmer and the clicker at login, and checks master every"
|
||||||
info " 5 minutes - rebuilding and restarting when it moves. A failed build"
|
info " 5 minutes - rebuilding and restarting when it moves. A failed build"
|
||||||
info " is never deployed."
|
info " is never deployed."
|
||||||
@@ -140,6 +140,25 @@ else
|
|||||||
info " Skipped. Run scripts/install-autostart.sh later to enable it."
|
info " Skipped. Run scripts/install-autostart.sh later to enable it."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# ── 7. extension ────────────────────────────────────────────────────────────
|
||||||
|
# Chrome refuses to side-load a CRX and will not update an unpacked folder, so
|
||||||
|
# the extension goes in the way a self-hosted one has to: a managed-policy file
|
||||||
|
# naming our update server. That lives under /etc, hence sudo — there is no
|
||||||
|
# per-user equivalent on Linux.
|
||||||
|
echo
|
||||||
|
info "[7/7] Chrome extension"
|
||||||
|
info " Installs it from the update server and lets Chrome keep it current"
|
||||||
|
info " by itself. Needs sudo - the policy file lives under /etc."
|
||||||
|
read -r -p " Set this up now? [Y/n] " DOEXT
|
||||||
|
EXTPOLICY=0
|
||||||
|
if [ "${DOEXT,,}" != "n" ]; then
|
||||||
|
if sudo bash scripts/install-extension-policy.sh; then EXTPOLICY=1; else
|
||||||
|
warn "extension policy failed - load $TARGET/extension unpacked for now"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
info " Skipped. Run: sudo scripts/install-extension-policy.sh"
|
||||||
|
fi
|
||||||
|
|
||||||
# ── summary ─────────────────────────────────────────────────────────────────
|
# ── summary ─────────────────────────────────────────────────────────────────
|
||||||
echo
|
echo
|
||||||
echo " ============================================"
|
echo " ============================================"
|
||||||
@@ -159,8 +178,13 @@ else
|
|||||||
fi
|
fi
|
||||||
echo
|
echo
|
||||||
info "Still manual:"
|
info "Still manual:"
|
||||||
info " - Load the Chrome extension: chrome://extensions -> Developer mode"
|
if [ "$EXTPOLICY" -eq 1 ]; then
|
||||||
info " -> Load unpacked -> $TARGET/extension"
|
info " - Restart Chrome, and remove any unpacked copy of the extension"
|
||||||
|
info " (it shares the same id now, and Chrome will not load both)"
|
||||||
|
else
|
||||||
|
info " - Load the Chrome extension: chrome://extensions -> Developer mode"
|
||||||
|
info " -> Load unpacked -> $TARGET/extension"
|
||||||
|
fi
|
||||||
info " - Add your firm credentials on the dashboard's Settings page"
|
info " - Add your firm credentials on the dashboard's Settings page"
|
||||||
if [ -n "${WAYLAND_DISPLAY:-}" ] && [ -z "${DISPLAY:-}" ]; then
|
if [ -n "${WAYLAND_DISPLAY:-}" ] && [ -z "${DISPLAY:-}" ]; then
|
||||||
echo
|
echo
|
||||||
|
|||||||
+412
-378
@@ -1,378 +1,412 @@
|
|||||||
@echo off
|
@echo off
|
||||||
setlocal EnableExtensions
|
setlocal EnableExtensions
|
||||||
title AutoFirmer - Windows setup
|
title AutoFirmer - Windows setup
|
||||||
|
|
||||||
REM ============================================================================
|
REM ============================================================================
|
||||||
REM AutoFirmer instance setup for Windows.
|
REM AutoFirmer instance setup for Windows.
|
||||||
REM
|
REM
|
||||||
REM Standalone: drop this file anywhere and run it. It clones the repo into a
|
REM Standalone: drop this file anywhere and run it. It clones the repo into a
|
||||||
REM subfolder next to itself, installs, builds, and points the instance at the
|
REM subfolder next to itself, installs, builds, and points the instance at the
|
||||||
REM master dashboard. Safe to re-run - it pulls and rebuilds instead of cloning.
|
REM master dashboard. Safe to re-run - it pulls and rebuilds instead of cloning.
|
||||||
REM ============================================================================
|
REM ============================================================================
|
||||||
|
|
||||||
set "REPO_URL=https://git.juicerroom.com/senofy/autofirmer-expanded.git"
|
set "REPO_URL=https://git.juicerroom.com/senofy/autofirmer-expanded.git"
|
||||||
set "DEFAULT_MASTER=https://master.juicerroom.com"
|
set "DEFAULT_MASTER=https://master.juicerroom.com"
|
||||||
set "TARGET=%~dp0autofirmer"
|
set "TARGET=%~dp0autofirmer"
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ============================================
|
echo ============================================
|
||||||
echo AutoFirmer - Windows setup
|
echo AutoFirmer - Windows setup
|
||||||
echo ============================================
|
echo ============================================
|
||||||
echo.
|
echo.
|
||||||
|
|
||||||
REM ---------------------------------------------------------------- git check
|
REM ---------------------------------------------------------------- git check
|
||||||
REM Git for Windows only lands on PATH if "Git from the command line" was chosen
|
REM Git for Windows only lands on PATH if "Git from the command line" was chosen
|
||||||
REM at install time, and an already-open cmd keeps its old PATH regardless. So:
|
REM at install time, and an already-open cmd keeps its old PATH regardless. So:
|
||||||
REM probe the usual homes, then offer to install, then probe again - a fresh
|
REM probe the usual homes, then offer to install, then probe again - a fresh
|
||||||
REM install is never visible to `where` in this session.
|
REM install is never visible to `where` in this session.
|
||||||
:git_probe
|
:git_probe
|
||||||
where git >nul 2>&1
|
where git >nul 2>&1
|
||||||
if not errorlevel 1 goto :git_done
|
if not errorlevel 1 goto :git_done
|
||||||
if exist "%ProgramFiles%\Git\cmd\git.exe" set "PATH=%ProgramFiles%\Git\cmd;%PATH%"
|
if exist "%ProgramFiles%\Git\cmd\git.exe" set "PATH=%ProgramFiles%\Git\cmd;%PATH%"
|
||||||
if exist "%ProgramFiles(x86)%\Git\cmd\git.exe" set "PATH=%ProgramFiles(x86)%\Git\cmd;%PATH%"
|
if exist "%ProgramFiles(x86)%\Git\cmd\git.exe" set "PATH=%ProgramFiles(x86)%\Git\cmd;%PATH%"
|
||||||
if exist "%LOCALAPPDATA%\Programs\Git\cmd\git.exe" set "PATH=%LOCALAPPDATA%\Programs\Git\cmd;%PATH%"
|
if exist "%LOCALAPPDATA%\Programs\Git\cmd\git.exe" set "PATH=%LOCALAPPDATA%\Programs\Git\cmd;%PATH%"
|
||||||
where git >nul 2>&1
|
where git >nul 2>&1
|
||||||
if not errorlevel 1 goto :git_found_offpath
|
if not errorlevel 1 goto :git_found_offpath
|
||||||
if "%GIT_TRIED%"=="1" goto :git_missing
|
if "%GIT_TRIED%"=="1" goto :git_missing
|
||||||
where winget >nul 2>&1
|
where winget >nul 2>&1
|
||||||
if errorlevel 1 goto :git_missing
|
if errorlevel 1 goto :git_missing
|
||||||
echo.
|
echo.
|
||||||
echo [--] Git is not installed.
|
echo [--] Git is not installed.
|
||||||
set "DOIT="
|
set "DOIT="
|
||||||
set /p "DOIT= Install it now with winget? [Y/n] "
|
set /p "DOIT= Install it now with winget? [Y/n] "
|
||||||
if /i "%DOIT%"=="n" goto :git_missing
|
if /i "%DOIT%"=="n" goto :git_missing
|
||||||
set "GIT_TRIED=1"
|
set "GIT_TRIED=1"
|
||||||
echo Installing Git ^(a UAC prompt may appear^)...
|
echo Installing Git ^(a UAC prompt may appear^)...
|
||||||
winget install --id Git.Git -e --source winget --accept-source-agreements --accept-package-agreements --silent
|
winget install --id Git.Git -e --source winget --accept-source-agreements --accept-package-agreements --silent
|
||||||
goto :git_probe
|
goto :git_probe
|
||||||
|
|
||||||
:git_found_offpath
|
:git_found_offpath
|
||||||
echo [ok] git ^(found off PATH, added for this run^)
|
echo [ok] git ^(found off PATH, added for this run^)
|
||||||
goto :git_done
|
goto :git_done
|
||||||
|
|
||||||
:git_missing
|
:git_missing
|
||||||
echo [X] Git not found on PATH, and not in any of:
|
echo [X] Git not found on PATH, and not in any of:
|
||||||
echo %ProgramFiles%\Git\cmd
|
echo %ProgramFiles%\Git\cmd
|
||||||
echo %LOCALAPPDATA%\Programs\Git\cmd
|
echo %LOCALAPPDATA%\Programs\Git\cmd
|
||||||
echo.
|
echo.
|
||||||
echo Install it from https://git-scm.com/download/win
|
echo Install it from https://git-scm.com/download/win
|
||||||
echo If you JUST installed it: close this window, open a new Command
|
echo If you JUST installed it: close this window, open a new Command
|
||||||
echo Prompt and run the script again - an open window keeps its old PATH.
|
echo Prompt and run the script again - an open window keeps its old PATH.
|
||||||
goto :fail
|
goto :fail
|
||||||
|
|
||||||
:git_done
|
:git_done
|
||||||
echo [ok] git
|
echo [ok] git
|
||||||
|
|
||||||
REM --------------------------------------------------------------- node check
|
REM --------------------------------------------------------------- node check
|
||||||
REM winget's LTS package is deliberate: better-sqlite3 publishes prebuilt
|
REM winget's LTS package is deliberate: better-sqlite3 publishes prebuilt
|
||||||
REM binaries for LTS Node, so installing LTS sidesteps the node-gyp build.
|
REM binaries for LTS Node, so installing LTS sidesteps the node-gyp build.
|
||||||
:node_probe
|
:node_probe
|
||||||
where node >nul 2>&1
|
where node >nul 2>&1
|
||||||
if not errorlevel 1 goto :node_found
|
if not errorlevel 1 goto :node_found
|
||||||
if exist "%ProgramFiles%\nodejs\node.exe" set "PATH=%ProgramFiles%\nodejs;%PATH%"
|
if exist "%ProgramFiles%\nodejs\node.exe" set "PATH=%ProgramFiles%\nodejs;%PATH%"
|
||||||
if exist "%LOCALAPPDATA%\Programs\nodejs\node.exe" set "PATH=%LOCALAPPDATA%\Programs\nodejs;%PATH%"
|
if exist "%LOCALAPPDATA%\Programs\nodejs\node.exe" set "PATH=%LOCALAPPDATA%\Programs\nodejs;%PATH%"
|
||||||
where node >nul 2>&1
|
where node >nul 2>&1
|
||||||
if not errorlevel 1 goto :node_found
|
if not errorlevel 1 goto :node_found
|
||||||
if "%NODE_TRIED%"=="1" goto :node_missing
|
if "%NODE_TRIED%"=="1" goto :node_missing
|
||||||
where winget >nul 2>&1
|
where winget >nul 2>&1
|
||||||
if errorlevel 1 goto :node_missing
|
if errorlevel 1 goto :node_missing
|
||||||
echo.
|
echo.
|
||||||
echo [--] Node.js is not installed.
|
echo [--] Node.js is not installed.
|
||||||
set "DOIT="
|
set "DOIT="
|
||||||
set /p "DOIT= Install Node 22 LTS now with winget? [Y/n] "
|
set /p "DOIT= Install Node 22 LTS now with winget? [Y/n] "
|
||||||
if /i "%DOIT%"=="n" goto :node_missing
|
if /i "%DOIT%"=="n" goto :node_missing
|
||||||
set "NODE_TRIED=1"
|
set "NODE_TRIED=1"
|
||||||
echo Installing Node LTS ^(a UAC prompt may appear^)...
|
echo Installing Node LTS ^(a UAC prompt may appear^)...
|
||||||
winget install --id OpenJS.NodeJS.LTS -e --source winget --accept-source-agreements --accept-package-agreements --silent
|
winget install --id OpenJS.NodeJS.LTS -e --source winget --accept-source-agreements --accept-package-agreements --silent
|
||||||
goto :node_probe
|
goto :node_probe
|
||||||
|
|
||||||
:node_missing
|
:node_missing
|
||||||
echo [X] Node.js not found on PATH, and not in any of:
|
echo [X] Node.js not found on PATH, and not in any of:
|
||||||
echo %ProgramFiles%\nodejs
|
echo %ProgramFiles%\nodejs
|
||||||
echo %LOCALAPPDATA%\Programs\nodejs
|
echo %LOCALAPPDATA%\Programs\nodejs
|
||||||
echo.
|
echo.
|
||||||
echo Install Node 22 LTS from https://nodejs.org/ then re-run.
|
echo Install Node 22 LTS from https://nodejs.org/ then re-run.
|
||||||
echo If you JUST installed it, open a NEW Command Prompt first.
|
echo If you JUST installed it, open a NEW Command Prompt first.
|
||||||
goto :fail
|
goto :fail
|
||||||
|
|
||||||
:node_found
|
:node_found
|
||||||
if exist "%ProgramFiles%\nodejs\node.exe" set "PATH=%ProgramFiles%\nodejs;%PATH%"
|
if exist "%ProgramFiles%\nodejs\node.exe" set "PATH=%ProgramFiles%\nodejs;%PATH%"
|
||||||
if exist "%LOCALAPPDATA%\Programs\nodejs\node.exe" set "PATH=%LOCALAPPDATA%\Programs\nodejs;%PATH%"
|
if exist "%LOCALAPPDATA%\Programs\nodejs\node.exe" set "PATH=%LOCALAPPDATA%\Programs\nodejs;%PATH%"
|
||||||
where node >nul 2>&1
|
where node >nul 2>&1
|
||||||
if not errorlevel 1 goto :node_found
|
if not errorlevel 1 goto :node_found
|
||||||
echo [X] Node.js not found on PATH, and not in any of:
|
echo [X] Node.js not found on PATH, and not in any of:
|
||||||
echo %ProgramFiles%\nodejs
|
echo %ProgramFiles%\nodejs
|
||||||
echo %LOCALAPPDATA%\Programs\nodejs
|
echo %LOCALAPPDATA%\Programs\nodejs
|
||||||
echo.
|
echo.
|
||||||
echo Install Node 22 LTS from https://nodejs.org/ then re-run.
|
echo Install Node 22 LTS from https://nodejs.org/ then re-run.
|
||||||
echo If you JUST installed it, open a NEW Command Prompt first.
|
echo If you JUST installed it, open a NEW Command Prompt first.
|
||||||
goto :fail
|
goto :fail
|
||||||
:node_found
|
:node_found
|
||||||
for /f "tokens=* usebackq" %%v in (`node -p "process.versions.node"`) do set "NODEVER=%%v"
|
for /f "tokens=* usebackq" %%v in (`node -p "process.versions.node"`) do set "NODEVER=%%v"
|
||||||
for /f "tokens=1 delims=." %%m in ("%NODEVER%") do set "NODEMAJOR=%%m"
|
for /f "tokens=1 delims=." %%m in ("%NODEVER%") do set "NODEMAJOR=%%m"
|
||||||
echo [ok] node v%NODEVER%
|
echo [ok] node v%NODEVER%
|
||||||
|
|
||||||
REM better-sqlite3 ships prebuilt binaries only for released Node ABIs. On a
|
REM better-sqlite3 ships prebuilt binaries only for released Node ABIs. On a
|
||||||
REM newer major it falls back to node-gyp, which needs Visual Studio Build
|
REM newer major it falls back to node-gyp, which needs Visual Studio Build
|
||||||
REM Tools - a long, confusing failure if it is not installed.
|
REM Tools - a long, confusing failure if it is not installed.
|
||||||
if %NODEMAJOR% GEQ 23 goto :node_warn
|
if %NODEMAJOR% GEQ 23 goto :node_warn
|
||||||
goto :node_ok
|
goto :node_ok
|
||||||
|
|
||||||
:node_warn
|
:node_warn
|
||||||
echo.
|
echo.
|
||||||
echo [!] Node %NODEMAJOR% is newer than better-sqlite3's prebuilt binaries.
|
echo [!] Node %NODEMAJOR% is newer than better-sqlite3's prebuilt binaries.
|
||||||
echo Install may try to compile from source and fail without Visual
|
echo Install may try to compile from source and fail without Visual
|
||||||
echo Studio Build Tools. Node 22 LTS is the safe choice here.
|
echo Studio Build Tools. Node 22 LTS is the safe choice here.
|
||||||
echo.
|
echo.
|
||||||
set "GOON="
|
set "GOON="
|
||||||
set /p "GOON= Continue anyway? [y/N] "
|
set /p "GOON= Continue anyway? [y/N] "
|
||||||
if /i not "%GOON%"=="y" goto :fail
|
if /i not "%GOON%"=="y" goto :fail
|
||||||
:node_ok
|
:node_ok
|
||||||
|
|
||||||
REM ------------------------------------------------------------------- python
|
REM ------------------------------------------------------------------- python
|
||||||
REM Only the clicker needs Python; the dashboard runs without it.
|
REM Only the clicker needs Python; the dashboard runs without it.
|
||||||
REM
|
REM
|
||||||
REM Detection is deliberately "run it and see" rather than `where python`:
|
REM Detection is deliberately "run it and see" rather than `where python`:
|
||||||
REM Windows ships a stub python.exe in WindowsApps that only opens the Microsoft
|
REM Windows ships a stub python.exe in WindowsApps that only opens the Microsoft
|
||||||
REM Store. `where` finds it, running it does nothing useful. Asking it to print
|
REM Store. `where` finds it, running it does nothing useful. Asking it to print
|
||||||
REM its major version separates a real interpreter from the stub. The py
|
REM its major version separates a real interpreter from the stub. The py
|
||||||
REM launcher is preferred when present - it is not shadowed by the stub.
|
REM launcher is preferred when present - it is not shadowed by the stub.
|
||||||
:py_probe
|
:py_probe
|
||||||
set "PYCMD="
|
set "PYCMD="
|
||||||
for /f "tokens=*" %%v in ('py -3 -c "import sys;print(sys.version_info[0])" 2^>nul') do if "%%v"=="3" set "PYCMD=py -3"
|
for /f "tokens=*" %%v in ('py -3 -c "import sys;print(sys.version_info[0])" 2^>nul') do if "%%v"=="3" set "PYCMD=py -3"
|
||||||
if not defined PYCMD for /f "tokens=*" %%v in ('python -c "import sys;print(sys.version_info[0])" 2^>nul') do if "%%v"=="3" set "PYCMD=python"
|
if not defined PYCMD for /f "tokens=*" %%v in ('python -c "import sys;print(sys.version_info[0])" 2^>nul') do if "%%v"=="3" set "PYCMD=python"
|
||||||
if defined PYCMD goto :py_found
|
if defined PYCMD goto :py_found
|
||||||
|
|
||||||
REM Not on PATH. Same story as Git and Node: a Python installed just now - or
|
REM Not on PATH. Same story as Git and Node: a Python installed just now - or
|
||||||
REM installed without "Add to PATH" ticked - is invisible to this session, which
|
REM installed without "Add to PATH" ticked - is invisible to this session, which
|
||||||
REM inherited its PATH at start. Prepend the standard install homes and retry.
|
REM inherited its PATH at start. Prepend the standard install homes and retry.
|
||||||
REM The version is globbed rather than hardcoded so a 3.13 install still works.
|
REM The version is globbed rather than hardcoded so a 3.13 install still works.
|
||||||
for /d %%D in ("%LOCALAPPDATA%\Programs\Python\Python3*") do if exist "%%~D\python.exe" set "PATH=%%~D;%%~D\Scripts;%PATH%"
|
for /d %%D in ("%LOCALAPPDATA%\Programs\Python\Python3*") do if exist "%%~D\python.exe" set "PATH=%%~D;%%~D\Scripts;%PATH%"
|
||||||
for /d %%D in ("%ProgramFiles%\Python3*") do if exist "%%~D\python.exe" set "PATH=%%~D;%%~D\Scripts;%PATH%"
|
for /d %%D in ("%ProgramFiles%\Python3*") do if exist "%%~D\python.exe" set "PATH=%%~D;%%~D\Scripts;%PATH%"
|
||||||
if exist "%LOCALAPPDATA%\Programs\Python\Launcher\py.exe" set "PATH=%LOCALAPPDATA%\Programs\Python\Launcher;%PATH%"
|
if exist "%LOCALAPPDATA%\Programs\Python\Launcher\py.exe" set "PATH=%LOCALAPPDATA%\Programs\Python\Launcher;%PATH%"
|
||||||
if exist "%SystemRoot%\py.exe" set "PATH=%SystemRoot%;%PATH%"
|
if exist "%SystemRoot%\py.exe" set "PATH=%SystemRoot%;%PATH%"
|
||||||
|
|
||||||
for /f "tokens=*" %%v in ('py -3 -c "import sys;print(sys.version_info[0])" 2^>nul') do if "%%v"=="3" set "PYCMD=py -3"
|
for /f "tokens=*" %%v in ('py -3 -c "import sys;print(sys.version_info[0])" 2^>nul') do if "%%v"=="3" set "PYCMD=py -3"
|
||||||
if not defined PYCMD for /f "tokens=*" %%v in ('python -c "import sys;print(sys.version_info[0])" 2^>nul') do if "%%v"=="3" set "PYCMD=python"
|
if not defined PYCMD for /f "tokens=*" %%v in ('python -c "import sys;print(sys.version_info[0])" 2^>nul') do if "%%v"=="3" set "PYCMD=python"
|
||||||
if defined PYCMD goto :py_found
|
if defined PYCMD goto :py_found
|
||||||
if "%PY_TRIED%"=="1" goto :py_skip
|
if "%PY_TRIED%"=="1" goto :py_skip
|
||||||
where winget >nul 2>&1
|
where winget >nul 2>&1
|
||||||
if errorlevel 1 goto :py_skip
|
if errorlevel 1 goto :py_skip
|
||||||
echo.
|
echo.
|
||||||
echo [--] Python is not installed ^(needed only for the clicker^).
|
echo [--] Python is not installed ^(needed only for the clicker^).
|
||||||
set "DOIT="
|
set "DOIT="
|
||||||
set /p "DOIT= Install Python 3.12 now with winget? [Y/n] "
|
set /p "DOIT= Install Python 3.12 now with winget? [Y/n] "
|
||||||
if /i "%DOIT%"=="n" goto :py_skip
|
if /i "%DOIT%"=="n" goto :py_skip
|
||||||
set "PY_TRIED=1"
|
set "PY_TRIED=1"
|
||||||
echo Installing Python ^(a UAC prompt may appear^)...
|
echo Installing Python ^(a UAC prompt may appear^)...
|
||||||
winget install --id Python.Python.3.12 -e --source winget --accept-source-agreements --accept-package-agreements --silent
|
winget install --id Python.Python.3.12 -e --source winget --accept-source-agreements --accept-package-agreements --silent
|
||||||
goto :py_probe
|
goto :py_probe
|
||||||
|
|
||||||
:py_skip
|
:py_skip
|
||||||
echo [--] python not found on PATH, and not in any of:
|
echo [--] python not found on PATH, and not in any of:
|
||||||
echo %LOCALAPPDATA%\Programs\Python\Python3*
|
echo %LOCALAPPDATA%\Programs\Python\Python3*
|
||||||
echo %ProgramFiles%\Python3*
|
echo %ProgramFiles%\Python3*
|
||||||
echo The dashboard will still work - python is only needed for the
|
echo The dashboard will still work - python is only needed for the
|
||||||
echo clicker ^(clicker\runner.py^). If you just installed it, close this
|
echo clicker ^(clicker\runner.py^). If you just installed it, close this
|
||||||
echo window and re-run to pick up the new PATH.
|
echo window and re-run to pick up the new PATH.
|
||||||
goto :py_end
|
goto :py_end
|
||||||
|
|
||||||
:py_found
|
:py_found
|
||||||
for /f "tokens=*" %%v in ('%PYCMD% -c "import sys;print(sys.version.split()[0])" 2^>nul') do set "PYVER=%%v"
|
for /f "tokens=*" %%v in ('%PYCMD% -c "import sys;print(sys.version.split()[0])" 2^>nul') do set "PYVER=%%v"
|
||||||
echo [ok] python %PYVER% ^(via "%PYCMD%"^)
|
echo [ok] python %PYVER% ^(via "%PYCMD%"^)
|
||||||
:py_end
|
:py_end
|
||||||
|
|
||||||
REM ------------------------------------------------------------------- prompts
|
REM ------------------------------------------------------------------- prompts
|
||||||
echo.
|
echo.
|
||||||
set "MASTER_URL="
|
set "MASTER_URL="
|
||||||
set /p "MASTER_URL= Master dashboard URL [%DEFAULT_MASTER%]: "
|
set /p "MASTER_URL= Master dashboard URL [%DEFAULT_MASTER%]: "
|
||||||
if "%MASTER_URL%"=="" set "MASTER_URL=%DEFAULT_MASTER%"
|
if "%MASTER_URL%"=="" set "MASTER_URL=%DEFAULT_MASTER%"
|
||||||
|
|
||||||
set "INSTANCE="
|
set "INSTANCE="
|
||||||
set /p "INSTANCE= Instance name [%COMPUTERNAME%]: "
|
set /p "INSTANCE= Instance name [%COMPUTERNAME%]: "
|
||||||
if "%INSTANCE%"=="" set "INSTANCE=%COMPUTERNAME%"
|
if "%INSTANCE%"=="" set "INSTANCE=%COMPUTERNAME%"
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo Installing to: %TARGET%
|
echo Installing to: %TARGET%
|
||||||
echo.
|
echo.
|
||||||
|
|
||||||
REM -------------------------------------------------------------- clone / pull
|
REM -------------------------------------------------------------- clone / pull
|
||||||
REM The branch is named explicitly throughout. A bare `git clone` follows the
|
REM The branch is named explicitly throughout. A bare `git clone` follows the
|
||||||
REM remote's default branch, which is not necessarily master - and an existing
|
REM remote's default branch, which is not necessarily master - and an existing
|
||||||
REM checkout may be sitting on a stale branch from before that was corrected.
|
REM checkout may be sitting on a stale branch from before that was corrected.
|
||||||
if exist "%TARGET%\.git" goto :repo_update
|
if exist "%TARGET%\.git" goto :repo_update
|
||||||
echo [1/6] Cloning %REPO_URL% ...
|
echo [1/7] Cloning %REPO_URL% ...
|
||||||
git clone --branch master "%REPO_URL%" "%TARGET%"
|
git clone --branch master "%REPO_URL%" "%TARGET%"
|
||||||
if errorlevel 1 goto :clone_failed
|
if errorlevel 1 goto :clone_failed
|
||||||
goto :repo_ready
|
goto :repo_ready
|
||||||
|
|
||||||
:clone_failed
|
:clone_failed
|
||||||
echo [X] Clone failed. Check network access to git.juicerroom.com.
|
echo [X] Clone failed. Check network access to git.juicerroom.com.
|
||||||
goto :fail
|
goto :fail
|
||||||
|
|
||||||
:repo_update
|
:repo_update
|
||||||
echo [1/6] Existing checkout found - switching to master and pulling...
|
echo [1/7] Existing checkout found - switching to master and pulling...
|
||||||
pushd "%TARGET%"
|
pushd "%TARGET%"
|
||||||
git fetch origin
|
git fetch origin
|
||||||
if errorlevel 1 goto :pull_failed
|
if errorlevel 1 goto :pull_failed
|
||||||
git checkout master
|
git checkout master
|
||||||
if errorlevel 1 goto :pull_failed
|
if errorlevel 1 goto :pull_failed
|
||||||
git pull --ff-only origin master
|
git pull --ff-only origin master
|
||||||
if errorlevel 1 goto :pull_failed
|
if errorlevel 1 goto :pull_failed
|
||||||
popd
|
popd
|
||||||
goto :repo_ready
|
goto :repo_ready
|
||||||
|
|
||||||
:pull_failed
|
:pull_failed
|
||||||
popd
|
popd
|
||||||
echo [X] Could not update the checkout. If you have local changes, either
|
echo [X] Could not update the checkout. If you have local changes, either
|
||||||
echo commit them or delete this folder and re-run to clone fresh:
|
echo commit them or delete this folder and re-run to clone fresh:
|
||||||
echo %TARGET%
|
echo %TARGET%
|
||||||
goto :fail
|
goto :fail
|
||||||
|
|
||||||
:repo_ready
|
:repo_ready
|
||||||
|
|
||||||
pushd "%TARGET%"
|
pushd "%TARGET%"
|
||||||
|
|
||||||
REM ------------------------------------------------------------------- install
|
REM ------------------------------------------------------------------- install
|
||||||
echo.
|
echo.
|
||||||
echo [2/6] Installing npm dependencies ^(this takes a few minutes^)...
|
echo [2/7] Installing npm dependencies ^(this takes a few minutes^)...
|
||||||
call npm install
|
call npm install
|
||||||
if errorlevel 1 (
|
if errorlevel 1 (
|
||||||
echo.
|
echo.
|
||||||
echo [X] npm install failed.
|
echo [X] npm install failed.
|
||||||
echo If the error mentions node-gyp, MSBuild, or better_sqlite3.cpp,
|
echo If the error mentions node-gyp, MSBuild, or better_sqlite3.cpp,
|
||||||
echo the native module could not find a prebuilt binary. Either switch
|
echo the native module could not find a prebuilt binary. Either switch
|
||||||
echo to Node 22 LTS, or install "Desktop development with C++" from the
|
echo to Node 22 LTS, or install "Desktop development with C++" from the
|
||||||
echo Visual Studio Build Tools installer.
|
echo Visual Studio Build Tools installer.
|
||||||
popd
|
popd
|
||||||
goto :fail
|
goto :fail
|
||||||
)
|
)
|
||||||
|
|
||||||
REM --------------------------------------------------------------------- build
|
REM --------------------------------------------------------------------- build
|
||||||
echo.
|
echo.
|
||||||
echo [3/6] Building...
|
echo [3/7] Building...
|
||||||
call npm run build
|
call npm run build
|
||||||
if errorlevel 1 (
|
if errorlevel 1 (
|
||||||
echo [X] Build failed.
|
echo [X] Build failed.
|
||||||
popd
|
popd
|
||||||
goto :fail
|
goto :fail
|
||||||
)
|
)
|
||||||
|
|
||||||
REM ------------------------------------------------------------------ settings
|
REM ------------------------------------------------------------------ settings
|
||||||
echo.
|
echo.
|
||||||
echo [4/6] Writing instance settings...
|
echo [4/7] Writing instance settings...
|
||||||
node scripts\seed-settings.js "%MASTER_URL%" "%INSTANCE%"
|
node scripts\seed-settings.js "%MASTER_URL%" "%INSTANCE%"
|
||||||
if errorlevel 1 (
|
if errorlevel 1 (
|
||||||
echo [X] Could not write settings to autotrader.sqlite.
|
echo [X] Could not write settings to autotrader.sqlite.
|
||||||
popd
|
popd
|
||||||
goto :fail
|
goto :fail
|
||||||
)
|
)
|
||||||
REM Record the interpreter resolved above. The Node helpers read this rather
|
REM Record the interpreter resolved above. The Node helpers read this rather
|
||||||
REM than repeating the Store-stub detection in a second language.
|
REM than repeating the Store-stub detection in a second language.
|
||||||
if defined PYCMD echo %PYCMD%> scripts\.python-cmd
|
if defined PYCMD echo %PYCMD%> scripts\.python-cmd
|
||||||
|
|
||||||
REM ------------------------------------------------------ python deps (option)
|
REM ------------------------------------------------------ python deps (option)
|
||||||
echo.
|
echo.
|
||||||
if not defined PYCMD goto :deps_skip
|
if not defined PYCMD goto :deps_skip
|
||||||
echo [5/6] Installing clicker Python dependencies...
|
echo [5/7] Installing clicker Python dependencies...
|
||||||
REM requirements.txt guards its pyobjc entries with sys_platform == "darwin",
|
REM requirements.txt guards its pyobjc entries with sys_platform == "darwin",
|
||||||
REM so on Windows this resolves to pyautogui and its wheels only.
|
REM so on Windows this resolves to pyautogui and its wheels only.
|
||||||
%PYCMD% -m pip install --upgrade --quiet --disable-pip-version-check pip
|
%PYCMD% -m pip install --upgrade --quiet --disable-pip-version-check pip
|
||||||
%PYCMD% -m pip install --quiet --disable-pip-version-check -r clicker\requirements.txt
|
%PYCMD% -m pip install --quiet --disable-pip-version-check -r clicker\requirements.txt
|
||||||
if errorlevel 1 goto :deps_failed
|
if errorlevel 1 goto :deps_failed
|
||||||
%PYCMD% -c "import pyautogui" 2>nul
|
%PYCMD% -c "import pyautogui" 2>nul
|
||||||
if errorlevel 1 goto :deps_failed
|
if errorlevel 1 goto :deps_failed
|
||||||
echo pyautogui imports cleanly.
|
echo pyautogui imports cleanly.
|
||||||
goto :deps_done
|
goto :deps_done
|
||||||
|
|
||||||
:deps_failed
|
:deps_failed
|
||||||
echo [!] Python dependency install failed - the dashboard still works,
|
echo [!] Python dependency install failed - the dashboard still works,
|
||||||
echo the clicker will not. Retry by hand with:
|
echo the clicker will not. Retry by hand with:
|
||||||
echo %PYCMD% -m pip install -r clicker\requirements.txt
|
echo %PYCMD% -m pip install -r clicker\requirements.txt
|
||||||
goto :deps_done
|
goto :deps_done
|
||||||
|
|
||||||
:deps_skip
|
:deps_skip
|
||||||
echo [5/6] Skipping Python dependencies ^(python not found^).
|
echo [5/7] Skipping Python dependencies ^(python not found^).
|
||||||
|
|
||||||
:deps_done
|
:deps_done
|
||||||
|
|
||||||
REM ------------------------------------------------------------- autostart
|
REM ------------------------------------------------------------- autostart
|
||||||
REM Prompted, not automatic: turning a trading PC into something that rebuilds
|
REM Prompted, not automatic: turning a trading PC into something that rebuilds
|
||||||
REM and restarts itself on every push to master should be a decision.
|
REM and restarts itself on every push to master should be a decision.
|
||||||
echo.
|
echo.
|
||||||
echo [6/6] Auto-start and auto-update
|
echo [6/7] Auto-start and auto-update
|
||||||
echo Starts AutoFirmer and the clicker at logon, and checks master every
|
echo Starts AutoFirmer and the clicker at logon, and checks master every
|
||||||
echo 5 minutes - rebuilding and restarting when it moves. A failed build
|
echo 5 minutes - rebuilding and restarting when it moves. A failed build
|
||||||
echo is never deployed.
|
echo is never deployed.
|
||||||
set "DOAUTO="
|
set "DOAUTO="
|
||||||
set /p "DOAUTO= Set this up now? [Y/n] "
|
set /p "DOAUTO= Set this up now? [Y/n] "
|
||||||
if /i "%DOAUTO%"=="n" goto :autostart_skipped
|
if /i "%DOAUTO%"=="n" goto :autostart_skipped
|
||||||
REM -ExecutionPolicy Bypass applies to this invocation only; nothing machine-wide
|
REM -ExecutionPolicy Bypass applies to this invocation only; nothing machine-wide
|
||||||
REM changes. No elevation is needed for a per-user scheduled task.
|
REM changes. No elevation is needed for a per-user scheduled task.
|
||||||
powershell -NoProfile -ExecutionPolicy Bypass -File "%TARGET%\scripts\install-autostart.ps1"
|
powershell -NoProfile -ExecutionPolicy Bypass -File "%TARGET%\scripts\install-autostart.ps1"
|
||||||
if errorlevel 1 (
|
if errorlevel 1 (
|
||||||
echo [!] Auto-start setup failed. AutoFirmer still works - start it with
|
echo [!] Auto-start setup failed. AutoFirmer still works - start it with
|
||||||
echo start-autofirmer.bat, and re-run this script to try again.
|
echo start-autofirmer.bat, and re-run this script to try again.
|
||||||
set "AUTOSTART=0"
|
set "AUTOSTART=0"
|
||||||
) else (
|
) else (
|
||||||
set "AUTOSTART=1"
|
set "AUTOSTART=1"
|
||||||
)
|
)
|
||||||
goto :autostart_done
|
goto :autostart_done
|
||||||
|
|
||||||
:autostart_skipped
|
:autostart_skipped
|
||||||
echo Skipped. Run scripts\install-autostart.ps1 later to enable it.
|
echo Skipped. Run scripts\install-autostart.ps1 later to enable it.
|
||||||
set "AUTOSTART=0"
|
set "AUTOSTART=0"
|
||||||
|
|
||||||
:autostart_done
|
:autostart_done
|
||||||
|
|
||||||
REM ---------------------------------------------------------------- start file
|
REM ------------------------------------------------------- extension policy
|
||||||
> "%~dp0start-autofirmer.bat" (
|
REM Chrome refuses to side-load a CRX and will not update an unpacked folder, so
|
||||||
echo @echo off
|
REM the extension is installed the way a self-hosted one has to be: a policy
|
||||||
echo title AutoFirmer - %INSTANCE%
|
REM entry naming our update server. Written to this user's hive, which needs no
|
||||||
echo cd /d "%TARGET%"
|
REM elevation - install-extension-policy.ps1 -Scope Machine covers every account.
|
||||||
echo echo Dashboard starting on http://localhost:3000
|
echo.
|
||||||
echo call npm run start
|
echo [7/7] Chrome extension
|
||||||
echo pause
|
echo Installs it from the update server and lets Chrome keep it current
|
||||||
)
|
echo by itself. No administrator rights needed.
|
||||||
|
set "DOEXT="
|
||||||
popd
|
set /p "DOEXT= Set this up now? [Y/n] "
|
||||||
|
if /i "%DOEXT%"=="n" goto :ext_skipped
|
||||||
echo.
|
powershell -NoProfile -ExecutionPolicy Bypass -File "%TARGET%\scripts\install-extension-policy.ps1"
|
||||||
echo ============================================
|
if errorlevel 1 (
|
||||||
echo Done.
|
echo [!] Extension policy failed. Load %TARGET%\extension unpacked for now,
|
||||||
echo ============================================
|
echo and re-run scripts\install-extension-policy.ps1 to try again.
|
||||||
echo.
|
set "EXTPOLICY=0"
|
||||||
echo Instance name : %INSTANCE%
|
) else (
|
||||||
echo Reporting to : %MASTER_URL%
|
set "EXTPOLICY=1"
|
||||||
echo Installed in : %TARGET%
|
)
|
||||||
echo.
|
goto :ext_done
|
||||||
echo Dashboard at : http://localhost:3000
|
|
||||||
echo.
|
:ext_skipped
|
||||||
if "%AUTOSTART%"=="1" goto :summary_auto
|
echo Skipped. Run scripts\install-extension-policy.ps1 later, or load
|
||||||
echo Start it with : start-autofirmer.bat
|
echo %TARGET%\extension unpacked and reload it by hand after updates.
|
||||||
echo Clicker : python clicker\runner.py
|
set "EXTPOLICY=0"
|
||||||
goto :summary_manual
|
|
||||||
|
:ext_done
|
||||||
:summary_auto
|
|
||||||
echo Running now, and again at every logon ^(PM2^).
|
REM ---------------------------------------------------------------- start file
|
||||||
echo Updates : master is checked every 5 min; see scripts\update.log
|
> "%~dp0start-autofirmer.bat" (
|
||||||
echo Handy : pm2 list ^| pm2 logs autofirmer ^| pm2 logs clicker
|
echo @echo off
|
||||||
|
echo title AutoFirmer - %INSTANCE%
|
||||||
:summary_manual
|
echo cd /d "%TARGET%"
|
||||||
echo.
|
echo echo Dashboard starting on http://localhost:3000
|
||||||
echo Still manual:
|
echo call npm run start
|
||||||
echo - Load the Chrome extension: chrome://extensions, enable Developer
|
echo pause
|
||||||
echo mode, "Load unpacked", select %TARGET%\extension
|
)
|
||||||
echo ^(an update cannot reload it for you - the dashboard warns when
|
|
||||||
echo the extension or runner is behind^)
|
popd
|
||||||
echo - Add your firm credentials on the dashboard's Settings page
|
|
||||||
echo.
|
echo.
|
||||||
pause
|
echo ============================================
|
||||||
exit /b 0
|
echo Done.
|
||||||
|
echo ============================================
|
||||||
:fail
|
echo.
|
||||||
echo.
|
echo Instance name : %INSTANCE%
|
||||||
echo Setup did not complete.
|
echo Reporting to : %MASTER_URL%
|
||||||
echo.
|
echo Installed in : %TARGET%
|
||||||
pause
|
echo.
|
||||||
exit /b 1
|
echo Dashboard at : http://localhost:3000
|
||||||
|
echo.
|
||||||
|
if "%AUTOSTART%"=="1" goto :summary_auto
|
||||||
|
echo Start it with : start-autofirmer.bat
|
||||||
|
echo Clicker : python clicker\runner.py
|
||||||
|
goto :summary_manual
|
||||||
|
|
||||||
|
:summary_auto
|
||||||
|
echo Running now, and again at every logon ^(PM2^).
|
||||||
|
echo Updates : master is checked every 5 min; see scripts\update.log
|
||||||
|
echo Handy : pm2 list ^| pm2 logs autofirmer ^| pm2 logs clicker
|
||||||
|
|
||||||
|
:summary_manual
|
||||||
|
echo.
|
||||||
|
echo Still manual:
|
||||||
|
if "%EXTPOLICY%"=="1" (
|
||||||
|
echo - Restart Chrome, and remove any unpacked copy of the extension
|
||||||
|
echo ^(it shares the same id now, and Chrome will not load both^)
|
||||||
|
) else (
|
||||||
|
echo - Load the Chrome extension: chrome://extensions, enable Developer
|
||||||
|
echo mode, "Load unpacked", select %TARGET%\extension
|
||||||
|
echo ^(loaded that way it reloads itself from disk after a pull;
|
||||||
|
echo the policy install lets Chrome update it properly^)
|
||||||
|
)
|
||||||
|
echo - Add your firm credentials on the dashboard's Settings page
|
||||||
|
echo.
|
||||||
|
pause
|
||||||
|
exit /b 0
|
||||||
|
|
||||||
|
:fail
|
||||||
|
echo.
|
||||||
|
echo Setup did not complete.
|
||||||
|
echo.
|
||||||
|
pause
|
||||||
|
exit /b 1
|
||||||
|
|||||||
Reference in New Issue
Block a user