--- sh.rotate 2002/07/11 17:23:25 1.3
+++ sh.rotate 2003/02/11 12:56:40 1.4
@@ -48,7 +48,7 @@
# make sure we have at least one file to rotate
if [ ".$opt_n" = .0 ]; then
echo "$msgprefix:Error: invalid argument \`$opt_n' to option -n." 1>&2
- exit 1
+ shtool_exit 1
fi
# canonicalize -s option argument
@@ -66,14 +66,14 @@
opt_s=`expr $opt_s \* 1073741824` # 1024*1024*1024
else
echo "$msgprefix:Error: invalid argument \`$opt_s' to option -s." 1>&2
- exit 1
+ shtool_exit 1
fi
fi
# option -d/-z consistency
if [ ".$opt_d" = .yes -a ".$opt_z" = . ]; then
echo "$msgprefix:Error: option -d requires option -z." 1>&2
- exit 1
+ shtool_exit 1
fi
# make sure target directory exists
@@ -81,14 +81,14 @@
if [ ! -d $opt_a ]; then
if [ ".$opt_f" = .no ]; then
echo "$msgprefix:Error: archive directory \`$opt_a' does not exist." 1>&2
- exit 1
+ shtool_exit 1
fi
- mkdir $opt_a || exit $?
+ mkdir $opt_a || shtool_exit $?
chmod 755 $opt_a
fi
if [ ! -w $opt_a ]; then
echo "$msgprefix:Error: archive directory \`$opt_a' not writable." 1>&2
- exit 1
+ shtool_exit 1
fi
fi
@@ -106,7 +106,7 @@
[0-9] )
;;
* ) echo "$msgprefix:Error: invalid compression level \`$comp_lvl'" 1>&2
- exit 1
+ shtool_exit 1
;;
esac
@@ -136,7 +136,7 @@
done
if [ ".$comp_prg" = . ]; then
echo "$msgprefix:Error: no suitable compression tool found in \$PATH" 1>&2
- exit 1
+ shtool_exit 1
fi
fi
@@ -147,7 +147,7 @@
*/gzip | gzip ) comp_ext="gz" comp_lvl="-$comp_lvl" ;;
*/compress | compress ) comp_ext="Z"; comp_lvl="" ;;
* ) echo "$msgprefix:Error: tool \`$comp_prg' is not a known compression tool" 1>&2
- exit 1
+ shtool_exit 1
;;
esac
comp_suf=".$comp_ext"
@@ -161,7 +161,7 @@
continue
fi
echo "$msgprefix:Error: logfile \`$file' not found" 1>&2
- exit 1
+ shtool_exit 1
fi
# determine log directory (where original logfile is placed)
@@ -206,7 +206,7 @@
echo "$opt_P"
fi
eval $opt_P
- [ $? -ne 0 ] && exit $?
+ [ $? -ne 0 ] && shtool_exit $?
fi
# kick away out-rotated logfile
@@ -219,13 +219,13 @@
echo "$opt_M ${adir}/${file}.${n}${comp_suf}"
fi
eval "$opt_M ${adir}/${file}.${n}${comp_suf}"
- [ $? -ne 0 ] && exit $?
+ [ $? -ne 0 ] && shtool_exit $?
fi
# finally get rid of the out-rotated logfile
if [ ".$opt_t" = .yes ]; then
echo "rm -f ${adir}/${file}.${n}${comp_suf}"
fi
- rm -f ${adir}/${file}.${n}${comp_suf} || exit $?
+ rm -f ${adir}/${file}.${n}${comp_suf} || shtool_exit $?
fi
# rotate already archived logfiles
@@ -244,14 +244,14 @@
if [ ".$opt_t" = .yes ]; then
echo "mv ${adir}/${file}.${n} ${adir}/${file}.${m}"
fi
- mv ${adir}/${file}.${n} ${adir}/${file}.${m} || exit $?
+ mv ${adir}/${file}.${n} ${adir}/${file}.${m} || shtool_exit $?
if [ ".$opt_t" = .yes ]; then
echo "(${comp_prg} ${comp_lvl} <${adir}/${file}.${m} >${adir}/${file}.${m}${comp_suf}; rm -f ${adir}/${file}.${m}) &"
fi
( ${comp_prg} ${comp_lvl} \
<${adir}/${file}.${m} \
- >${adir}/${file}.${m}${comp_suf} || exit $?
- rm -f ${adir}/${file}.${m} || exit $?
+ >${adir}/${file}.${m}${comp_suf} || shtool_exit $?
+ rm -f ${adir}/${file}.${m} || shtool_exit $?
) </dev/null >/dev/null 2>&1 &
else
if [ ".$opt_t" = .yes ]; then
@@ -259,11 +259,11 @@
fi
${comp_prg} ${comp_lvl} \
<${adir}/${file}.${n} \
- >${adir}/${file}.${m}${comp_suf} || exit $?
+ >${adir}/${file}.${m}${comp_suf} || shtool_exit $?
if [ ".$opt_t" = .yes ]; then
echo "rm -f ${adir}/${file}.${n}"
fi
- rm -f ${adir}/${file}.${n} || exit $?
+ rm -f ${adir}/${file}.${n} || shtool_exit $?
fi
# fix file attributes
@@ -271,19 +271,19 @@
if [ ".$opt_t" = .yes ]; then
echo "chown $opt_o ${adir}/${file}.${m}${comp_suf}"
fi
- chown $opt_o ${adir}/${file}.${m}${comp_suf} || exit $?
+ chown $opt_o ${adir}/${file}.${m}${comp_suf} || shtool_exit $?
fi
if [ ".$opt_g" != . ]; then
if [ ".$opt_t" = .yes ]; then
echo "chgrp $opt_g ${adir}/${file}.${m}${comp_suf}"
fi
- chgrp $opt_g ${adir}/${file}.${m}${comp_suf} || exit $?
+ chgrp $opt_g ${adir}/${file}.${m}${comp_suf} || shtool_exit $?
fi
if [ ".$opt_m" != . ]; then
if [ ".$opt_t" = .yes ]; then
echo "chmod $opt_m ${adir}/${file}.${m}${comp_suf}"
fi
- chmod $opt_m ${adir}/${file}.${m}${comp_suf} || exit $?
+ chmod $opt_m ${adir}/${file}.${m}${comp_suf} || shtool_exit $?
fi
else
# standard case: second and following rotation file
@@ -293,7 +293,7 @@
if [ ".$opt_t" = .yes ]; then
echo "mv ${adir}/${file}.${n}${comp_suf} ${adir}/${file}.${m}${comp_suf}"
fi
- mv ${adir}/${file}.${n}${comp_suf} ${adir}/${file}.${m}${comp_suf} || exit $?
+ mv ${adir}/${file}.${n}${comp_suf} ${adir}/${file}.${m}${comp_suf} || shtool_exit $?
fi
done
@@ -303,42 +303,42 @@
if [ ".$opt_t" = .yes ]; then
echo "cp -p ${ldir}/${file} ${adir}/${file}.${n}"
fi
- cp -p ${ldir}/${file} ${adir}/${file}.${n} || exit $?
+ cp -p ${ldir}/${file} ${adir}/${file}.${n} || shtool_exit $?
if [ ".$opt_r" = .no ]; then
if [ ".$opt_t" = .yes ]; then
echo "cp /dev/null ${ldir}/${file}"
fi
- cp /dev/null ${ldir}/${file} || exit $?
+ cp /dev/null ${ldir}/${file} || shtool_exit $?
fi
else
# approach: move[+touch]
if [ ".$opt_t" = .yes ]; then
echo "mv ${ldir}/${file} ${adir}/${file}.${n}"
fi
- mv ${ldir}/${file} ${adir}/${file}.${n} || exit $?
+ mv ${ldir}/${file} ${adir}/${file}.${n} || shtool_exit $?
if [ ".$opt_r" = .no ]; then
if [ ".$opt_t" = .yes ]; then
echo "touch ${ldir}/${file}"
fi
- touch ${ldir}/${file} || exit $?
+ touch ${ldir}/${file} || shtool_exit $?
# fix file attributes
if [ ".$opt_o" != . ]; then
if [ ".$opt_t" = .yes ]; then
echo "chown $opt_o ${ldir}/${file}"
fi
- chown $opt_o ${ldir}/${file} || exit $?
+ chown $opt_o ${ldir}/${file} || shtool_exit $?
fi
if [ ".$opt_g" != . ]; then
if [ ".$opt_t" = .yes ]; then
echo "chgrp $opt_g ${ldir}/${file}"
fi
- chgrp $opt_g ${ldir}/${file} || exit $?
+ chgrp $opt_g ${ldir}/${file} || shtool_exit $?
fi
if [ ".$opt_m" != . ]; then
if [ ".$opt_t" = .yes ]; then
echo "chmod $opt_m ${ldir}/${file}"
fi
- chmod $opt_m ${ldir}/${file} || exit $?
+ chmod $opt_m ${ldir}/${file} || shtool_exit $?
fi
fi
fi
@@ -352,8 +352,8 @@
fi
( ${comp_prg} ${comp_lvl} \
<${adir}/${file}.${n} \
- >${adir}/${file}.${n}${comp_suf} || exit $?
- rm -f ${adir}/${file}.${n} || exit $?
+ >${adir}/${file}.${n}${comp_suf} || shtool_exit $?
+ rm -f ${adir}/${file}.${n} || shtool_exit $?
) </dev/null >/dev/null 2>&1 &
else
if [ ".$opt_t" = .yes ]; then
@@ -361,11 +361,11 @@
fi
${comp_prg} ${comp_lvl} \
<${adir}/${file}.${n} \
- >${adir}/${file}.${n}${comp_suf} || exit $?
+ >${adir}/${file}.${n}${comp_suf} || shtool_exit $?
if [ ".$opt_t" = .yes ]; then
echo "rm -f ${opt_a}${file}.${n}"
fi
- rm -f ${adir}/${file}.${n} || exit $?
+ rm -f ${adir}/${file}.${n} || shtool_exit $?
fi
# fix file attributes
@@ -373,19 +373,19 @@
if [ ".$opt_t" = .yes ]; then
echo "chown $opt_o ${adir}/${file}.${n}${comp_suf}"
fi
- chown $opt_o ${adir}/${file}.${n}${comp_suf} || exit $?
+ chown $opt_o ${adir}/${file}.${n}${comp_suf} || shtool_exit $?
fi
if [ ".$opt_g" != . ]; then
if [ ".$opt_t" = .yes ]; then
echo "chgrp $opt_g ${adir}/${file}.${n}${comp_suf}"
fi
- chgrp $opt_g ${adir}/${file}.${n}${comp_suf} || exit $?
+ chgrp $opt_g ${adir}/${file}.${n}${comp_suf} || shtool_exit $?
fi
if [ ".$opt_m" != . ]; then
if [ ".$opt_t" = .yes ]; then
echo "chmod $opt_m ${adir}/${file}.${n}${comp_suf}"
fi
- chmod $opt_m ${adir}/${file}.${n}${comp_suf} || exit $?
+ chmod $opt_m ${adir}/${file}.${n}${comp_suf} || shtool_exit $?
fi
fi
@@ -395,7 +395,7 @@
echo "$opt_E"
fi
eval $opt_E
- [ $? -ne 0 ] && exit $?
+ [ $? -ne 0 ] && shtool_exit $?
fi
done
|