31 lines
1.5 KiB
Bash
Executable file
31 lines
1.5 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
# Copyright © 2022 Thorsten Schubert <tschubert@bafh.org>
|
|
|
|
set -eo pipefail
|
|
|
|
shopt -s nullglob
|
|
|
|
readonly BUILDHOST=casx1
|
|
readonly ENDPOINT=electra
|
|
readonly CONTAINER=tcpaste-dev
|
|
readonly SECRET_KV=pass:casx1
|
|
readonly SSH='command ssh -B'
|
|
readonly SCP="command scp"
|
|
readonly CARGO_ARGS="+nightly build -Z build-std=panic_abort,core,std,alloc,proc_macro -Z build-std-features=panic_immediate_abort --target x86_64-unknown-linux-gnu --manifest-path=/workspaces/tcpaste/Cargo.toml --release"
|
|
readonly TARGETS=(tcp-{pasted,erased,expire,filter,filter-adm})
|
|
|
|
get-secret() {
|
|
local -r kv=$1;
|
|
readarray -td \: arr < <(printf "%s\0" "$kv");
|
|
secret-tool lookup "${arr[0]}" "${arr[1]}"
|
|
}
|
|
|
|
set -x
|
|
$SSH -- "${USER}@${BUILDHOST}" /usr/bin/podman start $CONTAINER
|
|
$SSH -- "${USER}@${BUILDHOST}" /usr/bin/podman exec --workdir /workspaces/tcpaste $CONTAINER /usr/local/cargo/bin/cargo $CARGO_ARGS
|
|
$SSH -- "${USER}@${ENDPOINT}" rm -vf -- ${TARGETS[@]/#/tmp/}
|
|
$SCP -- "${TARGETS[@]/#/${USER}@${BUILDHOST}:repos/tcpaste/target/x86_64-unknown-linux-gnu/release/}" "${USER}@${ENDPOINT}:/tmp"
|
|
echo "$(get-secret "${SECRET_KV}")" | $SSH -- "${USER}@${ENDPOINT}" /usr/bin/sudo -S "sh -c 'systemctl stop tcp-erased.service tcp-pasted.service && cp -vft /usr/local/bin/ ${TARGETS[@]/#//tmp/} && rm -f -- ${TARGETS[@]/#//tmp/} && systemctl start tcp-erased.service tcp-pasted.service'"
|
|
echo "$(get-secret "${SECRET_KV}")" | $SSH -- "${USER}@${ENDPOINT}" systemctl is-active tcp-erased.service tcp-pasted.service
|