#!/usr/bin/env bash # Bootstrap the signed ServeUP repository on Ubuntu 22.04 amd64. set -euo pipefail channel=stable repository_only=false for arg in "$@"; do case "$arg" in --channel=stable|--channel=beta|--channel=dev) channel=${arg#*=} ;; --repository-only) repository_only=true ;; --help|-h) printf 'Usage: sudo bash install.sh [--repository-only] [--channel=stable|beta|dev]\n' exit 0 ;; *) printf 'Unknown option: %s\n' "$arg" >&2; exit 2 ;; esac done if [[ $(id -u) != 0 ]]; then printf 'Run this downloaded script with sudo bash.\n' >&2 exit 1 fi source /etc/os-release if [[ ${ID:-} != ubuntu || ${VERSION_ID:-} != 22.04 || $(dpkg --print-architecture) != amd64 ]]; then printf 'This installer currently supports Ubuntu 22.04 on x64 only. No changes made.\n' >&2 exit 1 fi work=$(mktemp -d) trap 'rm -rf "$work"' EXIT umask 022 mkdir -m 700 "$work/gnupg" printf 'Preparing ServeUP repository setup...\n' if ! command -v curl >/dev/null || ! command -v gpg >/dev/null || ! dpkg-query -W -f='${Status}' ca-certificates 2>/dev/null | grep -q 'install ok installed'; then apt-get update apt-get install -y --no-install-recommends ca-certificates curl gnupg fi curl --proto '=https' --tlsv1.2 --fail --show-error --silent --location \ --connect-timeout 15 --max-time 120 \ https://repo.serveup.software/repo.pub -o "$work/key.asc" fingerprints=$(gpg --homedir "$work/gnupg" --batch --show-keys --with-colons "$work/key.asc" | \ awk -F: '$1=="pub" {primary=1; next} $1=="fpr" && primary {print $10; primary=0}') if [[ "$fingerprints" != E54A85CBB1B9E9193C8D2A0EDD031DD93A4A1807 ]]; then printf 'ServeUP signing key verification failed. Repository was not added.\n' >&2 exit 1 fi gpg --homedir "$work/gnupg" --batch --dearmor --output "$work/serveup.gpg" "$work/key.asc" install -d -m 755 /etc/apt/keyrings install -m 644 "$work/serveup.gpg" /etc/apt/keyrings/serveup.gpg cat > "$work/serveup.sources" <<'SOURCES' Types: deb URIs: https://repo.serveup.software Suites: jammy Components: main Architectures: amd64 Signed-By: /etc/apt/keyrings/serveup.gpg SOURCES install -m 644 "$work/serveup.sources" /etc/apt/sources.list.d/serveup.sources # Accept the documented Ubuntu-to-ServeUP branding change for this source only. apt-get update --allow-releaseinfo-change-origin --allow-releaseinfo-change-label \ -o Dir::Etc::sourcelist=/etc/apt/sources.list.d/serveup.sources \ -o Dir::Etc::sourceparts=- -o APT::Get::List-Cleanup=0 \ -o APT::Update::Error-Mode=any printf 'ServeUP signing key and repository are configured.\n' if "$repository_only"; then exit 0; fi package=serveup-pos if [[ "$channel" != stable ]]; then package="serveup-pos-$channel"; fi candidate=$(apt-cache policy "$package" | awk '/Candidate:/ {print $2}') if [[ -z "$candidate" || "$candidate" == '(none)' ]]; then printf 'The %s installer package has not been published yet. Repository setup is complete.\n' "$channel" >&2 printf 'Once released, run: sudo apt update && sudo apt install %s\n' "$package" >&2 exit 3 fi apt-get update apt-get install -y "$package" printf 'ServeUP POS is installed. Open it from your application menu.\n'