Skip to content

Commit 49a8a13

Browse files
author
quibie
authored
Telegram-cli integration (#6)
* Add telegram-cli integration
1 parent 834e83e commit 49a8a13

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ Then add following line to your /etc/pam.d/sshd file:
99
session optional pam_exec.so /root/shelltracer/exec.sh
1010
```
1111

12+
## (Optional) Telegram-integration
13+
To send notifications via telegram, the telegram-cli is required. (https://github.com/vysheng/tg).
14+
You need to initiate the telegram-cli once and register yourself with your mobilenumber.
15+
A user name must be activated in the telegram account on the mobile device.
16+
17+
Edit your information in the config file.
18+
19+
1220
## Demo
1321

1422
![screenshot_lockscreen](https://cloud.githubusercontent.com/assets/3774136/18708456/2b20a088-7ffb-11e6-9381-ac06e43553ab.png)

config.sample

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
PUSHOVER_TOKEN_APP="your_pushover_app_token"
44
PUSHOVER_TOKEN_USER="your_pushover_user_token"
55

6+
# installed telegram-cli is needed
7+
USE_TELEGRAM="NO"
8+
TELEGRAM_ACCOUNT_NAME="your_telegram_account_name"
9+
TELEGRAM=/bin/telegram-bin
10+
TELEGRAM_SERVER_KEY=/etc/telegram-bin/server.pub
11+
12+
613
TITLE="Shelltracer"
714

815
LOGFILE=/var/log/shelltracer/log-trace.log
@@ -20,3 +27,4 @@ HOSTNAME=/bin/hostname
2027
W=/usr/bin/w
2128
AWK=/usr/bin/awk
2229

30+

notify.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@ SCRIPT_DIR=`dirname $0`
55

66
PUSHOVER_TITLE="$1"
77
PUSHOVER_MESSAGE="$2"
8+
FILE_TO_SEND="$3"
89
PUSHOVER_URL="https://api.pushover.net/1/messages.json"
910

1011
${CURL} -s -F "token=${PUSHOVER_TOKEN_APP}" -F "user=${PUSHOVER_TOKEN_USER}" -F "title=${PUSHOVER_TITLE}" -F "message=${PUSHOVER_MESSAGE}" ${PUSHOVER_URL} >> ${LOGFILE} 2>&1
12+
13+
if [ $USE_TELEGRAM = "YES" ]; then
14+
${TELEGRAM} -W ${TELEGRAM_SERVER_KEY} -e "send_text $TELEGRAM_ACCOUNT_NAME $FILE_TO_SEND" >> ${LOGFILE} 2>&1
15+
fi
16+
1117
echo >> ${LOGFILE}

tracer.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,6 @@ fi
6363

6464
PUSHOVER_TITLE=$TITLE
6565
PUSHOVER_MESSAGE=`cat $LOGFILE_TEMP`
66-
${SCRIPT_DIR}/notify.sh "${PUSHOVER_TITLE}" "${PUSHOVER_MESSAGE}"
66+
${SCRIPT_DIR}/notify.sh "${PUSHOVER_TITLE}" "${PUSHOVER_MESSAGE}" "${LOGFILE_TEMP}"
6767

6868
exit_program "${ACTION} END"

0 commit comments

Comments
 (0)