This commit is contained in:
2022-06-26 10:10:04 +01:00
parent f9b061fdc2
commit df77e53e2f
3 changed files with 149 additions and 32 deletions

47
shared/_tfile Executable file
View File

@ -0,0 +1,47 @@
#!/bin/sh
if [ -d /zTools/zPrivateConfig/shared ] && [ ! -d /static ]
then
BASE=/zTools/zPrivateConfig/shared
fi
if [ ! -d /zTools/zPrivateConfig/shared ] && [ -d /static ]
then
BASE=/static
fi
if [ -f ${BASE}/secrets/.telegramenv ]
then
. ${BASE}/secrets/.telegramenv
else
echo "Created ${BASE}/secrets/.telegramenv"
echo "Please update contents and rerun"
echo "DUFUS="" " > ${BASE}/secrets/.telegramenv
echo "TCHATID="" " >> ${BASE}/secrets/.telegramenv
exit 1
fi
SCRIPT=$1
MSG=$2
FILETOSEND=$3
MYNAME=`uname -n`
MSG=/var/tmp/${THIS_SCRIPT}.msg.$$
#if [ -e ${ERROR} ]
# then
# echo "---error_log_start" >> ${MSG}
# cat ${ERROR} >> ${MSG}
# echo "---error_log_finish" >> ${MSG}
SUBJECT=" ${MYNAME} - ${SCRIPT}: "
cat ${FILETOSEND} > ${MSG}.txt
FILE='document=@'"${MSG}.txt"
curl -X POST \
-F ${FILE} \
-F "chat_id=${TCHATID}" \
-F "caption=${SUBJECT} ${MSG}" \
https://api.telegram.org/bot${DUFUS}/sendDocument
rm -f ${MSG}