-
Notifications
You must be signed in to change notification settings - Fork 3
/
INSTALL-MacOSX.sh
executable file
·144 lines (113 loc) · 3.77 KB
/
INSTALL-MacOSX.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
#! /bin/sh
#
# ipv6mon installation script for Mac OS X
# Adapted from the Debian/Ubuntu Installation script by
# Yvan Janssens ([email protected])
#
# Copyright (C) 2011 United Kingdom's Centre for the Protection of
# National Infrastructure (UK CPNI)
#
# Programmed by Fernando Gont on behalf of CPNI (http://www.cpni.gov.uk)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
###############################################################################
if ! uname -a | grep Darwin >/dev/null 2>&1; then
echo "This installer script should be used only with Mac OS X."
exit 1
fi
if [ `id -u` -ne 0 ]; then
echo "Must have superuser privileges to install ipv6mon"
echo "hint: sudo ./INSTALL-MacOSX.sh"
exit 1
fi
echo "Installing ipv6mon on the local system"
printf "Compiling ipv6mon..."
if gcc ipv6mon.c -Wall -lpcap -o ipv6mon >/dev/null 2>&1; then
echo "succeeded."
else
echo "failed." && exit 1
fi
printf "Setting owner of ipv6mon to root:wheel..."
if chown root:wheel ipv6mon >/dev/null 2>&1; then
echo "succeeded."
else
echo "failed." && exit 1
fi
printf "Setting file mode bits of ipv6mon..."
if chmod 0755 ipv6mon >/dev/null 2>&1; then
echo "succeeded."
else
echo "failed." && exit 1
fi
printf "Copying ipv6mon to /usr/sbin/..."
if cp ipv6mon /usr/sbin/ >/dev/null 2>&1; then
echo "succeeded."
else
echo "failed." && exit 1
fi
if test -f /etc/ipv6mon.conf; then
printf "Renaming old /etc/ipv6mon.conf to /etc/ipv6mon.conf.old..."
if mv /etc/ipv6mon.conf /etc/ipv6mon.conf.old >/dev/null 2>&1; then
echo "succeeded."
else
echo "failed." && exit 1
fi
fi
printf "Setting owner of ipv6mon.conf to root:wheel..."
if chown root:wheel ipv6mon.conf >/dev/null 2>&1; then
echo "succeeded."
else
echo "failed." && exit 1
fi
printf "Setting file mode bits of ipv6mon.conf..."
if chmod 0644 ipv6mon.conf >/dev/null 2>&1; then
echo "succeeded."
else
echo "failed." && exit 1
fi
printf "Copying ipv6mon.conf to /etc/..."
if cp ipv6mon_osx.conf /etc/ipv6mon.conf >/dev/null 2>&1; then
echo "succeeded."
else
echo "failed." && exit 1
fi
printf "Copying ipv6mon StartupItem to /Library/StartupItems..."
if cp -R MacOSX/ipv6mon /Library/StartupItems >/dev/null 2>&1; then
echo "succeeded."
else
echo "failed." && exit 1
fi
printf "Fixing up ipv6mon StartupItem permissions..."
if chown -R root:wheel /Library/StartupItems/ipv6mon >/dev/null 2>&1; then
echo "succeeded."
else
echo "failed." && exit 1
fi
printf "Copying manual pages to the local system..."
if test -d "/usr/share/man/man8" && test -d "/usr/share/man/man5" >/dev/null 2>&1; then
chown root:wheel "manuals/ipv6mon.8" 2>&1
chmod 0644 "manuals/ipv6mon.8" >/dev/null 2>&1
cp manuals/ipv6mon.8 "/usr/share/man/man8/" 2>&1
gzip "/usr/share/man/man8/ipv6mon.8" 2>&1
chown root:wheel "manuals/ipv6mon.conf.5" 2>&1
chmod 0644 "manuals/ipv6mon.conf.5" >/dev/null 2>&1
cp "manuals/ipv6mon.conf.5" "/usr/share/man/man5/" 2>&1
gzip "/usr/share/man/man5/ipv6mon.conf.5" 2>&1
echo "succeeded."
else
echo "failed."
echo "You must install the manual pages on your system manually!"
fi
echo "ipv6mon installation complete!"
exit 0