-
Notifications
You must be signed in to change notification settings - Fork 46
/
uninstall.sh
executable file
·148 lines (121 loc) · 3.18 KB
/
uninstall.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
#!/bin/sh
help ()
{
cat <<EOF
This script is written and maintained by Dean Jones.
Please report all bugs using https://github.com/deanproxy/eMail/issues
Options are described below and all are MANDITORY.
--bindir dir Specifies the directory to find the binary to remove.
--mandir dir Specifies the directory to find the manual page to remove.
--sysconfdir dir Specifies the directory to find the config files to remove.
--docdir dir Specifies the directory to find the documentation to remove.
--version version Specifies the version of the program
--help Duh.
EOF
}
# Get command line arguments
while [ "$1" ]
do
case "$1" in
"-b" | "--bindir" | "-bindir")
if [ -z "$2" ]
then
echo "error: option '$1' requires an argument"
exit 2
fi
shift
bindir="$1"
;;
"-m" | "--mandir" | "-mandir")
if [ -z "$2" ]
then
echo "error: option '$1' requires an argument"
exit 2
fi
shift
mandir="$1"
;;
"-s" | "--sysconfdir" | "-sysconfdir")
if [ -z "$2" ]
then
echo "error: option '$1' requires an argument"
exit 2
fi
shift
sysconfdir="$1"
;;
"-d" | "--docdir" | "-docdir")
if [ -z "$2" ]
then
echo "error: option '$1' requires an argument"
exit 2
fi
shift
docdir="$1"
;;
"-v" | "--version" | "-version")
if [ -z "$2" ]
then
echo "error: option '$1' requires an argument"
exit 2
fi
shift
VERSION="$1"
;;
"-h" | "--help" | "-help" )
help
;;
* )
help
;;
esac
shift
done
if [ -z "$bindir" ] || [ -z "$mandir" ] || [ -z "$sysconfdir" ] || [ -z "$VERSION" ]
then
echo "Not enough arguments on the command line."
help
exit 2
fi
if [ -f "$bindir/email" ]
then
echo "Removing Binary..."
rm -f "$bindir/email"
elif [ -f "$bindir/email.exe" ]
then
echo "Removing Binary..."
rm -f "$bindir/email.exe"
fi
if [ -d "$sysconfdir/email" ]
then
echo "Removing $sysconfdir/email..."
rm -rf "$sysconfdir/email"
fi
if [ "`uname | cut -b 1-6`" = "CYGWIN" ]
then
rm -f "$bindir/email-config"
fi
if [ -d "$docdir/email-$VERSION" ]
then
echo "Removing $docdir/email-$VERSION..."
rm -rf "$docdir/email-$VERSION"
fi
if [ -f "$mandir/man1/email.1" ]
then
echo "Removing $mandir/man1/email.1..."
rm -f "$mandir/man1/email.1"
fi
echo -n "Would you like to remove users personal ~/.email.conf files? "
read answer
if [ "$answer" = "yes" ] || [ "$answer" = "y" ]
then
for home_dir in `cat /etc/passwd | awk -F : '{print $6}'`
do
if [ -f "$home_dir/.email.conf" ]
then
echo "Removing $home_dir/.email.conf"
rm -f "$home_dir/.email.conf"
fi
done
fi
echo "Finished!"