Last active
July 30, 2016 02:02
-
-
Save linroex/07b29fa08665da8c1a71b2c5341d83d9 to your computer and use it in GitHub Desktop.
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 | |
# install | |
# - Fill USERNM (Your Telegram user id) and PWD, then put this script to /usr/local/bin | |
# - Append next line to /etc/pam.d/sshd to enable ssh login notify | |
# - - session optional pam_exec.so seteuid /usr/local/bin/notify | |
# Usage | |
# - run any command and append notify cmd after it | |
# - - Ex. sudo apt-get upgrade;notify | |
# - - Ex. sudo apt-get upgrade;notify 'done :)' | |
# Be happy to use it | |
SERVER="https://notifyme.coder.tw" | |
USERNAME="" | |
PWD="" | |
DEFAULT_MSG="Job Done" | |
if [ -z ${PAM_TYPE+x} ]; then | |
curl -XPOST "$SERVER/send/$USERNAME" -d "pwd=$PWD&msg=${1:-$DEFAULT_MSG}" | |
else | |
if [ $PAM_TYPE == "open_session" ]; then | |
curl -XPOST "$SERVER/send/$USERNAME" -d "pwd=$PWD&msg=[$(hostname)][$PAM_RHOST] User $PAM_USER Login" | |
fi | |
# elif [ $PAM_TYPE == "close_session" ]; then | |
# curl -XPOST "$SERVER/send/$USERNAME" -d "pwd=$PWD&msg=[$(hostname)][$PAM_RHOST] User $PAM_USER Logout" | |
# fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
if you forgot your password, you can type /getpwd in your telegram (in bot room)