#!/usr/bin/env bash # Chinaski CMS - one-line bootstrap installer # # Online install (Debian/Ubuntu, uses apt for pre-compiled Perl packages): # curl -fsSL https://www.chinaski.net/install.sh | sudo bash -s -- # Example: curl -fsSL https://www.chinaski.net/install.sh | sudo bash -s -- 1 # # Offline-compatible install (any Linux, bundles vendored CPAN deps): # curl -fsSL https://www.chinaski.net/install.sh | sudo bash -s -- --offline [OPTIONS] # Example: curl -fsSL https://www.chinaski.net/install.sh | sudo bash -s -- --offline --prefix /srv/chinaski # # Online options (forwarded to deploy/install.sh): # Required. Alphanumeric name for this install (e.g. 1, prod) # --port PORT Daemon listen port (default: 3000+N for numeric N, else 3001) # --dir DIR Install directory (default: /var/www/chinaski) # # Offline options (forwarded to install/install.sh): # --prefix DIR Install root directory (default: current working directory) # --no-service Skip systemd unit installation # --site-url URL Seed the site_url setting in the database # # The --offline bundle is ~50 MB and includes vendored CPAN source tarballs # so Perl modules can be compiled without internet access. It requires a C # compiler, make, and image libraries (libjpeg, libpng, libgif). On Debian: # apt-get install -y make gcc libjpeg-dev libpng-dev libgif-dev set -euo pipefail BASE_URL="https://www.chinaski.net/dist" OFFLINE=0 PASS_ARGS=() while [[ $# -gt 0 ]]; do case "$1" in --offline) OFFLINE=1; shift ;; *) PASS_ARGS+=("$1"); shift ;; esac done if [[ "$(id -u)" -ne 0 ]]; then echo "error: Chinaski installer must be run as root" >&2 echo " curl -fsSL https://www.chinaski.net/install.sh | sudo bash -s -- ..." >&2 exit 1 fi TMP="$(mktemp -d)" trap 'rm -rf "$TMP"' EXIT if [[ "$OFFLINE" -eq 1 ]]; then echo "==> Chinaski: downloading offline bundle (~50 MB)..." curl -fsSL --progress-bar "$BASE_URL/chinaski-latest.tar.gz" \ | tar -xz -C "$TMP" --strip-components=1 echo "==> Running offline installer..." exec bash "$TMP/install.sh" "${PASS_ARGS[@]}" else if [[ "${#PASS_ARGS[@]}" -eq 0 ]]; then echo "error: instance name required" >&2 echo " curl -fsSL https://www.chinaski.net/install.sh | sudo bash -s -- " >&2 echo " e.g. sudo bash -s -- 1" >&2 exit 1 fi echo "==> Chinaski: downloading source archive..." curl -fsSL --progress-bar "$BASE_URL/chinaski-latest-src.tar.gz" \ | tar -xz -C "$TMP" --strip-components=1 echo "==> Running installer..." exec bash "$TMP/deploy/install.sh" "${PASS_ARGS[@]}" --src "$TMP" fi