diff --git a/install.sh b/install.sh
index 19cd2a0..53b962c 100644
--- a/install.sh
+++ b/install.sh
@@ -56,11 +56,8 @@ install_file() {
}
echo
datetime_print "------------- install files -------------"
-install_file "aws-backup.sh" "$SCRIPT_FILE" -Dm755
-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
+for element in scripts/*.sh; do install_file "$(basename $element)" "$SCRIPT_FILE" -Dm755; done
+install_file "docker-compose.yml" "$ETC_DIR" -Dm644
create_env_variable() {
local key="$1"
diff --git a/scripts/disk-monitor.sh b/scripts/disk-monitor.sh
index 6c92bda..d58b52c 100644
--- a/scripts/disk-monitor.sh
+++ b/scripts/disk-monitor.sh
@@ -1,19 +1,16 @@
- #!/bin/bash
+#!/bin/bash
- source /etc/serverconfig/.env
+source /usr/local/bin/notifications.sh
- disk_usage() {
- df -h / | grep / | awk -v max="$1" '{
- usage = $5;
- gsub("%", "", usage);
- if (usage > max) {
- printf "🚨 WARNING:\nDisk usage is at %d%%. which exceed the treshold of %d%%.\n\n", usage, max;
- }
- printf "💾 Disk Usage Information:\nTotal Size: %s, Used: %s, Available: %s\n\n", $2, $3, $4;
- }'
- }
+disk_usage() {
+ df -h / | grep / | awk -v max="$1" '{
+ usage = $5;
+ gsub("%", "", usage);
+ if (usage > max) {
+ printf "🚨 WARNING:\nDisk usage is at %d%%. which exceed the treshold of %d%%.\n\n", usage, max;
+ }
+ printf "💾 Disk Usage Information:\nTotal Size: %s, Used: %s, Available: %s\n\n", $2, $3, $4;
+ }'
+}
- curl -X POST "https://api.telegram.org/bot$TOKEN/sendMessage" \
- -d "chat_id=$CHAT_ID" \
- -d "text=$(disk_usage 80)" \
- -d "parse_mode=HTML"
+send_notification "$(disk_usage 80)"
diff --git a/scripts/notifications.sh b/scripts/notifications.sh
new file mode 100644
index 0000000..bebbf22
--- /dev/null
+++ b/scripts/notifications.sh
@@ -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"
+}
\ No newline at end of file
diff --git a/scripts/sshd-login.sh b/scripts/sshd-login.sh
index 85e3e57..bae3b78 100644
--- a/scripts/sshd-login.sh
+++ b/scripts/sshd-login.sh
@@ -1,6 +1,6 @@
#!bin/bash
-source /etc/serverconfig/.env
+source /usr/local/bin/notifications.sh
case "$PAM_TYPE" in
open_session)
@@ -12,8 +12,5 @@ case "$PAM_TYPE" in
esac
if [ -n "$PAYLOAD" ] ; then
- curl -X POST "https://api.telegram.org/bot$TOKEN/sendMessage" \
- -d "chat_id=$CHAT_ID" \
- -d "text=$PLAYLOAD" \
- -d "parse_mode=HTML"
+ send_notification "$PAYLOAD"
fi
\ No newline at end of file
diff --git a/scripts/telegram.sh b/scripts/telegram.sh
deleted file mode 100644
index e69de29..0000000