-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·49 lines (39 loc) · 1.26 KB
/
install.sh
File metadata and controls
executable file
·49 lines (39 loc) · 1.26 KB
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
#!/bin/bash
# install script for notifier
#checking if mailutils is installed to send mail
REQUIRED_PKG = "mailutils"
PKG_OK=$(dpkg-query -W --showformat='${Status}\n' $REQUIRED_PKG|grep "install ok installed")
echo "Checking for required dep:\n $REQUIRED_PKG: $PKG_OK"
if [ "" = "$PKG_OK"]; then
echo "No $REQUIRED_PKG. Setting up $REQUIRED_PKG."
sudo apt install -y $REUQIRED_PKG
fi
echo 'required deps installed'
#setting up folder structure
sudo mkdir /opt/notifier
echo 'Making folder /opt/notifier/ and moving the script into there'
sudo mv script.sh /opt/notifier
chmod +x /opt/notifier/script.sh
echo 'Script moved'
# ask user for notification address
read -p "What is the notification email address?: " email_address
sudo sed -i "s/notify_email/$email_address/" /opt/notifier/script.sh
echo 'email address changed.'
# will install a cron job to run the script
PS3="Do yo want to install a cronjob? (1/2): "
options=("Yes" "No")
select opt in "${options[@]}"
do
case $opt in
"Yes")
echo "setting up crontab now..."
(sudo crontab -l 2>/dev/null; echo "0 23 * * * /opt/notifier/script.sh") | crontab -
echo "cronjob installed to run every day at 11pm, feel free to change"
break
;;
"No")
echo "Exiting Setup... Goodbye."
break
;;
esac
done