#!/bin/sh . /etc/rc.sh ||: set -eu usage() { cat <<-'EOF' Usage: reconfigure [-n] [-U] [SHA] EOF } UPDATE=false DRY_RUN=false while getopts 'nU' flag; do case "$flag" in (n) DRY_RUN=true ;; (U) UPDATE=true ;; (*) usage >&2 exit 2 ;; esac done shift $((OPTIND - 1)) SHA="${1:-origin/main}" if [ "$UPDATE" = true ] && [ "$DRY_RUN" = false ]; then guix pull -v3 fi if [ "$DRY_RUN" = true ]; then ACTION=build DEPLOY_OPT=-n else ACTION=reconfigure DEPLOY_OPT= fi cd /opt/server git fetch git checkout "$SHA" untill -m3 guix system -v3 "$ACTION" /etc/guix/system.scm cicd add $DEPLOY_OPT /srv/git/*.git