Authentication-Results: mail-b.sr.ht; dkim=pass header.d=secluded.site header.i=@secluded.site Received: from mx.nixnet.email (mx.nixnet.email [94.16.121.167]) by mail-b.sr.ht (Postfix) with ESMTPS id 3DCC611EFC9 for <~whereswaldon/arbor-dev@lists.sr.ht>; Thu, 21 Jul 2022 03:10:34 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by mx.nixnet.email (Postfix) with ESMTPSA id 165E4202861; Wed, 20 Jul 2022 23:10:31 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=secluded.site; s=202002021149; t=1658373032; h=from:from:reply-to:subject:subject:to:to:cc:cc; bh=GIP/bs/2FlNxYpVwjNn21+7lKAnU7SRiBZ2Q8NH2iS4=; b=PCaTkwvZQXdSrK7cxC9IbQwQa6ZaxI1YBzIlVsD919nxF41zgI2i1hgVIh3MrgdBaX6ZUS Gm6JqlSZLsOIzpZZx/5v7cbNL5ZNEyItBlO4UK6bOoPnOT1LHLW7SstxtcFkyzRfUFk0RC yPzsum6pZ+lZfpjmIq1fsxOZn/ftLN8= From: Amolith To: ~whereswaldon/arbor-dev@lists.sr.ht Cc: Amolith Subject: [PATCH 02/12] Build relay from source & clean up temp dirs Date: Wed, 20 Jul 2022 23:09:51 -0400 Message-Id: <20220721031001.97027-3-amolith@secluded.site> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220721031001.97027-1-amolith@secluded.site> References: <20220721031001.97027-1-amolith@secluded.site> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Signed-off-by: Amolith --- deploy.sh | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) mode change 100644 => 100755 deploy.sh diff --git a/deploy.sh b/deploy.sh old mode 100644 new mode 100755 index 9532400..14e9f9b --- a/deploy.sh +++ b/deploy.sh @@ -1,33 +1,45 @@ #!/bin/sh set -e -function usage { - echo $0 [ip] +usage() { + echo "$0 [server.ip.address]" } if [[ "$1" == "" ]]; then - usage; exit 1; + usage + exit 1 fi echo "NOTE: In order to run this script your ssh key must have root access to the instance." echo "Your machine must also have mage installed and configured so that the bootstrap magefile can be built." echo "Press enter to continue" -read junk +read -r junk -WORKDIR=$(dirname $0) +WORKDIR=$(dirname "$0") RETURN=$(pwd) -echo "Building mage image" -cd $PWD +TEMPDIR=$(mktemp -d) -mage -compile deploy/mage +echo "Building relay binary" -tar czvf mage.tar.gz deploy +curl --tlsv1.2 -o "$TEMPDIR/gover" https://git.sr.ht/~whereswaldon/gover/blob/main/gover +chmod +x "$TEMPDIR/gover" +PREFIX=$TEMPDIR/ "$TEMPDIR/gover" -scp mage.tar.gz "root@$1:" +git clone --depth=1 https://git.sr.ht/~whereswaldon/sprout-go "$TEMPDIR/sprout-go" +cd "$TEMPDIR/sprout-go/cmd/relay" && "$TEMPDIR/bin/go" build && mv -v ./relay "$WORKDIR/files/relay" -ssh "root@$1" tar xzvf mage.tar.gz +echo "Building mage binary" +cd "$WORKDIR" +mage -compile mage -ssh "root@$1" sh -c "pwd && cd deploy && ./mage deploy" +scp mage "root@$1:" + +ssh root@"$1" sh -c "./mage deploy" + +cd "$RETURN" +rm -rf "$TEMPDIR" + +echo "Deploy finished!" -- 2.37.1