Created
October 4, 2017 18:43
-
-
Save ksn135/b7a4bb3feadadce54abbf407df3c6a7d to your computer and use it in GitHub Desktop.
Send message to Telegram chat via bash script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
########################################################### | |
# UPdate SDOC production script, v0.1 # | |
# (c) October 2017 by Serg N. Kalachev <[email protected]> # | |
########################################################### | |
START_HOUR=10 | |
END_HOUR=19 | |
CUR_HOUR=`date +"%H"` | |
TELEGRAM_AUTH="<censored>:<censored>" | |
TELEGRAM_CHAT="<censord>" | |
TELEGRAM_CMD="curl --silent --show-error --fail -G -o /dev/null https://api.telegram.org/bot${TELEGRAM_AUTH}/sendMessage -d chat_id=${TELEGRAM_CHAT} " | |
SEND_MSG=1 | |
[[ "$CUR_HOUR" -ge "$END_HOUR" ]] && SEND_MSG=0 | |
[[ "$CUR_HOUR" -lt "$START_HOUR" ]] && SEND_MSG=0 | |
[[ "$SEND_MSG" == "1" ]] && ${TELEGRAM_CMD} --data-urlencode "text=Произвожу обновление системы..." | |
bin/mage deploy to:production | |
ssh sdoc "sudo /etc/init.d/apache2 restart" | |
[[ "$SEND_MSG" == "1" ]] && ${TELEGRAM_CMD} --data-urlencode "text=Обновление системы выполнено." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment