-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh.in
executable file
·245 lines (219 loc) · 6.22 KB
/
install.sh.in
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
#!/bin/sh
#
# @package_copyright@
#
# @configure_input@
#
# $OpenBSD$
#
prefix="@prefix@"
exec_prefix="@exec_prefix@"
libexecdir="@libexecdir@"
localstatedir="@localstatedir@"
sbindir="@sbindir@"
datadir="@datadir@"
USER="@enable_run_user@"
GROUP="@enable_run_group@"
MILTER='@PACKAGE_TARNAME@'
INSTALL=install
INSTALL_O='-o'
UNAME=`uname`
if id | grep 'uid=0' >/dev/null ; then
:
else
echo
echo "You must be root to install this software."
echo
exit 1
fi
unalias hasCommand >/dev/null 2>&1
hasCommand()
{
case $UNAME in
Linux|OpenBSD|FreeBSD)
which "$1"
return $?
;;
*)
# SunOS which(1) always returns 0 it would seem, even if
# the command does not exist. Linux and OpenBSD return a
# false value when the command is not found.
if which $1 | grep "no $1 in" >/dev/null ; then
return 1
fi
return 0
esac
return 1
}
# Create group and user if necessary...
if id ${USER} >/dev/null 2>&1; then
:
else
echo "Creating..... ${USER}:${GROUP}"
if grep '^smmsp:' /etc/group >/dev/null ; then
HAS_SMMSP='-G smmsp '
fi
case $UNAME in
FreeBSD)
pw groupadd -n ${GROUP}
pw useradd -n ${USER} -g ${GROUP} ${HAS_SMMSP} -c "${MILTER} process" -d /var/empty -s /usr/sbin/nologin
;;
*)
groupadd ${GROUP}
useradd -g ${GROUP} ${HAS_SMMSP} -c "${MILTER} process" -d /var/empty -s /sbin/nologin ${USER} >/dev/null
esac
fi
if test -d $libexecdir -a $UNAME != 'Linux' ; then
program=$libexecdir/${MILTER}
else
# Linux tends not to come with a /usr/local/libexec and the
# FHS is silent about it. They prefer to put system daemons
# in sbin, unlike BSD systems that prefer libexec. A milter
# is a daemon consulted by sendmail systems.
program=$sbindir/${MILTER}
fi
INSTALL_WHEEL="${INSTALL_O} root -g 0"
INSTALL_GROUP="${INSTALL_O} root -g ${GROUP}"
INSTALL_USER="${INSTALL_O} ${USER} -g ${GROUP}"
# Always use this location. Linux FHS is silent about it. OpenBSD favours it.
examples=$datadir/examples/${MILTER}
doc=$datadir/doc/${MILTER}
run=$localstatedir/run/milter
# Find location of common startup script directories...
if test -d /etc/init.d ; then
# Debian Linux
startup_script="/etc/init.d/${MILTER}"
elif test -d /etc/rc.d/init.d ; then
# Older Linux, System V structure?
startup_script="/etc/rc.d/init.d/${MILTER}"
elif test -d /usr/local/etc/rc.d ; then
# FreeBSD
startup_script="/usr/local/etc/rc.d/${MILTER}.sh"
else
# OpenBSD policy is for root to install startup scripts by hand.
startup_script='NO'
fi
if test $UNAME = 'SunOS' ; then
# There are two different install tools.
if test -x /usr/ucb/install ; then
INSTALL=/usr/ucb/install
INSTALL_O='-o'
elif test -x /usr/sbin/install ; then
INSTALL=/usr/sbin/install
INSTALL_O='-u'
fi
fi
if test $startup_script = NO ; then
:
elif test -f $startup_script ; then
echo "You already have a startup script installed:"
echo
echo " $startup_script"
echo
if cmp -s $startup_script startup.sh ; then
echo "And its identical to the current distributiuon."
startup_script='NO'
else
while true ; do
echo -n "Shall I show you the differences against the new one? [n] "
read yn
if test ${yn:=n} = 'n' -o ${yn} = 'y' ; then
break;
fi
done
if test "X$yn" = 'Xy' ; then
diff -u $startup_script startup.sh | more
fi
echo
while true ; do
echo -n "Shall I replace the old startup script? [n] "
read yn
if test ${yn:=n} = 'n' -o ${yn} = 'y' ; then
break;
fi
done
if test "X$yn" = 'Xy' ; then
$INSTALL -m 555 $INSTALL_O root -g ${GROUP} startup.sh $startup_script
if hasCommand chkconfig ; then
# Red Hat Linux
chkconfig --add ${MILTER}
elif hasCommand update-rc.d ; then
# Debian Linux
update-rc.d ${MILTER} defaults 18
fi
else
startup_script='NO'
fi
fi
else
$INSTALL -m 555 $INSTALL_O root -g ${GROUP} startup.sh $startup_script
if hasCommand chkconfig ; then
# Red Hat Linux
chkconfig --add ${MILTER}
elif hasCommand update-rc.d ; then
# Debian Linux
update-rc.d ${MILTER} defaults 18
fi
fi
echo 'Installing...' $program
$INSTALL -m 555 $INSTALL_GROUP ${MILTER} $program
echo 'Creating.....' $doc
$INSTALL -m 555 -d $doc/Img
echo 'Installing...' $doc
$INSTALL -m 444 FILE.TXT $doc
$INSTALL -m 444 CHANGES.TXT $doc
$INSTALL -m 444 VERSION.TXT $doc
$INSTALL -m 444 manual.shtml $doc/manual.shtml
cd $doc >/dev/null; ln -s manual.shtml index.shtml 2>/dev/null; cd - >/dev/null
$INSTALL -m 444 mailto.js $doc
$INSTALL -m 444 style.css $doc
$INSTALL -m 444 Img/*.gif $doc/Img
#$INSTALL -m 444 doc/Img/*.jpg $doc/Img
$INSTALL -m 444 Img/*.png $doc/Img
echo 'Creating.....' $examples
$INSTALL -m 555 -d $examples
echo 'Installing...' $examples
$INSTALL -m 444 sample.mc $examples/${MILTER}.mc
$INSTALL -m 444 startup.sh $examples/${MILTER}.sh
$INSTALL -m 444 rc.milters $examples/rc.milters
./${MILTER} -help >${MILTER}.cf
$INSTALL -m 444 ${MILTER}.cf $examples/${MILTER}.cf
#if test -d $localstatedir/cache ; then
# echo 'Creating.....' $localstatedir/cache/milter
# $INSTALL -m 755 $INSTALL_USER -d $localstatedir/cache/milter
#elif test -d $localstatedir/db ; then
# echo 'Creating.....' $localstatedir/db/milter
# $INSTALL -m 755 $INSTALL_USER -d $localstatedir/db/milter
#fi
#if test -d $localstatedir/run ; then
# echo 'Creating.....' $localstatedir/run/milter
# $INSTALL -m 755 $INSTALL_USER -d $localstatedir/run/milter
#fi
echo
echo '***************************************************************'
echo
echo 'Remember to review the sample configuration files above with'
echo 'your current configuration as existing options sometimes are'
echo 'deleted or renamed, and new ones added between revisions.'
echo
if test $UNAME = 'OpenBSD' ; then
echo 'Remember to modify your /etc/rc or /etc/rc.local script to '
echo 'startup the milter before sendmail on system boot.'
echo
fi
echo "Check the sendmail.mc file and verify the socket specified for"
echo "the INPUT_MAIL_FILTER macro matches your prefered setup. The"
echo "default socket used is:"
echo
echo " unix:@snert_socket_file@"
echo
echo "The simplest solution is to insert the contents of the example"
echo "configuration into the sendmail.mc file, rebuild sendmail.cf,"
echo "start the milter, and restart sendmail. See the documentation"
echo "and"
echo
echo " $examples/${MILTER}.mc"
echo
echo '***************************************************************'
echo
exit 0