From d2295e738ab6032747f74338c4cfef7ed165649a Mon Sep 17 00:00:00 2001 From: TudbuT Date: Sun, 9 Jun 2024 12:08:48 +0200 Subject: [PATCH] use sftp for uploading --- .forgejo/workflows/build-client.yml | 3 +++ .forgejo/workflows/build-loader.yml | 3 +++ .forgejo/workflows/build-server.yml | 3 +++ Server/upload_key.pub | 1 + push_file.sh | 14 ++++---------- push_file.sh.old | 15 +++++++++++++++ 6 files changed, 29 insertions(+), 10 deletions(-) create mode 100644 Server/upload_key.pub create mode 100644 push_file.sh.old diff --git a/.forgejo/workflows/build-client.yml b/.forgejo/workflows/build-client.yml index eb1c330..f07b8a0 100644 --- a/.forgejo/workflows/build-client.yml +++ b/.forgejo/workflows/build-client.yml @@ -47,7 +47,10 @@ jobs: - name: Release to server if: github.ref == 'refs/heads/release' env: + SSH_PRIVATEKEY: ${{ secrets.SSH_PRIVATEKEY }} GPG_PRIVATEKEY: ${{ secrets.GPG_PRIVATEKEY }} BB_HOST: ${{ vars.BB_HOST }} + BB_PORT: ${{ vars.BB_PORT }} + BB_PATH: ${{ vars.BB_PATH }} run: bash push_file.sh Client/build/proguard/BaseBand-Broadway.jar 3849 diff --git a/.forgejo/workflows/build-loader.yml b/.forgejo/workflows/build-loader.yml index f622dd2..ecfd295 100644 --- a/.forgejo/workflows/build-loader.yml +++ b/.forgejo/workflows/build-loader.yml @@ -38,6 +38,9 @@ jobs: - name: Release to server if: github.ref == 'refs/heads/release' env: + SSH_PRIVATEKEY: ${{ secrets.SSH_PRIVATEKEY }} GPG_PRIVATEKEY: ${{ secrets.GPG_PRIVATEKEY }} BB_HOST: ${{ vars.BB_HOST }} + BB_PORT: ${{ vars.BB_PORT }} + BB_PATH: ${{ vars.BB_PATH }} run: bash push_file.sh Loader/build/proguard/BaseBand-Loader.jar 3848 diff --git a/.forgejo/workflows/build-server.yml b/.forgejo/workflows/build-server.yml index 0f33638..8632743 100644 --- a/.forgejo/workflows/build-server.yml +++ b/.forgejo/workflows/build-server.yml @@ -32,6 +32,9 @@ jobs: - name: Release to server if: github.ref == 'refs/heads/release' env: + SSH_PRIVATEKEY: ${{ secrets.SSH_PRIVATEKEY }} GPG_PRIVATEKEY: ${{ secrets.GPG_PRIVATEKEY }} BB_HOST: ${{ vars.BB_HOST }} + BB_PORT: ${{ vars.BB_PORT }} + BB_PATH: ${{ vars.BB_PATH }} run: bash push_file.sh Server/build/libs/BaseBand-Server.jar 3847 diff --git a/Server/upload_key.pub b/Server/upload_key.pub new file mode 100644 index 0000000..f0a0bd3 --- /dev/null +++ b/Server/upload_key.pub @@ -0,0 +1 @@ +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFrYCr6lzT4/dza0pEse9HjToHSZRktKwQuBP6wf1FXi tudbut@TudbuT-Arch diff --git a/push_file.sh b/push_file.sh index 1115897..37284f5 100644 --- a/push_file.sh +++ b/push_file.sh @@ -3,13 +3,7 @@ # DO NOT RUN THIS MANUALLY. PUSH TO RELEASE INSTEAD. ( <- unless there is an emergency.) -curl "https://data.tudbut.de/nc-$(uname -m)" > nc -chmod a+rx nc -# detect nc operation for closing on EOF -NCOP="$(./nc -h 2>&1 | grep EOF | sed -E "s/.*\W(-.).*/\1/g" | head -n1)" - -echo "$GPG_PRIVATEKEY" | gpg --import -( - gpg --trust-model always -sear BaseBand -u BaseBand < $1 - sleep 1 -) | ./nc $NCOP $BB_HOST $2 +echo "$SSH_PRIVATEKEY" > ssh_key +chmod 700 ssh_key +scp -i ssh_key -P "$BB_PORT" "$1" "root@$BB_HOST:$BB_PATH" +rm ssh_key \ No newline at end of file diff --git a/push_file.sh.old b/push_file.sh.old new file mode 100644 index 0000000..1115897 --- /dev/null +++ b/push_file.sh.old @@ -0,0 +1,15 @@ +#!/bin/bash + +# DO NOT RUN THIS MANUALLY. PUSH TO RELEASE INSTEAD. ( <- unless there is an emergency.) + + +curl "https://data.tudbut.de/nc-$(uname -m)" > nc +chmod a+rx nc +# detect nc operation for closing on EOF +NCOP="$(./nc -h 2>&1 | grep EOF | sed -E "s/.*\W(-.).*/\1/g" | head -n1)" + +echo "$GPG_PRIVATEKEY" | gpg --import +( + gpg --trust-model always -sear BaseBand -u BaseBand < $1 + sleep 1 +) | ./nc $NCOP $BB_HOST $2