2023-09-24 20:10:09 -06:00
|
|
|
#!/usr/bin/env bash
|
2026-10-14 15:51:40 -06:00
|
|
|
echo "Debian install start: $(date '+%Y-%m-%d %H:%M:%S')"
|
2023-09-24 20:10:09 -06:00
|
|
|
|
|
|
|
|
set -x
|
|
|
|
|
set -e
|
|
|
|
|
|
2026-07-22 18:41:59 -06:00
|
|
|
# Run the install in a predictable UTF-8 locale. Fresh images (or SSH sessions
|
|
|
|
|
# forwarding LC_* variables from the client) may reference an ungenerated
|
|
|
|
|
# locale, which makes apt/perl/python emit "Cannot set LC_CTYPE" warnings
|
|
|
|
|
# throughout the install. C.UTF-8 is built into glibc, always present, and
|
|
|
|
|
# locale-neutral, so this does not change the user's configured locale.
|
|
|
|
|
export LC_ALL=C.UTF-8
|
|
|
|
|
|
2023-09-24 20:10:09 -06:00
|
|
|
# Update if we haven't updated in the last day.
|
|
|
|
|
[ -z "$(find -H /var/lib/apt/lists -maxdepth 0 -mtime -1)" ] && apt update
|
|
|
|
|
# Install dependencies.
|
2023-10-03 19:21:12 -06:00
|
|
|
apt-get install -y $(cat /opt/wrolpi/debian-live-config/config/package-lists/wrolpi.list.chroot)
|
2023-09-24 20:10:09 -06:00
|
|
|
|
|
|
|
|
# App dependencies were installed.
|
|
|
|
|
node -v
|
|
|
|
|
npm -v
|
|
|
|
|
|
2026-07-23 18:10:52 -06:00
|
|
|
# Install serve, and archiving tools. Check each independently so a present
|
|
|
|
|
# single-file cannot mask a missing serve (which breaks wrolpi-app).
|
|
|
|
|
command -v serve >/dev/null || sudo npm i -g serve@12.0.1
|
|
|
|
|
single-file --version >/dev/null 2>&1 || sudo npm i -g single-file-cli@2.0.73
|
|
|
|
|
command -v readability-extractor >/dev/null || sudo npm i -g readability-extractor@0.0.6
|
2023-09-24 20:10:09 -06:00
|
|
|
|
Single file deno (#478)
* Singlefile runs under Deno 2.8.3; browser leftovers are reaped.
single-file-cli is designed for Deno. Under node 18 (Debian 12/RPi OS) it
cannot reach the browser CDP on IPv6-enabled hosts ("localhost" resolves to
::1 first with no IPv4 fallback) and it never exits after a successful save,
blocking the download worker forever.
The native path and the Archive docker container now run single-file with
"deno run". Deno is pinned at v2.8.3 everywhere because yt-dlp 2026.06.09
requires at least 2.3.0 (our node is Debian's v18, below yt-dlp's v22
minimum). Deno >= 2.3 kills the browser single-file spawns (piped stderr
that single-file never reads), so the browser is run through
singlefile_browser_wrapper.sh which discards its stderr.
Commands are run in their own process group which is killed when they
finish, reaping the browser single-file leaves behind. The Archive
downloader now has a ten minute timeout. Install scripts install Deno
(previously only upgrade.sh and the image builds did).
* Singlefile writes to a file instead of dumping to stdout.
Deno >= 2.3 truncates large --dump-content output at exit; compressed
(SingleFileZ) singlefiles of large pages lost their ZIP tail, failed the
compression check in write_archive_files, and were destroyed by the HTML
prettifier (blank white archives). single-file now writes its result to a
temporary file which WROLPi reads back.
As insurance, a singlefile marked compressed (<html data-sfz) whose ZIP is
unreadable is now stored verbatim instead of being prettified.
* Compressed Archive screenshots and readability images are no longer broken.
The index.html inside a compressed (SingleFileZ) singlefile references its
resources by relative ZIP paths. Screenshots are now taken from the fully
extracted ZIP so those references resolve. Readability images are inlined
as data URIs read from the ZIP (readability-extractor absolutizes relative
srcs against the page URL, so both forms are matched).
* Compressed Archives are created by converting the uncompressed capture.
The page is always captured uncompressed; readability, screenshot, and
title come from that canonical page (its images are inline data URIs, so
no ZIP extraction or image inlining is needed). When compress_singlefile
is set, a second single-file run converts the captured file into a
compressed (SingleFileZ) self-extracting file. The conversion is a local
file:// operation - the page is not fetched again, and single-file
preserves the original URL header when re-saving its own pages. If the
conversion fails, the uncompressed singlefile is stored instead.
* Consolidating duplicate compressed-singlefile tests.
The write_archive_files tests (verbatim write, title fallback, broken-ZIP
guard, readability inlining) are combined into one test; the helper probes
and the setting-plumbing tests are each merged into one. The do_singlefile
compression-failure scenario and the timeout constant are folded into the
main do_singlefile test, which shared their setup.
* Addressing review comments: removeprefix, PermissionError when killing.
* Bumping version to 0.24.1-beta.
* Install scripts assert the deno.zip hash to avoid malicious or invalid files.
The hashes are the official sha256sum assets of the Deno v2.8.3 release,
per architecture.
* Archive Dockerfile asserts the deno.zip hash to avoid malicious or invalid files.
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-06-12 17:07:10 -06:00
|
|
|
# Install Deno runtime; single-file runs under it.
|
|
|
|
|
command -v deno || {
|
|
|
|
|
DENO_VERSION="v2.8.3"
|
|
|
|
|
ARCH=$(uname -m)
|
|
|
|
|
if [ "$ARCH" = "aarch64" ]; then
|
|
|
|
|
DENO_ARCH="aarch64-unknown-linux-gnu"
|
|
|
|
|
DENO_SHA256="d4589cc1ffcbf1995c92a0127d932aaf832ac70cfdcc6d5b7bf38043cf303575"
|
|
|
|
|
else
|
|
|
|
|
DENO_ARCH="x86_64-unknown-linux-gnu"
|
|
|
|
|
DENO_SHA256="30455b845ffa6082209c3590269c910ad3b7efdf28c9879afd4006c47ae54197"
|
|
|
|
|
fi
|
|
|
|
|
curl -fsSL "https://github.com/denoland/deno/releases/download/${DENO_VERSION}/deno-${DENO_ARCH}.zip" -o /tmp/deno.zip
|
|
|
|
|
# Assert the hash to avoid malicious or invalid files.
|
|
|
|
|
echo "${DENO_SHA256} /tmp/deno.zip" | sha256sum -c -
|
|
|
|
|
unzip -o /tmp/deno.zip -d /usr/local/bin/
|
|
|
|
|
chmod +x /usr/local/bin/deno
|
|
|
|
|
rm /tmp/deno.zip
|
|
|
|
|
}
|
|
|
|
|
deno --version
|
|
|
|
|
|
2023-09-24 20:10:09 -06:00
|
|
|
# Build React app in background job.
|
|
|
|
|
cd /opt/wrolpi/app || exit 5
|
|
|
|
|
npm install || npm install || npm install || npm install # try install multiple times :(
|
|
|
|
|
|
|
|
|
|
# Install python requirements in background job.
|
|
|
|
|
python3 -m venv /opt/wrolpi/venv
|
2024-07-31 15:01:31 -06:00
|
|
|
/opt/wrolpi/venv/bin/pip3 install --upgrade -r /opt/wrolpi/requirements.txt
|
2023-09-24 20:10:09 -06:00
|
|
|
|
2026-07-22 18:30:26 -06:00
|
|
|
# Create the Controller venv (kept separate from the main API venv).
|
|
|
|
|
python3 -m venv /opt/wrolpi/controller/venv
|
|
|
|
|
/opt/wrolpi/controller/venv/bin/pip3 install --upgrade -r /opt/wrolpi/controller/requirements.txt
|
|
|
|
|
|
2023-10-03 19:21:12 -06:00
|
|
|
# Create the WROLPi user
|
|
|
|
|
grep wrolpi: /etc/passwd || useradd -md /home/wrolpi wrolpi -s "$(command -v bash)"
|
|
|
|
|
|
Replace nginx with Caddy for TLS termination and reverse proxying.
- Replace nginx with Caddy as the web server for both Docker and native
(RPi/Debian) deployments. Caddy handles HTTPS termination, reverse
proxying to all services (API, React app, Controller, Kiwix, Help, Map),
and serves the media/download file browsers.
- Generate a Root CA and signed leaf certificates for HTTPS. The Root CA
uses Name Constraints to restrict signing to local addresses only
(.local, localhost, and RFC 1918 private IP ranges), mitigating MITM
risk if the CA key is compromised.
- Add an HTTP landing page that guides users through one-time CA
certificate installation on iOS, Android, macOS, Windows, Linux, and
Firefox, with auto-redirect when the cert is already trusted.
- Add trailing-slash redirects for /controller, /docs, /media, and
/download so bare paths don't fall through to the React catch-all.
- Add a Root CA download link on the Settings page under Configs.
- Update help.sh diagnostics for IPv6 listener detection and HTTP/2
status codes.
- Remove all nginx config files and the https_proxy Docker container.
- Bump wrolpi-help submodule with certificate documentation.
2026-03-07 12:08:27 -07:00
|
|
|
# Install Caddy from official apt repo if not already installed.
|
|
|
|
|
if ! command -v caddy &>/dev/null; then
|
2026-07-05 13:02:59 -06:00
|
|
|
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | gpg --batch --yes --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
|
Replace nginx with Caddy for TLS termination and reverse proxying.
- Replace nginx with Caddy as the web server for both Docker and native
(RPi/Debian) deployments. Caddy handles HTTPS termination, reverse
proxying to all services (API, React app, Controller, Kiwix, Help, Map),
and serves the media/download file browsers.
- Generate a Root CA and signed leaf certificates for HTTPS. The Root CA
uses Name Constraints to restrict signing to local addresses only
(.local, localhost, and RFC 1918 private IP ranges), mitigating MITM
risk if the CA key is compromised.
- Add an HTTP landing page that guides users through one-time CA
certificate installation on iOS, Android, macOS, Windows, Linux, and
Firefox, with auto-redirect when the cert is already trusted.
- Add trailing-slash redirects for /controller, /docs, /media, and
/download so bare paths don't fall through to the React catch-all.
- Add a Root CA download link on the Settings page under Configs.
- Update help.sh diagnostics for IPv6 listener detection and HTTP/2
status codes.
- Remove all nginx config files and the https_proxy Docker container.
- Bump wrolpi-help submodule with certificate documentation.
2026-03-07 12:08:27 -07:00
|
|
|
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | tee /etc/apt/sources.list.d/caddy-stable.list
|
|
|
|
|
apt-get update
|
|
|
|
|
apt-get install -y caddy
|
|
|
|
|
fi
|
|
|
|
|
|
2023-11-22 11:02:30 -07:00
|
|
|
# Install WROLPi Help.
|
2023-11-23 15:49:01 -07:00
|
|
|
/opt/wrolpi/scripts/install_help_service.sh
|
2023-11-22 11:02:30 -07:00
|
|
|
|
2023-09-24 20:10:09 -06:00
|
|
|
# Repair will install configs and restart services.
|
|
|
|
|
/opt/wrolpi/repair.sh
|
|
|
|
|
|
|
|
|
|
set +x
|
|
|
|
|
|
|
|
|
|
echo "
|
|
|
|
|
|
|
|
|
|
WROLPi has successfully been installed!
|
|
|
|
|
|
2026-10-14 15:51:40 -06:00
|
|
|
Browse to http://$(hostname).local to choose the drive for your library, or join
|
|
|
|
|
the WiFi hotspot:
|
2023-09-24 20:10:09 -06:00
|
|
|
SSID: WROLPi
|
|
|
|
|
Password: wrolpi hotspot
|
|
|
|
|
|
|
|
|
|
"
|