New paste: add_paste.sh

This commit is contained in:
Thomas Jensen 2020-04-30 10:25:54 +02:00
parent ef2dce7256
commit c7a8810ee8
3 changed files with 26 additions and 2 deletions

1
1u8gNc
View File

@ -1 +0,0 @@
test

26
add_paste.sh Normal file
View File

@ -0,0 +1,26 @@
#!/bin/bash
paste=$(</dev/stdin)
filename=$1
folder=/home/hebron/pastebin
url=https://git.homelab.no/thomasjsn/pastebin/src/branch/master
cd $folder
git pull
if [ -z "$filename" ]; then
filename=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 6 | head -n 1)
fi
if [ -f "$folder/$filename" ]; then
echo "Paste already exists!"
exit 1
fi
echo "$paste" > $folder/$filename
git add .
git commit -m "New paste: $filename"
git push
echo "$url/$filename"

1
pA87wr
View File

@ -1 +0,0 @@
test