New paste: add_paste.sh
This commit is contained in:
parent
238d520bc6
commit
e8361fbba9
23
add_paste.sh
Normal file
23
add_paste.sh
Normal file
@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
|
||||
paste=$(</dev/stdin)
|
||||
filename=$1
|
||||
folder=/home/hebron/pastebin
|
||||
|
||||
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
|
Loading…
Reference in New Issue
Block a user