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 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421
|
#!/bin/sh
# Install fcron under SysV system.
#
# $Id: boot-install,v 1.38 2004/01/29 10:36:00 thib Exp thib $
# takes 6 arguments : the name of the BSD-like install program (with "-o" and the correct username)
# the DESTSBIN directory
# the value of DEBUG
# the value of FCRONTABS
# the automatic answer
# the src dir
PATH="/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin"
if test -d /usr/ucb; then
PATH=/usr/ucb:$PATH
fi
startdir=$PWD
if test $# -ne 6; then
echo "Too few/many arguments"
exit 1
fi
# The program we use to install a file. This may be the script install.sh.
if echo "$1" | grep 'install.sh$'; then
INSPROG=$SRCDIR/$1
else
INSPROG=$1
fi
DESTBIN=$2
DEBUG=$3
#DEBUG=1
FCRONTABS=$4
ANSWER=$5
SRCDIR=$6
if test $DEBUG -eq 1; then
STARTCMD="fcron -b -d"
else
STARTCMD="fcron -b"
fi
if test `uname -s` = "FreeBSD"; then
IS_FREEBSD=1
else
IS_FREEBSD=0
fi
# Check now if there is an old ( < 1.1.x ) version of fcrontab on the system.
# We do that here because if user say "no" too early, the PREVIOUS_VERSION would
# not be removed.
if test -r "$SRCDIR/script/PREVIOUS_VERSION"; then
MAJOR=`cat $SRCDIR/script/PREVIOUS_VERSION | awk '{print $2}' | awk -F '.' '{print $1}'`
MINOR=`cat $SRCDIR/script/PREVIOUS_VERSION | awk '{print $2}' | awk -F '.' '{print $2}'`
# echo "MINOR $MINOR MAJOR $MAJOR"
if test \( "$MAJOR" -lt 1 \) -o \( \( "$MINOR" -lt 1 \) -a "$MAJOR" -eq 1 \); then
NEED_UPDATE=1
else
NEED_UPDATE=0
fi
rm -f $SRCDIR/script/PREVIOUS_VERSION
else
NEED_UPDATE=1
fi
#echo "NEED_UPDATE : $NEED_UPDATE"
echo
echo "Fcron should be started by your init scripts."
echo "The installation process is going to try to install fcron in them."
echo
echo "Note that if you answer no to a proposition made at this point by"
echo "the installation script, it will try to propose another way to do it."
echo "(if there are several possibilities, a list will be printed before each"
echo "action)"
echo
echo "If you answer no to all the propositions of the script, or if the script"
echo "fails, a message will be printed telling you what you should do manually."
echo
echo
echo "The script proposes the following location to do it :"
if test $IS_FREEBSD -eq 1; then
echo " /usr/local/etc/rc.d/fcron.sh"
fi
if test -d /etc/init.d/; then
echo " /etc/init.d/fcron"
elif test -d /etc/rc.d/init.d/; then
echo " /etc/rc.d/init.d/fcron"
fi
if test -f /etc/rc.d/rc.local; then
echo " /etc/rc.d/rc.local"
fi
if test -f /etc/rc.local; then
echo " /etc/rc.local"
fi
echo
INSTALL="nothing"
SYSV=0
STOPPED=0
INSTALLED=0
if test $IS_FREEBSD -eq 1; then
if test -x /usr/local/etc/rc.d/fcron.sh; then
echo "Fcron is already in /usr/local/etc/rc.d/."
INSTALLED=1
else
if test $ANSWER -eq 2; then
while test \( ! -z "$INSTALL" \) -a \( "$INSTALL" != "y" \) -a \( "$INSTALL" != "n" \);
do
echo "Would you like to add fcron.sh script in the directory /usr/local/etc/rc.d/ ?"
echo -n "Please answer with 'y' or 'n' (default: 'y'): "
read INSTALL NOTHING
done
# automatic answer given by configure script (option --with-answer-all)
elif test $ANSWER -eq 1; then
INSTALL="y"
else
INSTALL="n"
fi
if test \( -z "$INSTALL" \) -o \( "$INSTALL" = "y" \); then
cp -f $SRCDIR/script/fcron.sh /usr/local/etc/rc.d/
if test $DEBUG -eq 1; then
cat /usr/local/etc/rc.d/fcron.sh | sed 's: -b: -b -d:' > /usr/local/etc/rc.d/fcron.sh2
mv -f /usr/local/etc/rc.d/fcron.sh2 /usr/local/etc/rc.d/fcron.sh
fi
cat /usr/local/etc/rc.d/fcron.sh | sed "s:@@DESTSBIN@:$DESTBIN:" > /usr/local/etc/rc.d/fcron.sh2
mv -f /usr/local/etc/rc.d/fcron.sh2 /usr/local/etc/rc.d/fcron.sh
chmod +x /usr/local/etc/rc.d/fcron.sh
INSTALLED=1
else
INSTALLED=0
fi
fi
fi
INSTALL="nothing"
ROOTDIR=""
if test -d /etc/init.d/; then
ROOTDIR="/etc"
elif test -d /etc/rc.d/init.d/; then
ROOTDIR="/etc/rc.d"
fi
if test \( ! "$INSTALLED" -eq 1 \) -a \( "$ROOTDIR" != "" \); then
if test $ANSWER -eq 2; then
while test \( ! -z "$INSTALL" \) -a \( "$INSTALL" != "y" \) -a \( "$INSTALL" != "n" \);
do
echo "Would you like to add fcron in the directory $ROOTDIR/init.d/ and in runlevel 2, 3, 4 and 5"
echo "(directories $ROOTDIR/rc{2,3,4,5}.d/) ?"
echo -n "Please answer with 'y' or 'n' (default: 'y'): "
read INSTALL NOTHING
done
# automatic answer given by configure script (option --with-answer-all)
elif test $ANSWER -eq 1; then
INSTALL="y"
else
INSTALL="n"
fi
if test \( -z "$INSTALL" \) -o \( "$INSTALL" = "y" \); then
$INSPROG -c -m 755 $SRCDIR/script/sysVinit-launcher $ROOTDIR/init.d/fcron
if test $DEBUG -eq 1; then
cat $ROOTDIR/init.d/fcron | sed 's: -b: -b -d:' >$ROOTDIR/init.d/fcron2
mv -f $ROOTDIR/init.d/fcron2 $ROOTDIR/init.d/fcron
chmod +x $ROOTDIR/init.d/fcron
fi
cat $ROOTDIR/init.d/fcron | sed "s:@@DESTSBIN@:$DESTBIN:" >$ROOTDIR/init.d/fcron2
mv -f $ROOTDIR/init.d/fcron2 $ROOTDIR/init.d/fcron
chmod +x $ROOTDIR/init.d/fcron
for j in 2 3 4 5
do
cd $ROOTDIR/rc$j.d/ ; ln -f -s ../init.d/fcron S40fcron
done
for j in 0 6
do
cd $ROOTDIR/rc$j.d/ ; ln -f -s ../init.d/fcron K60fcron
done
cd $startdir
INSTALLED=1
SYSV=1
else
INSTALLED=0
fi
fi
INSTALL="nothing"
if test \( ! "$INSTALLED" -eq 1 \) -a \( -f /etc/rc.d/rc.local \); then
# Slackware
if ! cat /etc/rc.d/rc.local | grep "$STARTCMD"; then
if cat /etc/rc.d/rc.local | grep fcron; then
echo "Fcron seems to be in /etc/rc.d/rc.local, but not with the appropriate options :"
echo "you should probably correct this file in order to run fcron with $STARTCMD."
INSTALLED=1
else
if test $ANSWER -eq 2; then
while test \( ! -z "$INSTALL" \) -a \( "$INSTALL" != "y" \) -a \( "$INSTALL" != "n" \);
do
echo "Would you like to add $STARTCMD in the file /etc/rc.d/rc.local ?"
echo -n "Please answer with 'y' or 'n' (default: 'y'): "
read INSTALL NOTHING
done
# automatic answer given by configure script (option --with-answer-all)
elif test $ANSWER -eq 1; then
INSTALL="y"
else
INSTALL="n"
fi
if test \( -z "$INSTALL" \) -o \( "$INSTALL" = "y" \); then
echo $STARTCMD >> /etc/rc.d/rc.local
INSTALLED=1
else
INSTALLED=0
fi
fi
else
echo "Fcron is already in /etc/rc.d/rc.local."
INSTALLED=1
fi
fi
INSTALL="nothing"
if test \( ! "$INSTALLED" -eq 1 \) -a \( -f /etc/rc.local \) ; then
if ! cat /etc/rc.local | grep "$STARTCMD"; then
if cat /etc/rc.local | grep fcron; then
echo "Fcron seems to be in /etc/rc.local, but not with the appropriate options :"
echo "you should probably correct this file in order to run fcron with $STARTCMD."
INSTALLED=1
else
if test $ANSWER -eq 2; then
while test \( ! -z "$INSTALL" \) -a \( "$INSTALL" != "y" \) -a \( "$INSTALL" != "n" \);
do
echo "Would you like to add $STARTCMD in the file /etc/rc.local ?"
echo -n "Please answer with 'y' or 'n' (default: 'y'): "
read INSTALL NOTHING
done
# automatic answer given by configure script (option --with-answer-all)
elif test $ANSWER -eq 1; then
INSTALL="y"
else
INSTALL="n"
fi
if test \( -z "$INSTALL" \) -o \( "$INSTALL" = "y" \); then
echo $STARTCMD >> /etc/rc.local
INSTALLED=1
else
INSTALLED=0
fi
fi
else
echo "Fcron is already in /etc/rc.local."
INSTALLED=1
fi
fi
if test "$INSTALLED" -eq 0; then
echo
echo "Installation process failed to install fcron in your init scripts :"
echo "please do it manually."
fi
if PID=`pidof fcron`; then
KILL="kill -TERM $PID"
KILLSTR="kill -TERM \`pidof fcron\`"
else
KILL="killall -TERM fcron"
KILLSTR=$KILL
COMMENT="WARNING : this command may not have the desired effect on non-Linux systems.\n"
PID="test -z on PID is not need in this case"
fi
# NEED_UPDATE is set at the beginning of this script
if test $NEED_UPDATE -eq 0; then
# we stop fcron like this (not using "fcron restart") because
# an old version of fcron may not stop correctly otherwise.
echo
echo "You should now stop the old version of fcron and start the new one."
RESTART="nothing"
COMMENT=""
if test -z "$PID"; then
echo "Fcron is not running."
KILL=""
COMMENT=""
fi
if test "$SYSV" -eq 1; then
CMD="$ROOTDIR/init.d/fcron start"
else
CMD=$STARTCMD
fi
if test $ANSWER -eq 2; then
while test \( ! -z "$RESTART" \) -a \( "$RESTART" != "y" \) -a \( "$RESTART" != "n" \);
do
if test ! -z "$KILL"; then
echo "Would you like to do it with a '"$KILLSTR"' ?"
echo -n $COMMENT
echo "followed by a '"$CMD"' ?"
else
echo "Would you like to start it by '"$CMD"' ?"
fi
echo -n "Please answer with 'y' or 'n' (default: 'y'): "
read RESTART NOTHING
done
# automatic answer given by configure script (option --with-answer-all)
elif test $ANSWER -eq 1; then
RESTART="y"
else
RESTART="n"
fi
if test \( -z "$RESTART" \) -o \( "$RESTART" = "y" \); then
$KILL
sleep 2 # wait for fcron to stop
$CMD
fi
else # test $NEED_UPDATE -eq 0
echo
echo "You should now stop the old version fcron."
STOP="nothing"
COMMENT=""
if test -z "$PID"; then
echo "Fcron is not running."
echo "You may start it after having updated the fcrontabs."
STOPPED=1
else
if test $ANSWER -eq 2; then
while test \( ! -z "$STOP" \) -a \( "$STOP" != "y" \) -a \( "$STOP" != "n" \);
do
echo "Would you like to do it with a '"$KILLSTR"'"
echo -n $COMMENT
echo -n "Please answer with 'y' or 'n' (default: 'y'): "
read STOP NOTHING
done
# automatic answer given by configure script (option --with-answer-all)
elif test $ANSWER -eq 1; then
STOP="y"
else
STOP="n"
fi
if test \( -z "$STOP" \) -o \( "$STOP" = "y" \); then
$KILL
STOPPED=1
fi
fi
echo
if test "$STOPPED" = "1"; then
echo "You should now update the fcrontabs format using convert-fcrontab program."
else
echo "After having restarted fcron, you should update the fcrontabs format"
echo "using the convert-fcrontab program ($SRCDIR/convert-fcrontab)"
echo "(run \"convert-fcrontab -h\" to get help) and then start the new version"
echo "of fcron."
exit 0
fi
echo "As a matter of fact, you must know that fcrontabs installed by an old"
echo "version (<1.1.x) of fcrontab won't work anymore with this version if you don't"
echo "update their format."
UPDATE="nothing"
# reinstall the fcrontabs
if test $ANSWER -eq 2; then
while test \( ! -z "$UPDATE" \) -a \( "$UPDATE" != "y" \) -a \( "$UPDATE" != "n" \);
do
echo "Would you like to do it now ?"
echo -n "Please answer with 'y' or 'n' (default: 'y'): "
read UPDATE NOTHING
done
elif test $ANSWER -eq 1; then
UPDATE="y"
else
UPDATE="n"
fi
if test \( -z "$UPDATE" \) -o \( "$UPDATE" = "y" \); then
for FILE in $FCRONTABS/* ; do \
if test "$FILE" != "$FCRONTABS/*"; then
BASENAME=`basename $FILE` ; \
FCRONTAB=`echo "$BASENAME" | \
sed "s|.*orig|| ; s|fcrontab.sig|| ; s|rm.*||"` ; \
( test ! -z "$FCRONTAB" && $SRCDIR/convert-fcrontab $FCRONTAB ) \
|| echo -n ""; \
fi
done
fi
# start the new version of fcron
echo
echo "You should now start the new version of fcron."
START="nothing"
COMMENT=""
if test "$SYSV" -eq 1; then
CMD="$ROOTDIR/init.d/fcron start"
else
CMD=$STARTCMD
fi
if test $ANSWER -eq 2; then
while test \( ! -z "$START" \) -a \( "$START" != "y" \) -a \( "$START" != "n" \);
do
echo "Would you like to do it with a '"$CMD"'"
echo -n "Please answer with 'y' or 'n' (default: 'y'): "
read START NOTHING
done
# automatic answer given by configure script (option --with-answer-all)
elif test $ANSWER -eq 1; then
START="y"
else
START="n"
fi
if test \( -z "$START" \) -o \( "$START" = "y" \); then
$CMD
fi
fi
|