updated autotools abstraction to properly pick up different awk, sed,

and md5sum locations
This commit is contained in:
Micah Anderson 2007-02-23 18:04:04 +00:00
parent d15a347be5
commit 05c26446ed
16 changed files with 55 additions and 37 deletions

View File

@ -3,6 +3,7 @@ version 0.9.5 -- unreleased
. Fixed checks on configuration files permissions, since the patch
applied to fix #370396 broke this, especially for configuration files
created with permissions 000 by an older ninjahelper version.
. Enhanced portability for other platforms
handler changes
sys:
. Fixed typo breaking things for VServers.

View File

@ -12,20 +12,30 @@ AM_INIT_AUTOMAKE
# BASH may already be set in the shell, if the admin then changes the
# the /bin/sh symlink to a non-bash shell, all hell will break lose.
unset BASH
AC_PATH_PROGS([BASH], [bash], [/bin/bash], [$PATH:/bin:/usr/bin:/usr/sbin])
if test x$BASH = "x"; then
AC_PATH_PROGS(BASH, bash, "no", [$PATH:/bin:/usr/bin:/usr/sbin])
if test x$BASH = "xno"; then
AC_MSG_ERROR([bash is required])
fi
AC_CHECK_PROGS(SED, sed)
if test x$SED = "x"; then
AC_PATH_PROGS(SED, sed, "no")
if test x$SED = "xno"; then
AC_MSG_ERROR([sed is required])
else
export SED
fi
AC_CHECK_PROGS(AWK, awk)
if test x$AWK = "x"; then
AC_PATH_PROGS(AWK, awk, "no")
if test x$AWK = "xno"; then
AC_MSG_ERROR([awk is required])
else
export AWK
fi
AC_PATH_PROGS(MD5SUM, md5sum, "no")
if test x$MD5SUM = "xno"; then
AC_MSG_ERROR([md5sum is required])
fi
AC_CHECK_PROG(ac_cv_have_rpm, rpm, "yes", "no")
if test "x$ac_cv_have_rpm" = "xyes"; then
rpm --define '_topdir /tmp' > /dev/null 2>&1

View File

@ -5,4 +5,9 @@ HANDLERS = dup dup.helper maildir mysql.helper rdiff sys makecd makecd.helper \
EXTRA_DIST = Makefile.am $(HANDLERS)
edit = sed \
-e "s,@BASH\@,$(BASH),g" \
-e "s,@AWK\@,$(AWK),g" \
-e "s,@SED\@,$(SED),g"
dist_pkgdata_DATA = $(HANDLERS)

View File

@ -71,10 +71,10 @@ fi
### COMMAND-LINE MANGLING ###
# duplicity >= 0.4.2 needs --sftp-command (NB: sftp does not support the -l option)
duplicity_version="`duplicity --version | awk '{print $2}'`"
duplicity_major="`echo $duplicity_version | awk -F '.' '{print $1}'`"
duplicity_minor="`echo $duplicity_version | awk -F '.' '{print $2}'`"
duplicity_sub="`echo $duplicity_version | awk -F '.' '{print $3}'`"
duplicity_version="`duplicity --version | @AWK@ '{print $2}'`"
duplicity_major="`echo $duplicity_version | @AWK@ -F '.' '{print $1}'`"
duplicity_minor="`echo $duplicity_version | @AWK@ -F '.' '{print $2}'`"
duplicity_sub="`echo $duplicity_version | @AWK@ -F '.' '{print $3}'`"
if [ "$duplicity_major" -ge 0 -a "$duplicity_minor" -ge 4 -a "$duplicity_sub" -ge 2 ]; then
sftpoptions="$sshoptions"
fi

View File

