-
Notifications
You must be signed in to change notification settings - Fork 6
/
install.sh
193 lines (153 loc) · 5.4 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
#!/bin/bash
# This installer was written by https://github.com/happycodinguk
# Am looking forward to its modification and improvement from the Open Source Community!
# Please leave feedback or message me on telegram https://t.me/joinchat/xlmtm7jVYR4yODQ0
# Make temporary installer folder in /tmp
# -------------------------------------------------------
read -p "
-------------------------------------------------------
**TELEGRAM-SYSTEM-MONITOR**
-------------------------------------------------------
INSTALL SCRIPT TESTED ON:
DEBIAN 10
CENTOS 7
You can view all installation files at:
https://github.com/happycodinguk/telegram-system-monitor
You will need to run this script with root privileges.
If logged in a standard user. Before running this script, run the command:
sudo su
You can run the command:
exit
After the script has finished to return to your normal user command line.
System Requirements for basic install:
wget
Ubuntu/Debian: apt install -y wget
CentOS: yum install -y wget
curl
Ubuntu/Debian apt install -y curl
CentOS: yum install -y curl
zip
Ubuntu/Debian apt install -y zip
CentOS: yum install -y curl
If you need to install any of these, open a second terminal window and do it now..
OK. Are you ready?
Yes or No?" -n 1 -r
echo # (optional) move to a new line
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
exit 1
fi
rm -fr -y /tmp/tg_install
mkdir /tmp/tg_install
cd /tmp/tg_install
### Downloading monitor scripts
wget https://github.com/happycodinguk/telegram-system-monitor/archive/refs/heads/main.zip
unzip main.zip
cd telegram-system-monitor-main
cp install-template.sh installed-choices.sh
read -p "
-------------------------------------------------------
This script will install Telegram BOT Notifications.
Pick one, all, or any combo if these notifications!
-------------------------------
- Postfix Activity Reports
- Low Storage Alerts
- System Service Failure Alerts
- CPU and Memory Alerts
- CSF LFD Firewall alerts
- SSH Login alerts (NOT WORKING ON CENTOS YET)
-------------------------------
- You will choose an install location for the scripts (default options avaiable).
- SSH Login alerts will install the script into your chosen location.
It will also add a link to trigger the script on SSH login in:
/etc/pam.d/sshd (at the end of the file)
- SSH Login alerts option isn't needed if you are running CSF Firewall.
CSF/LFD sends SSH, webmin login notifications along with IP blocking info etc.
>> Always have a backup of your system or try out in a testing environment<<
Lets compile your install package!
Are you ready?
(Type Y or N)" -n 1 -r
echo # (optional) move to a new line
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
exit 1
fi
#Menu options
options[0]="Postfix Activity Reporter"
options[1]="Low Storage Alert"
options[2]="System Service Failure Alert"
options[3]="CPU and Memory Alert"
options[4]="CSF LFD Firewall alerts (CSF sends SSH Login notifications by default)"
options[5]="SSH Login alerts (NOT WORKING ON CENTOS YET - This option isnt needed with CSF Firewall installations - CSF Send SSH and other notifications)"
#Actions to take based on selection
function ACTIONS {
if [[ ${choices[0]} ]]; then
#Option 1 selected
echo "Postfix Activity Report - *SELECTED*"
# cat telegram-inst.txt >> /tmp/custom-install.sh
sed -i -e '/"postfix"/r postfix-inst.txt' installed-choices.sh
sleep 1
fi
if [[ ${choices[1]} ]]; then
#Option 2 selected
echo "Low Storage Alert - *SELECTED*"
sed -i -e '/"storage"/r storage-inst.txt' installed-choices.sh
sleep 1
fi
if [[ ${choices[2]} ]]; then
#Option 3 selected
echo "System Service Failure Alert - *SELECTED*"
sed -i -e '/"system"/r system-inst.txt' installed-choices.sh
sleep 1
fi
if [[ ${choices[3]} ]]; then
#Option 4 selected
echo "CPU and Memory Alert - *SELECTED*"
sed -i -e '/"cpu"/r cpu-inst.txt' installed-choices.sh
sleep 1
fi
if [[ ${choices[4]} ]]; then
#Option 5 selected
echo "CSF LFD Firewall alerts - *SELECTED*"
sed -i -e '/"csf"/r csf-inst.txt' installed-choices.sh
sleep 1
fi
if [[ ${choices[5]} ]]; then
#Option 6 selected
echo "SSH Login alerts - *SELECTED*"
sed -i -e '/"ssh"/r ssh-inst.txt' installed-choices.sh
sleep 1
fi
}
#Variables
ERROR=" "
#Clear screen for menu
clear
#Menu function
function MENU {
echo "System Messages Install Options!
(Pick one, all or any seletion of these notifications)"
for NUM in ${!options[@]}; do
echo "[""${choices[NUM]:- }""]" $(( NUM+1 ))") ${options[NUM]}"
done
echo "$ERROR"
}
#Menu loop
while MENU && read -e -p "Select the options you would like using their number (tap the number again to uncheck, Press ENTER when done!):
" -n1 SELECTION && [[ -n "$SELECTION" ]]; do
clear
if [[ "$SELECTION" == *[[:digit:]]* && $SELECTION -ge 1 && $SELECTION -le ${#options[@]} ]]; then
(( SELECTION-- ))
if [[ "${choices[SELECTION]}" == "+" ]]; then
choices[SELECTION]=""
else
choices[SELECTION]="+"
fi
ERROR=" "
else
ERROR="Invalid option: $SELECTION"
fi
done
ACTIONS
chmod +x installed-choices.sh
./installed-choices.sh