pub / pastesrv

Paste service setup for paste.jayvii.de
git clone https://src.jayvii.de/pub/pastesrv.git
Home | Log | Files | Exports | Refs | README | RSS

commit 16131703d49971ba2ef40193115d5fc0552fda7a
Author: JayVii <jayvii[AT]posteo[DOT]de>
Date:   Sat, 29 Jun 2024 12:16:47 +0200

feat: initial version of pastesrv

Diffstat:
AREADME | 57+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Apastesrv-apache.conf | 9+++++++++
Apastesrv.sh | 12++++++++++++
3 files changed, 78 insertions(+), 0 deletions(-)

diff --git a/README b/README @@ -0,0 +1,57 @@ +pastesrv +======== + +Please send patches or remarks to <jayvii[AT]posteo[DOT]de> + +Super simple selfhosted paste server inspired / copy-cat'ed from: +https://www.codemadness.org/paste-service.html + +Setup +----- + +Let's assume you are running Debian on your server, OpenSSH is already setup +and you are using Apache as your webserver with "paste.example.com". + +Create a new user for the paste service on your server: + + useradd -d /var/www/pastesrv -G www-data -m paste + mkdir -p /var/www/pastesrv/paste + chown paste:www-data -R /var/www/pastesrv + chmod 770 -R /var/www/pastesrv + +Optionally, set a password for the "paste" user. Or, better yet use an SSH-key. +See: https://wiki.archlinux.org/title/SSH_keys + +Copy the apache-config and edit it accordingly + + cp pastesrv-apache.conf /etc/apache2/sites-available/ + # now edit it accordingly + a2ensite pastesrv-apache + +The service is ready now. Next, setup your client accordingly. The codemadness +blog has a nifty bash-function (https://www.codemadness.org/paste-service.html), +which I adapted a little bit. You can also find it in this repository as +"pastesrv.sh": + + pastesrv() { + # set default file name if none is given + HASH=$(date +%s | sha256sum | awk '{ print $1 }') + # forward stdin to the server + ssh paste[AT]paste[DOT]example.com "cat > ~/paste/${1:-$HASH}" + # output for user + echo "https://paste.example.com/${1:-$HASH}" + } + +The function reads from stdin, so whatever you pipe to it, will be send to the +paste-service: + + # sending the current date to the server as unnamed paste + date | pastesrv + + # sending some script file to the server as named paste + cat my_script.sh | pastesrv "check_out_my_script.sh" + + # make a screenshot (wayland) and upload it immediately + grim - | pastesrv + + diff --git a/pastesrv-apache.conf b/pastesrv-apache.conf @@ -0,0 +1,9 @@ +<VirtualHost *:80> + ServerName paste.example.com + DocumentRoot /var/www/pastesrv/paste + + <Directory /var/www/paste.example.com> + AllowOverride All + </Directory> + +</VirtualHost> diff --git a/pastesrv.sh b/pastesrv.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +# put following function in your ~/.bashrc + +pastesrv() { + # set default file name if none is given + HASH=$(date +%s | sha256sum | awk '{ print $1 }') + # forward stdin to the server + ssh paste[AT]paste[DOT]example.com "cat > ~/paste/${1:-$HASH}" + # output for user + echo "https://paste.example.com/${1:-$HASH}" +}