2 # Install fcron under SysV system.
6 # takes 6 arguments : the name of the BSD-like install program (with "-o" and the correct username)
7 # the DESTSBIN directory
9 # the value of FCRONTABS
10 # the automatic answer
13 PATH="/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin"
14 if test -d /usr/ucb; then
19 if test $# -ne 6; then
20 echo "Too few/many arguments"
24 # The program we use to install a file. This may be the script install.sh.
25 if echo "$1" | grep 'install.sh$'; then
37 if test $DEBUG -eq 1; then
38 STARTCMD="fcron -b -d"
43 if test `uname -s` = "FreeBSD"; then
49 # Check now if there is an old ( < 1.1.x ) version of fcrontab on the system.
50 # We do that here because if user say "no" too early, the PREVIOUS_VERSION would
52 if test -r "PREVIOUS_VERSION"; then
53 MAJOR=`cat PREVIOUS_VERSION | awk '{print $2}' | awk -F '.' '{print $1}'`
54 MINOR=`cat PREVIOUS_VERSION | awk '{print $2}' | awk -F '.' '{print $2}'`
55 #echo "MINOR $MINOR MAJOR $MAJOR"
56 if test "x$MAJOR" = "x" -a "x$MINOR" = "x"; then
57 # we don't have the version: there was no previous fcron installed
59 elif test \( "$MAJOR" -lt 1 \) -o \( \( "$MINOR" -lt 1 \) -a "$MAJOR" -eq 1 \); then
64 rm -f PREVIOUS_VERSION
68 #echo "NEED_UPDATE : $NEED_UPDATE"
71 echo "Fcron should be started by your init scripts."
72 echo "The installation process is going to try to install fcron in them."
74 echo "Note that if you answer no to a proposition made at this point by"
75 echo "the installation script, it will try to propose another way to do it."
76 echo "(if there are several possibilities, a list will be printed before each"
79 echo "If you answer no to all the propositions of the script, or if the script"
80 echo "fails, a message will be printed telling you what you should do manually."
84 echo "The script proposes the following location to do it :"
85 if test $IS_FREEBSD -eq 1; then
86 echo " /usr/local/etc/rc.d/fcron.sh"
88 if test -d /etc/init.d/; then
89 echo " /etc/init.d/fcron"
90 elif test -d /etc/rc.d/init.d/; then
91 echo " /etc/rc.d/init.d/fcron"
93 if test -f /etc/rc.d/rc.local; then
94 echo " /etc/rc.d/rc.local"
96 if test -f /etc/rc.local; then
106 if test $IS_FREEBSD -eq 1; then
107 if test -x /usr/local/etc/rc.d/fcron.sh; then
108 echo "Fcron is already in /usr/local/etc/rc.d/."
111 if test $ANSWER -eq 2; then
112 while test \( ! -z "$INSTALL" \) -a \( "$INSTALL" != "y" \) -a \( "$INSTALL" != "n" \);
114 echo "Would you like to add fcron.sh script in the directory /usr/local/etc/rc.d/ ?"
115 echo -n "Please answer with 'y' or 'n' (default: 'y'): "
118 # automatic answer given by configure script (option --with-answer-all)
119 elif test $ANSWER -eq 1; then
124 if test \( -z "$INSTALL" \) -o \( "$INSTALL" = "y" \); then
125 cp -f script/fcron.sh /usr/local/etc/rc.d/
126 if test $DEBUG -eq 1; then
127 cat /usr/local/etc/rc.d/fcron.sh | sed 's: -b: -b -d:' > /usr/local/etc/rc.d/fcron.sh2
128 mv -f /usr/local/etc/rc.d/fcron.sh2 /usr/local/etc/rc.d/fcron.sh
130 chmod +x /usr/local/etc/rc.d/fcron.sh
141 if test -d /etc/init.d/; then
143 elif test -d /etc/rc.d/init.d/; then
146 if test \( ! "$INSTALLED" -eq 1 \) -a \( "$ROOTDIR" != "" \); then
147 if test $ANSWER -eq 2; then
148 while test \( ! -z "$INSTALL" \) -a \( "$INSTALL" != "y" \) -a \( "$INSTALL" != "n" \);
150 echo "Would you like to add fcron in the directory $ROOTDIR/init.d/ and in runlevel 2, 3, 4 and 5"
151 echo "(directories $ROOTDIR/rc{2,3,4,5}.d/) ?"
152 echo -n "Please answer with 'y' or 'n' (default: 'y'): "
155 # automatic answer given by configure script (option --with-answer-all)
156 elif test $ANSWER -eq 1; then
161 if test \( -z "$INSTALL" \) -o \( "$INSTALL" = "y" \); then
162 $INSPROG -c -m 755 script/sysVinit-launcher $ROOTDIR/init.d/fcron
163 if test $DEBUG -eq 1; then
164 cat $ROOTDIR/init.d/fcron | sed 's: -b: -b -d:' >$ROOTDIR/init.d/fcron2
165 mv -f $ROOTDIR/init.d/fcron2 $ROOTDIR/init.d/fcron
166 chmod +x $ROOTDIR/init.d/fcron
168 chmod +x $ROOTDIR/init.d/fcron
172 cd $ROOTDIR/rc$j.d/ ; ln -f -s ../init.d/fcron S40fcron
177 cd $ROOTDIR/rc$j.d/ ; ln -f -s ../init.d/fcron K60fcron
190 if test \( ! "$INSTALLED" -eq 1 \) -a \( -f /etc/rc.d/rc.local \); then
192 if ! cat /etc/rc.d/rc.local | grep "$STARTCMD"; then
193 if cat /etc/rc.d/rc.local | grep fcron; then
194 echo "Fcron seems to be in /etc/rc.d/rc.local, but not with the appropriate options :"
195 echo "you should probably correct this file in order to run fcron with $STARTCMD."
198 if test $ANSWER -eq 2; then
199 while test \( ! -z "$INSTALL" \) -a \( "$INSTALL" != "y" \) -a \( "$INSTALL" != "n" \);
201 echo "Would you like to add $STARTCMD in the file /etc/rc.d/rc.local ?"
202 echo -n "Please answer with 'y' or 'n' (default: 'y'): "
205 # automatic answer given by configure script (option --with-answer-all)
206 elif test $ANSWER -eq 1; then
211 if test \( -z "$INSTALL" \) -o \( "$INSTALL" = "y" \); then
212 echo $STARTCMD >> /etc/rc.d/rc.local
219 echo "Fcron is already in /etc/rc.d/rc.local."
227 if test \( ! "$INSTALLED" -eq 1 \) -a \( -f /etc/rc.local \) ; then
228 if ! cat /etc/rc.local | grep "$STARTCMD"; then
229 if cat /etc/rc.local | grep fcron; then
230 echo "Fcron seems to be in /etc/rc.local, but not with the appropriate options :"
231 echo "you should probably correct this file in order to run fcron with $STARTCMD."
234 if test $ANSWER -eq 2; then
235 while test \( ! -z "$INSTALL" \) -a \( "$INSTALL" != "y" \) -a \( "$INSTALL" != "n" \);
237 echo "Would you like to add $STARTCMD in the file /etc/rc.local ?"
238 echo -n "Please answer with 'y' or 'n' (default: 'y'): "
241 # automatic answer given by configure script (option --with-answer-all)
242 elif test $ANSWER -eq 1; then
247 if test \( -z "$INSTALL" \) -o \( "$INSTALL" = "y" \); then
248 echo $STARTCMD >> /etc/rc.local
255 echo "Fcron is already in /etc/rc.local."
261 if test "$INSTALLED" -eq 0; then
263 echo "Installation process failed to install fcron in your init scripts :"
264 echo "please do it manually."
268 if PID=`pidof fcron`; then
269 KILL="kill -TERM $PID"
270 KILLSTR="kill -TERM \`pidof fcron\`"
272 KILL="killall -TERM fcron"
274 COMMENT="WARNING : this command may not have the desired effect on non-Linux systems.\n"
275 PID="test -z on PID is not need in this case"
278 # NEED_UPDATE is set at the beginning of this script
279 if test $NEED_UPDATE -eq 0; then
280 # we stop fcron like this (not using "fcron restart") because
281 # an old version of fcron may not stop correctly otherwise.
283 echo "You should now stop the old version of fcron and start the new one."
286 if test -z "$PID"; then
287 echo "Fcron is not running."
291 if test "$SYSV" -eq 1; then
292 CMD="$ROOTDIR/init.d/fcron start"
296 if test $ANSWER -eq 2; then
297 while test \( ! -z "$RESTART" \) -a \( "$RESTART" != "y" \) -a \( "$RESTART" != "n" \);
299 if test ! -z "$KILL"; then
300 echo "Would you like to do it with a '"$KILLSTR"' ?"
302 echo "followed by a '"$CMD"' ?"
304 echo "Would you like to start it by '"$CMD"' ?"
306 echo -n "Please answer with 'y' or 'n' (default: 'y'): "
309 # automatic answer given by configure script (option --with-answer-all)
310 elif test $ANSWER -eq 1; then
315 if test \( -z "$RESTART" \) -o \( "$RESTART" = "y" \); then
317 sleep 2 # wait for fcron to stop
321 else # test $NEED_UPDATE -eq 0
324 echo "You should now stop the old version fcron."
327 if test -z "$PID"; then
328 echo "Fcron is not running."
329 echo "You may start it after having updated the fcrontabs."
332 if test $ANSWER -eq 2; then
333 while test \( ! -z "$STOP" \) -a \( "$STOP" != "y" \) -a \( "$STOP" != "n" \);
335 echo "Would you like to do it with a '"$KILLSTR"'"
337 echo -n "Please answer with 'y' or 'n' (default: 'y'): "
340 # automatic answer given by configure script (option --with-answer-all)
341 elif test $ANSWER -eq 1; then
346 if test \( -z "$STOP" \) -o \( "$STOP" = "y" \); then
353 if test "$STOPPED" = "1"; then
354 echo "You should now update the fcrontabs format using convert-fcrontab program."
356 echo "After having restarted fcron, you should update the fcrontabs format"
357 echo "using the convert-fcrontab program ($SRCDIR/convert-fcrontab)"
358 echo "(run \"convert-fcrontab -h\" to get help) and then start the new version"
362 echo "As a matter of fact, you must know that fcrontabs installed by an old"
363 echo "version (<1.1.x) of fcrontab won't work anymore with this version if you don't"
364 echo "update their format."
367 # reinstall the fcrontabs
368 if test $ANSWER -eq 2; then
369 while test \( ! -z "$UPDATE" \) -a \( "$UPDATE" != "y" \) -a \( "$UPDATE" != "n" \);
371 echo "Would you like to do it now ?"
372 echo -n "Please answer with 'y' or 'n' (default: 'y'): "
375 elif test $ANSWER -eq 1; then
380 if test \( -z "$UPDATE" \) -o \( "$UPDATE" = "y" \); then
381 for FILE in $FCRONTABS/* ; do \
382 if test "$FILE" != "$FCRONTABS/*"; then
383 BASENAME=`basename $FILE` ; \
384 FCRONTAB=`echo "$BASENAME" | \
385 sed "s|.*orig|| ; s|fcrontab.sig|| ; s|rm.*||"` ; \
386 ( test ! -z "$FCRONTAB" && $SRCDIR/convert-fcrontab $FCRONTAB ) \
392 # start the new version of fcron
394 echo "You should now start the new version of fcron."
397 if test "$SYSV" -eq 1; then
398 CMD="$ROOTDIR/init.d/fcron start"
402 if test $ANSWER -eq 2; then
403 while test \( ! -z "$START" \) -a \( "$START" != "y" \) -a \( "$START" != "n" \);
405 echo "Would you like to do it with a '"$CMD"'"
406 echo -n "Please answer with 'y' or 'n' (default: 'y'): "
409 # automatic answer given by configure script (option --with-answer-all)
410 elif test $ANSWER -eq 1; then
415 if test \( -z "$START" \) -o \( "$START" = "y" \); then