.
This commit is contained in:
2
shared/.telegramenv
Normal file
2
shared/.telegramenv
Normal file
@ -0,0 +1,2 @@
|
||||
DUFUS="1816161258:AAGNRS1t_ApXwAm0jJyms5H6H7BaJFPvyok"
|
||||
TCHATID="1462463122"
|
||||
88
shared/mykeys
Executable file
88
shared/mykeys
Executable file
@ -0,0 +1,88 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
# Common environment variables
|
||||
#
|
||||
|
||||
|
||||
check_keystore () {
|
||||
if [ ! -d ${KEYSTORE} ]
|
||||
then
|
||||
mkdir -p ${KEYSTORE}
|
||||
fi
|
||||
}
|
||||
|
||||
check_bastionkey () {
|
||||
if [ ! -f ${BASTIONKEY} ]
|
||||
then
|
||||
ssh-keygen -o -a 100 -t ed25519 -f ${BASTIONKEY} -N "" -C donkey@${NAME}
|
||||
fi
|
||||
}
|
||||
|
||||
check_gitkey () {
|
||||
if [ ! -f ${GITKEY} ]
|
||||
then
|
||||
ssh-keygen -o -a 100 -t ed25519 -f ${GITKEY} -N "" -C git@${NAME}
|
||||
fi
|
||||
}
|
||||
|
||||
check_rsynckey () {
|
||||
if [ ! -f ${RSYNCKEY} ]
|
||||
then
|
||||
ssh-keygen -o -a 100 -t ed25519 -f ${RSYNCKEY} -N "" -C rsync@${NAME}
|
||||
fi
|
||||
}
|
||||
|
||||
check_vibblerkey () {
|
||||
if [ ! -f ${VIBBLERKEY} ]
|
||||
then
|
||||
ssh-keygen -o -a 100 -t ed25519 -f ${VIBBLERKEY} -N "" -C vibbler@${NAME}
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
#####
|
||||
# Main script below
|
||||
#####
|
||||
KEYSTORE=~/.mykeys
|
||||
BASTIONKEY=${KEYSTORE}/donkeykey
|
||||
GITKEY=${KEYSTORE}/gitkey
|
||||
RSYNCKEY=${KEYSTORE}/rsynckey
|
||||
VIBBLERKEY=${KEYSTORE}/vibblerkey
|
||||
|
||||
|
||||
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/myshared ]
|
||||
then
|
||||
. ${BASE}/shared/myshared
|
||||
else
|
||||
echo "Environment file not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
SHARED=${BASE}/shared
|
||||
|
||||
. ${SHARED}/myshared
|
||||
|
||||
NAME=$(uname -n|cut -c2-4)
|
||||
LAST=$(uname -n| sed -e 's/.*\(.$\)/\1/')
|
||||
|
||||
check_keystore
|
||||
check_bastionkey
|
||||
cp -p ${BASTIONKEY}.pub ${KEYSTORE}/_d${NAME}${LAST}.pub
|
||||
|
||||
check_gitkey
|
||||
check_rsynckey
|
||||
cp -p ${RSYNCKEY}.pub ${KEYSTORE}/_r${NAME}${LAST}.pub
|
||||
check_vibblerkey
|
||||
cp -p ${VIBBLERKEY}.pub ${KEYSTORE}/_v${NAME}${LAST}.pub
|
||||
36
shared/myshared
Normal file
36
shared/myshared
Normal file
@ -0,0 +1,36 @@
|
||||
# Common environment variables
|
||||
#
|
||||
set_constants () {
|
||||
MYNAME=$(uname -n)
|
||||
DATENOW=$(date '+%Y%m%d-%H%M%S')
|
||||
|
||||
THIS_SCRIPT=`basename $0`
|
||||
THIS_PATH=`dirname $0`
|
||||
LOCK=/var/tmp/${THIS_SCRIPT}.lock
|
||||
LOG=/var/tmp/${THIS_SCRIPT}.log
|
||||
ERROR=/var/tmp/${THIS_SCRIPT}.error.$$
|
||||
|
||||
APP=${THIS_SCRIPT}
|
||||
VERSION=
|
||||
}
|
||||
|
||||
|
||||
################### shared functions below
|
||||
|
||||
get_myip () {
|
||||
# dig not installed on alpine
|
||||
#MYEXTERNALIP=$(dig +short myip.opendns.com @resolver1.opendns.com)
|
||||
#MYEXTERNALIP=$(curl checkip.dyndns.org| awk -F'<' '{print $7 }'| awk -F' ' '{ print $4 }')
|
||||
MYEXTERNALIP=$(curl ipinfo.io/ip)
|
||||
MYFULLIP=$(ip route get 8.8.8.8 | sed -n '/src/{s/.*src *\([^ ]*\).*/\1/p;q}')
|
||||
MYNETWORK=$(echo ${MYFULLIP}| cut -f1-3 -d.)
|
||||
MYIP=$(echo ${MYFULLIP}| cut -f4 -d.)
|
||||
echo "MYEXTERNALIP ${MYEXTERNALIP}"
|
||||
echo "MYFULLIP ${MYFULLIP}"
|
||||
echo "MYIP ${MYIP}"
|
||||
echo "MYNETWORK ${MYNETWORK}"
|
||||
echo ""
|
||||
|
||||
export MYFULLIP MYNETWORK MYIP MYEXTERNALIP
|
||||
}
|
||||
######
|
||||
44
shared/tfile
Executable file
44
shared/tfile
Executable file
@ -0,0 +1,44 @@
|
||||
#!/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}
|
||||
33
shared/tmsg
Executable file
33
shared/tmsg
Executable file
@ -0,0 +1,33 @@
|
||||
#!/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
|
||||
MYNAME=`uname -n`
|
||||
|
||||
SUBJECT=" ${MYNAME} - ${SCRIPT}: "
|
||||
|
||||
DROP='{"chat_id": "'"${TCHATID}"'", "text": " '"${SUBJECT}"' '"${MSG}"'"}'
|
||||
curl -X POST \
|
||||
-H 'content-type: application/json' \
|
||||
-d "${DROP}" \
|
||||
https://api.telegram.org/bot${DUFUS}/sendmessage
|
||||
|
||||
rm -f ${MSG}
|
||||
Reference in New Issue
Block a user