#!/bin/sh # Installs the pixel command line for the person who runs it, with no administrator rights: # # curl -fsSL | sh # # It puts the command line under your home folder, with a private Node runtime from nodejs.org when # this computer has no Node 22 or later, and checks the SHA-256 of every download before anything is # put in place. Run the same line again to update; a run that stops leaves the previous install as it # was. Linux and macOS (macOS is built and checked, but has not been run on a Mac). # # Overrides (environment variables): # PIXEL_INSTALL_DIR= where the files go (default ~/.pixel) # PIXEL_BIN_DIR= where the pixel launcher goes (default ~/.local/bin) # PIXEL_NO_MODIFY_PATH=1 leave shell profiles alone, even when the launcher is not on PATH # PIXEL_PRIVATE_NODE=1 download Node even when this computer has Node 22 or later # PIXEL_NODE_MIRROR= where Node is downloaded from (default https://nodejs.org/dist) # PIXEL_INSTALL_ORIGIN= where pixel.cjs is downloaded from (default: where this script came from) # # To remove it, delete the install folder, the launcher, and the PATH line this script added to your # shell profile (it says which file). set -eu main() { portal_url='https://pxsignage.com' origin='https://cli.pxsignage.com' release='2026.10.64' bundle_sha256='1f3bab4fadc2c45a0a4b6603ac9310333faaefa316d10ec3c0412a31b41ce11f' node_version='24.22.3' # Character ranges in the checks below mean ASCII only in the C locale. LC_ALL=C export LC_ALL say() { printf '%s\n' "$*"; } stop() { printf 'Install stopped: %s\n' "$*" >&2 exit 1 } # A value written into the launcher or a profile line, in single quotes for sh. quote() { printf "'%s'" "$(printf '%s' "$1" | sed "s/'/'\\\\''/g")"; } is_address() { case $1 in http://?* | https://?*) ;; *) return 1 ;; esac case $1 in *[!A-Za-z0-9.:/_~-]*) return 1 ;; esac } is_absolute() { case $1 in /*) return 0 ;; *) return 1 ;; esac; } # Plain http to another computer, as pixel login judges it: anyone on the way can change what comes back. is_unencrypted_remote() { case $1 in http://*) ;; *) return 1 ;; esac host_port=${1#http://} case ${host_port%%/*} in localhost | localhost:* | 127.0.0.1 | 127.0.0.1:* | '[::1]' | '[::1]:'*) return 1 ;; esac } verify() { actual=$(sha256_of "$1") [ "$actual" = "$2" ] || stop "$3 does not match its SHA-256 (expected $2, got $actual), so nothing was changed." } node_is_recent() { "$1" -e 'process.exit(Number(process.versions.node.split(".")[0]) >= 22 ? 0 : 1)' >/dev/null 2>&1 } install_dir=${PIXEL_INSTALL_DIR:-$HOME/.pixel} bin_dir=${PIXEL_BIN_DIR:-$HOME/.local/bin} mirror=${PIXEL_NODE_MIRROR:-https://nodejs.org/dist} mirror=${mirror%/} origin=${PIXEL_INSTALL_ORIGIN:-$origin} origin=${origin%/} is_absolute "$install_dir" || stop "PIXEL_INSTALL_DIR must be an absolute path." is_absolute "$bin_dir" || stop "PIXEL_BIN_DIR must be an absolute path." is_address "$origin" || stop "PIXEL_INSTALL_ORIGIN must be an http or https address of plain letters, digits and . : / _ ~ -." is_address "$mirror" || stop "PIXEL_NODE_MIRROR must be an http or https address of plain letters, digits and . : / _ ~ -." # A warning, not a refusal: such installs exist, and someone who can change the download can delete a refusal too. if is_unencrypted_remote "$origin"; then printf 'Warning: %s is plain http, so the connection is not encrypted: what this installer downloads can be changed on the way, and its checks cannot catch that. Use it on a network you trust, or serve the portal over https.\n' "$origin" >&2 fi case $(uname -s) in Linux) os=linux ;; Darwin) os=darwin ;; MINGW* | MSYS* | CYGWIN*) stop "This is Windows: run install.ps1 from the same address in PowerShell instead." ;; *) stop "This installer is for Linux and macOS, and this is $(uname -s)." ;; esac case $(uname -m) in x86_64 | amd64) arch=x64 ;; aarch64 | arm64) arch=arm64 ;; *) arch= ;; esac # A Terminal under Rosetta reports x86_64 on Apple silicon; the arm64 build runs natively there. if [ "$os" = darwin ] && [ "$arch" = x64 ] && [ "$(sysctl -n sysctl.proc_translated 2>/dev/null || true)" = 1 ]; then arch=arm64; fi target= no_private_node= if [ -z "$arch" ]; then no_private_node="nodejs.org has no Node build for $(uname -s) on $(uname -m)" else target=$os-$arch if [ "$os" = linux ]; then for loader in /lib/ld-musl-*; do if [ -e "$loader" ]; then no_private_node="This is Linux with musl (such as Alpine), which the nodejs.org builds do not run on"; fi done fi fi if command -v curl >/dev/null 2>&1; then fetch() { curl -fsSL -o "$2" "$1"; } elif command -v wget >/dev/null 2>&1; then fetch() { wget -q -O "$2" "$1"; } else stop "Neither curl nor wget is installed, so nothing can be downloaded." fi if command -v sha256sum >/dev/null 2>&1; then sha256_of() { sha256sum <"$1" | cut -d ' ' -f 1; } elif command -v shasum >/dev/null 2>&1; then sha256_of() { shasum -a 256 <"$1" | cut -d ' ' -f 1; } else stop "Neither sha256sum nor shasum is installed, so the downloads cannot be checked. Install one of them, then run this again." fi node_bin= if [ "${PIXEL_PRIVATE_NODE:-}" != 1 ] && system_node=$(command -v node 2>/dev/null) && node_is_recent "$system_node"; then node_bin=$system_node node_said="Node $("$system_node" --version) at $system_node" fi private_node=$install_dir/node/bin/node new_node= if [ -z "$node_bin" ]; then [ -z "$no_private_node" ] || stop "$no_private_node. Install Node 22 or later, then run this again." node_bin=$private_node node_said="a private Node $node_version" if [ ! -x "$private_node" ] || [ "$("$private_node" --version 2>/dev/null || true)" != "v$node_version" ]; then new_node=1; fi fi mkdir -p "$install_dir" "$bin_dir" staging=$install_dir/.update.$$ rm -rf "$staging" mkdir "$staging" trap 'rm -rf "$staging"' EXIT trap 'exit 130' INT TERM say "Downloading pixel $release from $origin" fetch "$origin/pixel.cjs" "$staging/pixel.cjs" || stop "Could not download $origin/pixel.cjs." verify "$staging/pixel.cjs" "$bundle_sha256" "The downloaded pixel.cjs" runner=$node_bin if [ -n "$new_node" ]; then case $target in linux-x64) node_sha256='061ec3e3062115705b56b51fa9cc330ab50d34b6969387d4e4b1a50c6809acc2' ;; linux-arm64) node_sha256='261af2af250dfd7e9f25cf151d1b2713a0adf8f10a9ad116c4947f68627affe8' ;; darwin-x64) node_sha256='977614af0504c81045e7fd85596dbca0e5f951b96681516dadafedcca8c447f7' ;; darwin-arm64) node_sha256='ff6e17d4874b76d272212b908cc020d6e815fba5a6c7eaaa06add725840307fd' ;; esac archive=node-v$node_version-$target say "Downloading Node $node_version for $target from $mirror" fetch "$mirror/v$node_version/$archive.tar.gz" "$staging/node.tar.gz" || stop "Could not download $mirror/v$node_version/$archive.tar.gz." verify "$staging/node.tar.gz" "$node_sha256" "The downloaded Node archive" mkdir "$staging/unpack" "$staging/node" tar -xzf "$staging/node.tar.gz" -C "$staging/unpack" "$archive/bin/node" "$archive/LICENSE" || stop "Could not unpack the Node archive." mv "$staging/unpack/$archive/bin" "$staging/unpack/$archive/LICENSE" "$staging/node/" runner=$staging/node/bin/node fi printf '{\n "url": "%s",\n "origin": "%s",\n "release": "%s"\n}\n' "$portal_url" "$origin" "$release" >"$staging/install.json" printed=$("$runner" "$staging/pixel.cjs" version 2>&1) || { case $printed in *libatomic.so.1*) stop "Node $node_version needs the libatomic1 library, which this computer does not have. Install it (for example: sudo apt-get install libatomic1), or install Node 22 or later yourself, then run this again." ;; esac stop "The downloaded command line did not run on this computer: $printed" } case $printed in "pixel $release "*) ;; *) stop "The downloaded command line says it is \"$printed\", not release $release." ;; esac if [ -n "$new_node" ]; then rm -rf "$install_dir/node.old" if [ -d "$install_dir/node" ]; then mv "$install_dir/node" "$install_dir/node.old"; fi mv "$staging/node" "$install_dir/node" rm -rf "$install_dir/node.old" elif [ "$node_bin" != "$private_node" ] && [ -x "$private_node" ]; then rm -rf "$install_dir/node" fi mv -f "$staging/pixel.cjs" "$install_dir/pixel.cjs" mv -f "$staging/install.json" "$install_dir/install.json" launcher=$bin_dir/.pixel.$$ printf '#!/bin/sh\nexec %s %s "$@"\n' "$(quote "$node_bin")" "$(quote "$install_dir/pixel.cjs")" >"$launcher" chmod 755 "$launcher" mv -f "$launcher" "$bin_dir/pixel" path_said= case ":$PATH:" in *":$bin_dir:"*) ;; *) if [ "${PIXEL_NO_MODIFY_PATH:-}" = 1 ]; then path_said="$bin_dir is not on your PATH, and PIXEL_NO_MODIFY_PATH=1 left your shell profile alone: add it to PATH, or run $bin_dir/pixel." else case ${SHELL:-} in */zsh) profile=$HOME/.zshrc ;; */bash) if [ "$os" = darwin ]; then profile=$HOME/.bash_profile; else profile=$HOME/.bashrc; fi ;; *) profile=$HOME/.profile ;; esac line="export PATH=$(quote "$bin_dir"):\"\$PATH\"" if [ -f "$profile" ] && grep -Fqx "$line" "$profile"; then path_said="$profile already puts $bin_dir on PATH. Open a new terminal to use pixel." else printf '\n# Added by the pixel installer\n%s\n' "$line" >>"$profile" path_said="Added $bin_dir to PATH in $profile. Open a new terminal to use pixel." fi fi ;; esac say "Installed pixel $release in $install_dir, run by $node_said." say "The launcher is $bin_dir/pixel." if [ -n "$path_said" ]; then say "$path_said"; fi if is_unencrypted_remote "$portal_url"; then say "Next, sign in: pixel login --allow-http (the portal's address is plain http, so pixel login needs --allow-http to send your key there)" else say "Next, sign in: pixel login" fi } main "$@"