pastesrv.sh (692B)
1 #!/usr/bin/env bash
2 # SPDX-License-Identifier: AGPL-3.0-or-later
3 # SPDX-FileCopyrightText: 2024 JayVii <jayvii[AT]posteo[DOT]de>
4 # SPDX-FileCopyrightText: 2024 Codemadness <hiltjo[AT]codemadness[DOT]org>
5
6 # put following function in your ~/.bashrc and adjust accordingly
7
8 pastesrv() {
9 # configuration: adjust accordingly
10 SSH_PASTESRV="paste[AT]paste[DOT]example.com"
11 WEB_PASTESRV="https://paste.example.com"
12 # set default file name if none is given
13 TMP=$(date +%s)
14 HASH=$(echo "$TMP $RANDOM" | sha256sum | awk '{ print $1 }')
15 # forward stdin to the server
16 ssh "$SSH_PASTESRV" "cat > ~/paste/${1:-$HASH}"
17 # output for user
18 echo "File available under: $WEB_PASTESRV/${1:-$HASH}"
19 }