From 2bbe3fd19e1f057a7129365cdb4ef5e9336e977e Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Mon, 27 Mar 2023 14:41:36 -0300 Subject: src/infrastructure/config/conf.env: Use file to parameterize reconfigure(8) and report(8) scripts --- src/infrastructure/ci/git-post-receive.sh | 2 +- src/infrastructure/config/conf.env | 10 ++++++++++ src/infrastructure/config/rc.sh | 3 ++- src/infrastructure/guix/system.scm | 1 + src/infrastructure/scripts/reconfigure.sh | 7 +++++-- src/infrastructure/scripts/report.sh | 17 +++++++++++++---- 6 files changed, 32 insertions(+), 8 deletions(-) create mode 100644 src/infrastructure/config/conf.env (limited to 'src') diff --git a/src/infrastructure/ci/git-post-receive.sh b/src/infrastructure/ci/git-post-receive.sh index c00c583..65a17a5 100755 --- a/src/infrastructure/ci/git-post-receive.sh +++ b/src/infrastructure/ci/git-post-receive.sh @@ -144,7 +144,7 @@ mkdtemp() { --chown=deployer:deployer \ --delete \ -a \ - "$DIR"/ /srv/www/s/servers/ci/ + "$DIR"/ "$HTML_OUTDIR"/ci/ rm -rf "$DIR" } 1>/dev/null 2>&1 & } diff --git a/src/infrastructure/config/conf.env b/src/infrastructure/config/conf.env new file mode 100644 index 0000000..daf313c --- /dev/null +++ b/src/infrastructure/config/conf.env @@ -0,0 +1,10 @@ +#!/bin/sh + +NAME='servers' +TLD='euandre.org' +HOMEPAGE="https://$TLD/s/servers/" +HTML_OUTDIR="/srv/www/s/$NAME/" +RSYNC_ADDR='zh3051@zh3051.rsync.net' + +CGIT_URL="https://$TLD/git/$NAME/commit/?id=" +REPO_NAME="$NAME.git" diff --git a/src/infrastructure/config/rc.sh b/src/infrastructure/config/rc.sh index 996e515..abb966b 100644 --- a/src/infrastructure/config/rc.sh +++ b/src/infrastructure/config/rc.sh @@ -2,6 +2,7 @@ # shellcheck source=/dev/null . /etc/profile +. /etc/conf.env export XDG_PREFIX=~/.usr export XDG_CACHE_HOME="$XDG_PREFIX"/var/cache @@ -49,7 +50,7 @@ export RLWRAP_HOME="$XDG_CACHE_HOME"/rlwrap export GUILE_HISTORY="$XDG_STATE_HOME"/guile-history HOSTNAME="$(hostname)" -export BORG_REPO="zh3051@zh3051.rsync.net:borg/$HOSTNAME" +export BORG_REPO="$RSYNC_ADDR:borg/$HOSTNAME" export BORG_REMOTE_PATH='borg1' export BORG_PASSCOMMAND='cat /opt/secrets/borg-passphrase.txt' diff --git a/src/infrastructure/guix/system.scm b/src/infrastructure/guix/system.scm index 9257cc6..277f85a 100644 --- a/src/infrastructure/guix/system.scm +++ b/src/infrastructure/guix/system.scm @@ -418,6 +418,7 @@ ("id_rsa.pub" ,(plain-file "id_rsa.pub" (file (fmt "src/infrastructure/keys/SSH/root@~a.id_rsa.pub.stripped" tld)))) ("ssh.conf" ,(plain-file "ssh.conf" (file "src/infrastructure/config/ssh.conf"))) ("init.scm" ,(plain-file "init.scm" (file "src/infrastructure/config/init.scm"))) + ("conf.env" ,(plain-file "conf.env" (file "src/infrastructure/config/conf.env"))) ("gitconfig" ,(plain-file "gitconfig" (file "src/infrastructure/config/gitconfig"))))) (service git-daemon-service-type (git-daemon-configuration diff --git a/src/infrastructure/scripts/reconfigure.sh b/src/infrastructure/scripts/reconfigure.sh index 945f115..ed3da6f 100755 --- a/src/infrastructure/scripts/reconfigure.sh +++ b/src/infrastructure/scripts/reconfigure.sh @@ -85,8 +85,10 @@ while getopts 'nUh' flag; do done shift $((OPTIND - 1)) +# shellcheck source=/dev/null +. /etc/conf.env SHA="${1:-main}" -REPO='/srv/git/servers.git' +REPO="/srv/git/$REPO_NAME" NOW="$(date '+%Y-%m-%dT%H:%M:%S%:z')" NOW_DIR=/opt/deploy/"$NOW" NPROC=$(($(nproc) * 2 + 1)) @@ -135,6 +137,7 @@ else --chown=deployer:deployer \ -a \ --exclude='dev/ci/*' \ - /run/current-system/profile/share/doc/servers/ /srv/www/s/servers/ + /run/current-system/profile/share/doc/"$NAME"/ "$HTML_OUTDIR" + deploy fi diff --git a/src/infrastructure/scripts/report.sh b/src/infrastructure/scripts/report.sh index 54fbcd8..5c89b91 100755 --- a/src/infrastructure/scripts/report.sh +++ b/src/infrastructure/scripts/report.sh @@ -119,6 +119,15 @@ if [ -z "${OUTDIR:-}" ]; then exit 2 fi +if [ -r src/infrastructure/config/conf.env ]; then + CONF=src/infrastructure/config/conf.env +else + CONF=/etc/conf.env +fi + +# shellcheck source=/dev/null +. "$CONF" + esc() { sed \ @@ -147,9 +156,9 @@ done - + - servers - CI logs + $NAME - CI logs