mirror of
https://github.com/guezoloic/serverconfig.git
synced 2026-01-25 04:34:23 +00:00
fix: add few functions
- create send_notification function - auto scripts/*.sh scripts searcher
This commit is contained in:
@@ -56,10 +56,7 @@ install_file() {
|
|||||||
}
|
}
|
||||||
echo
|
echo
|
||||||
datetime_print "------------- install files -------------"
|
datetime_print "------------- install files -------------"
|
||||||
install_file "aws-backup.sh" "$SCRIPT_FILE" -Dm755
|
for element in scripts/*.sh; do install_file "$(basename $element)" "$SCRIPT_FILE" -Dm755; done
|
||||||
install_file "disk-monitor.sh" "$SCRIPT_FILE" -Dm755
|
|
||||||
install_file "sshd-login.sh" "$SCRIPT_FILE" -Dm755
|
|
||||||
install_file "telegram.sh" "$SCRIPT_FILE" -Dm755
|
|
||||||
install_file "docker-compose.yml" "$ETC_DIR" -Dm644
|
install_file "docker-compose.yml" "$ETC_DIR" -Dm644
|
||||||
|
|
||||||
create_env_variable() {
|
create_env_variable() {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
source /etc/serverconfig/.env
|
source /usr/local/bin/notifications.sh
|
||||||
|
|
||||||
disk_usage() {
|
disk_usage() {
|
||||||
df -h / | grep / | awk -v max="$1" '{
|
df -h / | grep / | awk -v max="$1" '{
|
||||||
@@ -13,7 +13,4 @@
|
|||||||
}'
|
}'
|
||||||
}
|
}
|
||||||
|
|
||||||
curl -X POST "https://api.telegram.org/bot$TOKEN/sendMessage" \
|
send_notification "$(disk_usage 80)"
|
||||||
-d "chat_id=$CHAT_ID" \
|
|
||||||
-d "text=$(disk_usage 80)" \
|
|
||||||
-d "parse_mode=HTML"
|
|
||||||
|
|||||||
11
scripts/notifications.sh
Normal file
11
scripts/notifications.sh
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
source /etc/serverconfig/.env
|
||||||
|
|
||||||
|
send_notification() {
|
||||||
|
local message="$1"
|
||||||
|
curl -X POST "https://api.telegram.org/bot$TELEGRAM_TOKEN/sendMessage" \
|
||||||
|
-d "chat_id=$TELEGRAM_CHAT_ID" \
|
||||||
|
-d "text=$message" \
|
||||||
|
-d "parse_mode=HTML"
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#!bin/bash
|
#!bin/bash
|
||||||
|
|
||||||
source /etc/serverconfig/.env
|
source /usr/local/bin/notifications.sh
|
||||||
|
|
||||||
case "$PAM_TYPE" in
|
case "$PAM_TYPE" in
|
||||||
open_session)
|
open_session)
|
||||||
@@ -12,8 +12,5 @@ case "$PAM_TYPE" in
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
if [ -n "$PAYLOAD" ] ; then
|
if [ -n "$PAYLOAD" ] ; then
|
||||||
curl -X POST "https://api.telegram.org/bot$TOKEN/sendMessage" \
|
send_notification "$PAYLOAD"
|
||||||
-d "chat_id=$CHAT_ID" \
|
|
||||||
-d "text=$PLAYLOAD" \
|
|
||||||
-d "parse_mode=HTML"
|
|
||||||
fi
|
fi
|
||||||
Reference in New Issue
Block a user