generated from pavel.muhortov/template-bash
added sending config to telegram
This commit is contained in:
parent
cd2450cf72
commit
1cfe3156bb
|
@ -129,6 +129,39 @@ startsendmail() {
|
|||
addtologs "sent mail with subject '${subj}' to ${dest}"
|
||||
}
|
||||
|
||||
#######################################
|
||||
# Send telegram notification about client config.
|
||||
# Globals:
|
||||
# clientname
|
||||
# faqprofile
|
||||
# ovpncfgdir
|
||||
# API_KEY
|
||||
# CHAT_ID
|
||||
# THRD_ID
|
||||
# Arguments:
|
||||
# None
|
||||
#######################################
|
||||
# shellcheck disable=SC2030,2031
|
||||
startsendtlgm() {
|
||||
(
|
||||
API_URL="https://api.telegram.org/bot${API_KEY}/sendMediaGroup?chat_id=${CHAT_ID}"
|
||||
|
||||
if grep -q "_" <<< "${CHAT_ID}"; then
|
||||
THRD_ID=$(printf "%s\n" "${CHAT_ID}" | cut -d_ -f2)
|
||||
CHAT_ID=$(printf "%s\n" "${CHAT_ID}" | cut -d_ -f1)
|
||||
fi
|
||||
if [ -n "${THRD_ID}" ]; then
|
||||
API_URL="${API_URL}&message_thread_id=${THRD_ID}"
|
||||
fi
|
||||
|
||||
curl "${API_URL}" \
|
||||
-F "media=[{\"type\": \"document\", \"media\": \"attach://qr\", \"caption\": \"${faqprofile}\", \"parse_mode\": \"Markdown\"}, {\"type\": \"document\", \"media\": \"attach://cf\" }]" \
|
||||
-F "qr=@/etc/wireguard/${clientname}.png" \
|
||||
-F "cf=@/etc/wireguard/${clientname}.conf"
|
||||
) > /dev/null 2>&1
|
||||
addtologs "sent telegram media with ${clientname}.conf client profile to ${CHAT_ID}"
|
||||
}
|
||||
|
||||
#######################################
|
||||
# Create wireguard client certificates.
|
||||
# Globals:
|
||||
|
@ -297,6 +330,7 @@ if checkroot; then
|
|||
createconf
|
||||
createinfo
|
||||
startsendmail
|
||||
startsendtlgm
|
||||
fi
|
||||
if [ "${resetforce}" -eq 1 ];then
|
||||
addtologs "restarting wg-quick@${iface_name}..."
|
||||
|
|
Loading…
Reference in New Issue
Block a user