Compare commits
4 Commits
e0881dac90
...
c14625b26e
Author | SHA1 | Date |
---|---|---|
Cesura | c14625b26e | 2 years ago |
Cesura | 0eff189cd9 | 2 years ago |
Serge van Ginderachter | 3ae36db717 | 2 years ago |
WolfwithSword | 914a250a40 | 2 years ago |
@ -1,6 +1,8 @@
|
||||
FROM tensorflow/tensorflow:2.2.0
|
||||
FROM tensorflow/tensorflow:2.5.0
|
||||
WORKDIR /app
|
||||
COPY requirements.txt /app
|
||||
RUN mkdir -p /app/data && pip install -r /app/requirements.txt
|
||||
COPY . /app/
|
||||
RUN pip install -r /app/requirements.txt
|
||||
EXPOSE 5000
|
||||
WORKDIR /app
|
||||
ENTRYPOINT ["python3","app.py"]
|
||||
ENV PASTEY_DATA_DIRECTORY=/app/data
|
||||
ENTRYPOINT ["python3", "app.py"]
|
||||
|
@ -1,4 +1,4 @@
|
||||
Flask==1.1.2
|
||||
Flask-Limiter==1.4
|
||||
guesslang==2.0.1
|
||||
guesslang==2.2.1
|
||||
cryptography==3.4.7
|
After Width: | Height: | Size: 53 KiB |
After Width: | Height: | Size: 33 KiB |
After Width: | Height: | Size: 19 KiB |
After Width: | Height: | Size: 25 KiB |
After Width: | Height: | Size: 35 KiB |
After Width: | Height: | Size: 51 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 56 KiB |
After Width: | Height: | Size: 54 KiB |
After Width: | Height: | Size: 76 KiB |
After Width: | Height: | Size: 21 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 43 KiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 62 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 40 KiB |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 53 KiB |
After Width: | Height: | Size: 33 KiB |
After Width: | Height: | Size: 19 KiB |
After Width: | Height: | Size: 25 KiB |
After Width: | Height: | Size: 35 KiB |
After Width: | Height: | Size: 51 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 56 KiB |
After Width: | Height: | Size: 47 KiB |
After Width: | Height: | Size: 76 KiB |
After Width: | Height: | Size: 21 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 43 KiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 62 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 40 KiB |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 22 KiB |
@ -1,19 +1,234 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Install this script into your PATH and chmod +x
|
||||
# Usage example:
|
||||
# $ cat /var/log/nginx.log | pastey
|
||||
# c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t
|
||||
# vi: set shiftwidth=4 tabstop=4 noexpandtab:
|
||||
# :indentSize=4:tabSize=4:noTabs=false:
|
||||
|
||||
if ! command -v curl &> /dev/null ; then
|
||||
echo "Please install curl to use this script"
|
||||
exit 1
|
||||
fi
|
||||
# script framework based on https://betterdev.blog/minimal-safe-bash-script-template/
|
||||
# initially adapted and written by Serge van Ginderachter <serge@vanginderachter.be>
|
||||
|
||||
set -Eeo pipefail
|
||||
#execute=(echo popo)trap cleanup SIGINT SIGTERM ERR EXIT
|
||||
|
||||
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
|
||||
|
||||
# your custom endpoint
|
||||
PASTEY_ENDPOINT="{{ endpoint }}"
|
||||
PASTEY_CONTENT=$(</dev/stdin)
|
||||
|
||||
# Submit paste
|
||||
PASTEY_LINK=$(curl -s -X POST -H "Content-Type: text/plain" --data "${PASTEY_CONTENT}" "${PASTEY_ENDPOINT}")
|
||||
#
|
||||
## functions
|
||||
|
||||
usage() {
|
||||
cat <<-EOF
|
||||
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
|
||||
|
||||
Script description here.
|
||||
|
||||
Available options:
|
||||
|
||||
-h, --help Print this help and exit
|
||||
-v, --verbose Print script debug info
|
||||
-c, --content Pass the content of the paste in a simple argument
|
||||
-e, --encrypt Encrypt the paste content
|
||||
-f, --file Read the content from this file. If file is "-", read from stdin
|
||||
-s, --single Create a paste that expires after the first view
|
||||
-t, --title Set the title of the paste
|
||||
-x, --expiration
|
||||
Set the time in hours after which the paste expires
|
||||
|
||||
-- Stop further option parsing
|
||||
Arguments passed after the -- option are evaluated
|
||||
as a command, and that command's output is pasted.
|
||||
The full command is used a the title.
|
||||
|
||||
If zero arguments are passed,
|
||||
or none of --content, --file or -- are passed,
|
||||
content is read from stdin.
|
||||
|
||||
EOF
|
||||
exit
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
trap - SIGINT SIGTERM ERR EXIT
|
||||
msg "Some unhandled error happened.\n"
|
||||
usage
|
||||
}
|
||||
|
||||
msg() {
|
||||
echo >&2 -e "${1-}"
|
||||
}
|
||||
|
||||
die() {
|
||||
local msg=$1
|
||||
local code=${2-1} # default exit status 1
|
||||
msg "$msg\n"
|
||||
exit "$code"
|
||||
}
|
||||
|
||||
parse_params() {
|
||||
# check required params and arguments
|
||||
|
||||
|
||||
expiration=
|
||||
content=
|
||||
title=
|
||||
file=
|
||||
single="false"
|
||||
encrypt="false"
|
||||
|
||||
while (( "$#" ))
|
||||
do
|
||||
case "${1-}" in
|
||||
|
||||
-h | --help)
|
||||
usage
|
||||
;;
|
||||
|
||||
-v | --verbose)
|
||||
set -x
|
||||
;;
|
||||
|
||||
-t | --title)
|
||||
shift || :
|
||||
title="${1}"
|
||||
shift || :
|
||||
;;
|
||||
|
||||
-c | --content)
|
||||
shift || :
|
||||
content="${1}"
|
||||
shift || :
|
||||
;;
|
||||
|
||||
-f | --file)
|
||||
shift || :
|
||||
file="${1}"
|
||||
shift || :
|
||||
;;
|
||||
-x | --expiration)
|
||||
shift || :
|
||||
expiration="${1}"
|
||||
shift || :
|
||||
;;
|
||||
|
||||
-s | --single)
|
||||
shift || :
|
||||
single="true"
|
||||
;;
|
||||
|
||||
-e | --encrypt)
|
||||
shift || :
|
||||
encrypt="true"
|
||||
;;
|
||||
|
||||
--)
|
||||
shift || :
|
||||
execute=($*)
|
||||
shift $#
|
||||
;;
|
||||
|
||||
-?*)
|
||||
die "Unknown option: $1"
|
||||
shift || :
|
||||
;;
|
||||
|
||||
*)
|
||||
if [[ -n "${1:-}" ]]
|
||||
then
|
||||
die "Unknown parameter: $1"
|
||||
fi
|
||||
;;
|
||||
|
||||
esac
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
parse_options(){
|
||||
|
||||
# warn if both single and expiration are set
|
||||
if [[ -n "${expiration}" ]] && [[ -n "${single}" ]]
|
||||
then
|
||||
die "option -x|--expiration and -s|--single are mutually exclusive"
|
||||
fi
|
||||
|
||||
# warn if more than 1 source
|
||||
if [[ -n "${content}" && -n "${file}" ]] ||
|
||||
[[ -n "${content}" && -n "${execute[*]}" ]] ||
|
||||
[[ -n "${execute[*]}" && -n "${file}" ]]
|
||||
then
|
||||
die "option -c|--content, -f|--file and -- <command> are mutually exclusive"
|
||||
fi
|
||||
|
||||
if [[ -z "${content}" ]]
|
||||
then
|
||||
if [[ -n "${file}" ]]
|
||||
then
|
||||
if [[ ${file} = "-" ]]
|
||||
then
|
||||
content="$(</dev/stdin)"
|
||||
elif [ -r ${file} ]
|
||||
then
|
||||
content="$(cat ${file} | tr -d '\0')"
|
||||
else
|
||||
die "Could not read from ${file}"
|
||||
fi
|
||||
elif [[ -n "${execute[*]}" ]]
|
||||
then
|
||||
content="$( bash -c "${execute[*]}" 2>&1 ||: )"
|
||||
else
|
||||
content="$(</dev/stdin)"
|
||||
fi
|
||||
fi
|
||||
|
||||
# expiration needs to be set to disabled
|
||||
if [ -z "${expiration}" ]
|
||||
then
|
||||
expiration="-1"
|
||||
fi
|
||||
|
||||
# alternative titles if possible
|
||||
if [ -z "${title}" ]
|
||||
then
|
||||
if [ -n "${file}" ]
|
||||
then
|
||||
title="${file}"
|
||||
elif [ -n "${execute[*]}" ]
|
||||
then
|
||||
title="${execute[@]}"
|
||||
fi
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
|
||||
# just do it now
|
||||
paste_it() {
|
||||
|
||||
content=$(echo -n "${content}" | base64)
|
||||
payload="{
|
||||
\"content\": \"${content}\",
|
||||
\"title\": \"${title}\",
|
||||
\"expiration\": \"${expiration}\",
|
||||
\"encrypt\": ${encrypt},
|
||||
\"single\": ${single},
|
||||
\"base64\": true
|
||||
}"
|
||||
|
||||
echo -n $payload | curl \
|
||||
-X POST \
|
||||
-H "Content-Type: application/json" \
|
||||
--data-binary @- \
|
||||
${PASTEY_ENDPOINT}; echo
|
||||
}
|
||||
|
||||
## main execution
|
||||
|
||||
parse_params $*
|
||||
parse_options
|
||||
paste_it
|
||||
|
||||
# Print link
|
||||
echo "${PASTEY_LINK}"
|
||||
# exit cleanly
|
||||
trap - SIGINT SIGTERM ERR EXIT
|
||||
exit 0
|
||||
|