45 lines
846 B
Bash
Executable File
45 lines
846 B
Bash
Executable File
#!/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}/shared/.telegramenv ]
|
|
then
|
|
. ${BASE}/shared/.telegramenv
|
|
else
|
|
echo "Environment file not found"
|
|
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}
|