@ -27,7 +27,7 @@ status="ok"
[ -d $backupdir ] || mkdir -p $backupdir
[ -d $backupdir ] || fatal "Backup directory '$backupdir'"
dbsuffixes=(`awk 'BEGIN {OFS=":"} /[:space:]*^database[:space:]*\w*/ {db=$2}; /^[:space:]*suffix[:space:]*\w*/ {if (db=="bdb"||db=="ldbm") print db,$2}' $conf|sed -e 's/[" ]//g'`)
dbsuffixes=(`@AWK@ 'BEGIN {OFS=":"} /[:space:]*^database[:space:]*\w*/ {db=$2}; /^[:space:]*suffix[:space:]*\w*/ {if (db=="bdb"||db=="ldbm") print db,$2}' $conf|@SED@ -e 's/[" ]//g'`)
## LDIF DUMP

View File

@ -54,7 +54,7 @@ done
ldap_wizard() {
bdb=no
ldbm=no
for backend in `grep -e "^backend" /etc/ldap/slapd.conf | awk '{print $2}'`; do
for backend in `grep -e "^backend" /etc/ldap/slapd.conf | @AWK@ '{print $2}'`; do
if [ "$backend" == "bdb" -a "$bdb" == "no" ]; then
bdb=yes
elif [ "$backend" == "ldbm" -a "$ldbm" == "no" ]; then

View File

@ -157,7 +157,7 @@ function do_rotate() {
fi
# Rotate the current list of backups, if we can.
oldest=\`find $backuproot -type d -maxdepth 1 -name \$rottype'.*' | sed 's/^.*\.//' | sort -n | tail -1\`
oldest=\`find $backuproot -type d -maxdepth 1 -name \$rottype'.*' | @SED@ 's/^.*\.//' | sort -n | tail -1\`
#echo "Debug: oldest \$oldest"
[ "\$oldest" == "" ] && oldest=0
for (( i=\$oldest; i > 0; i-- )); do
@ -201,7 +201,7 @@ function do_rotate() {
for rottype in daily weekly monthly; do
max=\$((keep\${rottype}+1))
dir="$backuproot/\$rottype"
oldest=\`find $backuproot -type d -maxdepth 1 -name \$rottype'.*' | sed 's/^.*\.//' | sort -n | tail -1\`
oldest=\`find $backuproot -type d -maxdepth 1 -name \$rottype'.*' | @SED@ 's/^.*\.//' | sort -n | tail -1\`
[ "\$oldest" == "" ] && oldest=0
# if we've rotated the last backup off the stack, remove it.
for (( i=\$oldest; i >= \$max; i-- )); do

View File

@ -90,10 +90,10 @@ if [ "$dbusername" != "" -a "$dbpassword" != "" ]
then
if [ $usevserver = yes ]
then
vhome=`$VSERVER $vsname exec getent passwd "root" | awk -F: '{print $6}'`
vhome=`$VSERVER $vsname exec getent passwd "root" | @AWK@ -F: '{print $6}'`
home="$vroot$vhome"
else
home=`getent passwd "root" | awk -F: '{print $6}'`
home=`getent passwd "root" | @AWK@ -F: '{print $6}'`
fi
[ -d $home ] || fatal "Can't find root's home directory ($home)."
@ -144,14 +144,14 @@ else
userset=true;
if [ $usevserver = yes ]
then
vuserhome=`$VSERVER $vsname exec getent passwd "$user" | awk -F: '{print $6}'`
vuserhome=`$VSERVER $vsname exec getent passwd "$user" | @AWK@ -F: '{print $6}'`
if [ $? -eq 2 ]
then
fatal "User $user not found in /etc/passwd"
fi
userhome="$vroot$vuserhome"
else
userhome=`getent passwd "$user" | awk -F: '{print $6}'`
userhome=`getent passwd "$user" | @AWK@ -F: '{print $6}'`
if [ $? -eq 2 ]
then
fatal "User $user not found in /etc/passwd"

View File

@ -62,9 +62,9 @@ fi
# give backup dir the good uid and permissions
# (in respect to the vserver, if $usevserver = yes)
if [ $usevserver = yes ]; then
pguid=`$VSERVER $vsname exec getent passwd $PGSQLUSER | awk -F: '{print $3}'`
pguid=`$VSERVER $vsname exec getent passwd $PGSQLUSER | @AWK@ -F: '{print $3}'`
else
pguid=`getent passwd $PGSQLUSER | awk -F: '{print $3}'`
pguid=`getent passwd $PGSQLUSER | @AWK@ -F: '{print $3}'`
fi
[ -n "$pguid" ] || \
fatal "No user called $PGSQLUSER`[ $usevserver = no ] || echo \" on vserver $vsname\"`."

View File

@ -188,7 +188,7 @@ elif [ $os = "debian" ]; then
echo "Level: $level" >> $sysreportfile
for f in /etc/rc${level}.d/*; do
# Remove /etc/Knn or Snn from beginning
ff=$(echo $f | sed 's_/etc/rc..d/[KS][0-9][0-9]__')
ff=$(echo $f | @SED@ 's_/etc/rc..d/[KS][0-9][0-9]__')
if [ $f != $ff ]; then
echo $ff >> $sysreportfile
fi
@ -443,7 +443,7 @@ fi
# these files can be used to directly partition a disk of the same size.
if [ "$partitions" == "yes" ]; then
devices=`$SFDISK -l 2>/dev/null | grep "^Disk /dev" | awk '{print $2}' | cut -d: -f1`
devices=`$SFDISK -l 2>/dev/null | grep "^Disk /dev" | @AWK@ '{print $2}' | cut -d: -f1`
if [ "$devices" == "" ]; then
warning "No harddisks found"
fi

View File

@ -7,10 +7,10 @@ EXTRA_DIST = easydialog.in parseini.in tools.in vserver.in
edit = sed \
-e "s,@CFGDIR\@,$(CFGDIR),g" \
-e "s,@BASH\@,$(BASH),g" \
-e 's,@datadir\@,$(pkgdatadir),g' \
-e "s,@libdir\@,$(pkglibdir),g" \
-e 's,@localstatedir\@,$(localstatedir),g' \
-e 's,@prefix\@,$(prefix),g'
-e "s,@AWK\@,$(AWK),g" \
-e "s,@SED\@,$(SED),g" \
-e "s,@MD5SUM\@,$(MD5SUM),g" \
-e "s,@libdir\@,$(pkglibdir),g"
easydialog: $(srcdir)/easydialog.in
rm -f easydialog

View File

@ -15,7 +15,7 @@ function maketemp() {
local tempfile=`mktemp /tmp/$1.XXXXXXXX`
else
DATE=`date`
sectmp=`echo $DATE | /usr/bin/md5sum | cut -d- -f1`
sectmp=`echo $DATE | @MD5SUM@ | cut -d- -f1`
local tempfile=/tmp/$1.$sectmp
fi
echo $tempfile
@ -39,7 +39,7 @@ function setsection() {
#
function getconf() {
CURRENT_PARAM=$1
ret=`awk -f $libdirectory/parseini S=$CURRENT_SECTION P=$CURRENT_PARAM $CURRENT_CONF_FILE`
ret=`@AWK@ -f $libdirectory/parseini S=$CURRENT_SECTION P=$CURRENT_PARAM $CURRENT_CONF_FILE`
# if nothing is returned, set the default
if [ "$ret" == "" -a "$2" != "" ]; then
ret="$2"

View File

@ -33,7 +33,7 @@ init_vservers() {
getconf vservers no
getconf VSERVERINFO /usr/sbin/vserver-info
getconf VSERVER /usr/sbin/vserver
getconf VROOTDIR `if [ -x "$VSERVERINFO" ]; then $VSERVERINFO info SYSINFO | grep '^ *vserver-Rootdir' | awk '{print $2}'; fi`
getconf VROOTDIR `if [ -x "$VSERVERINFO" ]; then $VSERVERINFO info SYSINFO | grep '^ *vserver-Rootdir' | @AWK@ '{print $2}'; fi`
# canonicalize VROOTDIR
[ -z "$VROOTDIR" ] || VROOTDIR=`readlink --canonicalize $VROOTDIR`
# init this library's global variables

View File

@ -9,10 +9,12 @@ EXTRA_DIST = backupninja.in ninjahelper.in
edit = sed \
-e "s,@CFGDIR\@,$(CFGDIR),g" \
-e "s,@BASH\@,$(BASH),g" \
-e "s,@AWK\@,$(AWK),g" \
-e "s,@SED\@,$(SED),g" \
-e 's,@datadir\@,$(pkgdatadir),g' \
-e "s,@libdir\@,$(pkglibdir),g" \
-e 's,@localstatedir\@,$(localstatedir),g' \
-e 's,@prefix\@,$(prefix),g'
-e 's,@prefix\@,$(prefix),g'
#install-exec-hook:

View File

@ -34,7 +34,7 @@ function setupcolors () {
function colorize () {
if [ "$usecolors" == "yes" ]; then
local typestr=`echo "$@" | sed 's/\(^[^:]*\).*$/\1/'`
local typestr=`echo "$@" | @SED@ 's/\(^[^:]*\).*$/\1/'`
[ "$typestr" == "Debug" ] && type=0
[ "$typestr" == "Info" ] && type=1
[ "$typestr" == "Warning" ] && type=2
@ -68,7 +68,7 @@ function printmsg() {
type=$1
shift
if [ $type == 100 ]; then
typestr=`echo "$@" | sed 's/\(^[^:]*\).*$/\1/'`
typestr=`echo "$@" | @SED@ 's/\(^[^:]*\).*$/\1/'`
[ "$typestr" == "Debug" ] && type=0
[ "$typestr" == "Info" ] && type=1
[ "$typestr" == "Warning" ] && type=2
@ -204,7 +204,7 @@ function isnow() {
whendayofweek=$1; at=$2; whentime=$3;
whenday=`toint "$whendayofweek"`
whendayofweek=`tolower "$whendayofweek"`
whentime=`echo "$whentime" | sed 's/:[0-9][0-9]$//' | sed -r 's/^([0-9])$/0\1/'`
whentime=`echo "$whentime" | @SED@ 's/:[0-9][0-9]$//' | @SED@ -r 's/^([0-9])$/0\1/'`
if [ "$whendayofweek" == "everyday" -o "$whendayofweek" == "daily" ]; then
whendayofweek=$nowdayofweek
@ -409,7 +409,7 @@ if [ ! -r "$conffile" ]; then
fi
# find $libdirectory
libdirectory=`grep '^libdirectory' $conffile | awk '{print $3}'`
libdirectory=`grep '^libdirectory' $conffile | @AWK@ '{print $3}'`
if [ -z "$libdirectory" ]; then
if [ -d "@libdir@" ]; then
libdirectory="@libdir@"
@ -541,9 +541,9 @@ if [ $doit == 1 ]; then
if [ "$reportspace" == "yes" ]; then
previous=""
for i in $(ls "$configdirectory"); do
backuploc=$(grep ^directory "$configdirectory"/"$i" | awk '{print $3}')
backuploc=$(grep ^directory "$configdirectory"/"$i" | @AWK@ '{print $3}')
if [ "$backuploc" != "$previous" ]; then
mountdev=$(mount | grep "$backuploc" | awk '{print $1}')
mountdev=$(mount | grep "$backuploc" | @AWK@ '{print $1}')
df -h "$mountdev"
previous="$backuploc"
fi

View File

@ -183,7 +183,7 @@ if [ ! -r "$conffile" ]; then
fi
# find $libdirectory
libdirectory=`grep '^libdirectory' $conffile | awk '{print $3}'`
libdirectory=`grep '^libdirectory' $conffile | @AWK@ '{print $3}'`
if [ -z "$libdirectory" ]; then
if [ -d "@libdir@" ]; then
libdirectory="@libdir@"