From 5d36dd69cfc9fe3dbc4e9c3559031d370f86dcc1 Mon Sep 17 00:00:00 2001 From: RMcTn Date: Mon, 18 Sep 2023 10:09:28 +0100 Subject: [PATCH] Move scripts to makefile --- Makefile | 14 ++++++++++++++ build-for-x64-linux.sh | 2 -- deploy_binary_to_host.sh | 12 ------------ 3 files changed, 14 insertions(+), 14 deletions(-) create mode 100644 Makefile delete mode 100755 build-for-x64-linux.sh delete mode 100755 deploy_binary_to_host.sh diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..f034791 --- /dev/null +++ b/Makefile @@ -0,0 +1,14 @@ +USER = root + +build-for-server: + cargo zigbuild --target x86_64-unknown-linux-gnu --release + +deploy-to-prod: + @if [ -z ${WHAT_BIN_HOST} ]; then\ + echo "WHAT_BIN_HOST must be set" && exit 1;\ + fi + ssh ${USER}@${WHAT_BIN_HOST} "mkdir -p /root/what-bin-is-it/archive" + scp -r ./target/x86_64-unknown-linux-gnu/release/server ${USER}@${WHAT_BIN_HOST}:/root/what-bin-is-it/server-new + ssh ${USER}@${WHAT_BIN_HOST} "mv /root/what-bin-is-it/server /root/what-bin-is-it/archive/server_$(date +"%Y%m%d%H%M%S")" + ssh ${USER}@${WHAT_BIN_HOST} "mv /root/what-bin-is-it/server-new /root/what-bin-is-it/server" + ssh ${USER}@${WHAT_BIN_HOST} "systemctl restart whatbin" diff --git a/build-for-x64-linux.sh b/build-for-x64-linux.sh deleted file mode 100755 index 42aecbd..0000000 --- a/build-for-x64-linux.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -cargo zigbuild --target x86_64-unknown-linux-gnu --release diff --git a/deploy_binary_to_host.sh b/deploy_binary_to_host.sh deleted file mode 100755 index 970d6da..0000000 --- a/deploy_binary_to_host.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -# Is this a ridiculous deployment method? Yes. Does it work? Yes. -# Is it a workaround for slow cross compile times until I setup something better? Yes. -if [ -z $1 ]; then - echo "Need to provide a host"; -else - ssh root@$1 "mkdir -p /root/what-bin-is-it/archive" - scp -r ./target/x86_64-unknown-linux-gnu/release/server root@$1:/root/what-bin-is-it/server-new - ssh root@$1 "mv /root/what-bin-is-it/server /root/what-bin-is-it/archive/server_$(date +"%Y%m%d%H%M%S")" - ssh root@$1 "mv /root/what-bin-is-it/server-new /root/what-bin-is-it/server" - ssh root@$1 "systemctl restart whatbin" -fi