-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmail_setup
executable file
·122 lines (103 loc) · 2.43 KB
/
mail_setup
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
#!/bin/bash
#this is a menu driven shell that will:
#1. Check a Server status
#2. Find the router hops
#3. Enter login and display owner
#4. Compress and email file
#5. Send a file (using mailx)
#6. Exit Program
#Display the options User can Choose from
function showMenu()
{
echo "Please select the option by pressing the number"
echo ------------------------
echo "Press 1 to check a Server status: "
echo "Press 2 to find the router hops: "
echo "Press 3 to Enter login and display owner: "
echo "Press 4 to Compress and email file: "
echo "Press 5 to Send a file using email: "
echo "Press 0 to Exit Program: "
echo "------------------------"
echo ""
}
#Run selected option user chooses
function Menu()
{
local choice
read -n1 -p "> " choice
clear
case $choice in
1) Ping_IP ;;
2) IP_Hops ;;
3) ID_Owner ;;
4) Compress_Email ;;
5) Email_File ;;
0) Prompt_Exit;;
esac
}
#Function to Ping IP Once
function Ping_IP()
{
read -p "Input IP Address > " IP
ping $IP -c1
}
#Function to trace Hops for IP
function IP_Hops()
{
read -p "View Router Hops for IP > " IP
traceroute $IP
}
#Function to OutputID Owner
function ID_Owner()
{
read -p "Input ID to display ID owner > " ID
echo "ID owner is "
id -u $ID
}
#Function to compress and email a file to User
function Compress_Email()
{
read -p "Input File to Compress > " Tfile
read -p "Name Compressed file > " cfile
read -p "Who would you like to send? > " mail #declare contact
tar -zcvf $cfile.tar.gz $Tfile # compress selected file
read -p "Input subject line > " SU
mailx -s "$SU" $mail < $cfile.tar.gz #email compressed file
}
#Function to Email a file to User
function Email_File()
{
read -p "Who would you like to email? > " mail #declare contact
read -p "Attach File to Send > " Tfile
read -p "Input Subject > " SU
read -p "Enter body of the message > " msgbody
echo "$msgbody" | mailx -s "$SU" -a $Tfile $mail #email file to sender
}
#Function that will ask user if they REALLY want to quit
function Prompt_Exit ()
{
read -n1 -p "Are you sure you want to quit? (Y/N) " Choice
echo
case $Choice in
y|Y) exit 1
esac
}
#Creates a pause within the loop
#User must press Enter to Continue
function Pause()
{
echo
echo
echo "Press enter For Main Menu"
read
clear
}
#Run Script in Loop
#Used this method to Allow the Pause Function to work Properly
while true
do
showMenu
Menu
Pause
done
exit 0