#!/usr/bin/env bash # Xiracom laptop enrolment - run once as the installer user: # curl -fsSL https://enroll.xiracom.co.ke/enroll.sh | sudo bash # 1. creates the break-glass admin (xiradmin) # 2. creates this laptop's read-only deploy key for the config repo # 3. stores the NetBird setup key root-only # 4. runs ansible-pull, which then keeps the laptop in policy every 30 min set -euo pipefail # Wrapped in main() so the whole script is read before it runs; this lets it be # piped from curl while prompts still read from the keyboard (/dev/tty). main() { exec /dev/null 2>&1; then useradd -m -s /bin/bash -G sudo "$ADMIN" echo ">> Set the break-glass password for $ADMIN (IT keeps it in the vault):" until passwd "$ADMIN"; do :; done fi if [ ! -f /etc/xiracom/deploy_key ]; then ssh-keygen -q -t ed25519 -N "" -C "endpoint-config@$(hostname)" -f /etc/xiracom/deploy_key fi echo echo ">> Send this line to IT so it can be added as a read-only deploy key:" echo cat /etc/xiracom/deploy_key.pub echo read -rp ">> Press Enter once IT confirms the key is added... " _ if [ ! -s /etc/xiracom/netbird-setup-key ]; then read -rsp ">> NetBird setup key: " NBKEY; echo printf '%s' "$NBKEY" > /etc/xiracom/netbird-setup-key fi if [ ! -s /etc/xiracom/ldap-bind-password ]; then read -rsp ">> LDAP service account password (svc-sssd): " LDAPPW; echo printf '%s' "$LDAPPW" > /etc/xiracom/ldap-bind-password fi chmod 600 /etc/xiracom/* apt-get update -qq apt-get install -y -qq ansible-core git openssh-client export GIT_SSH_COMMAND="ssh -i /etc/xiracom/deploy_key -o IdentitiesOnly=yes -o StrictHostKeyChecking=accept-new" ansible-pull -U "$REPO" -C main -d /var/lib/endpoint-config -i localhost, laptop/site.yml echo echo ">> Enrolled. Only '$ADMIN' can use sudo from now on." netbird status | head -5 || true } main "$@"