#!/bin/bash # Source os-release if [[ -r /etc/os-release ]]; then . /etc/os-release else echo "Cannot determine OS (missing /etc/os-release)" >&2 exit 1 fi # Major version only OSVER="${VERSION_ID%%.*}" ARCH="$(uname -m)" REPO_BASE_URL="https://repo.spictera.se/deb" REPO_URL="${REPO_BASE_URL}/${ID}/${OSVER}/${ARCH}" KEY_URL="${REPO_BASE_URL}/spictera_repo.gpg.key" # The public key file you exported earlier KEY_PATH="/usr/share/keyrings/spictera-archive-keyring.gpg" LIST_PATH="/etc/apt/sources.list.d/spictera.list" REPO_LINE="deb [signed-by=${KEY_PATH}] ${REPO_URL} ./" # Check for root privileges if [ "$(id -u)" != "0" ] then echo "This script must be run as root or with sudo." 1>&2 exit 1 fi echo "--- 1. Downloading and installing GPG public key ---" # Use curl or wget to download the ASCII-armored key and convert it to binary format if command -v curl > /dev/null then curl -sSL "$KEY_URL" | gpg --dearmor -o "$KEY_PATH" elif command -v wget > /dev/null then wget -qO- "$KEY_URL" | gpg --dearmor -o "$KEY_PATH" else echo "Error: Neither wget nor curl found. Please install one of them." exit 1 fi if [ $? -eq 0 ] then echo "GPG key installed successfully to $KEY_PATH." else echo "Failed to download/install GPG key." exit 1 fi echo "--- 2. Adding APT repository entry ---" # Check if the repository line already exists before adding if ! grep -q "^${REPO_LINE}" "$LIST_PATH" 2> /dev/null then echo "$REPO_LINE" | tee "$LIST_PATH" > /dev/null echo "Repository line added to $LIST_PATH." else echo "Repository line already exists in $LIST_PATH." fi echo "--- 3. Updating APT package index ---" apt update echo "--- Installation complete! ---" echo "You can now install packages from Spictera repo, e.g., 'apt install '"