diff --git a/ChangeLog b/ChangeLog index b2e21818c776408ccbc9d8b48f16ff4e9c287381..98482ac154e6a93e8c04664960a7edebe72316b4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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. diff --git a/configure.in b/configure.in index 2b8c2693f5e6cbf3b2f34eb5289a9072d5b43f64..716c1752a507076588d2919e7391af92f86fdff4 100644 --- a/configure.in +++ b/configure.in @@ -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 diff --git a/handlers/Makefile.am b/handlers/Makefile.am index 7d802c16a9540c5a4c0e98b2c3b6ddaa827bca20..b627f79bd8e3d31cf4022b8865c0b0b148b054e2 100644 --- a/handlers/Makefile.am +++ b/handlers/Makefile.am @@ -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) diff --git a/handlers/dup b/handlers/dup index 15d1a02f0c5e79699d95e174be9c04bf0b6c9cc2..8e0367d85e36a71b9534f8bc9a82b2cd916f600f 100644 --- a/handlers/dup +++ b/handlers/dup @@ -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 diff --git a/handlers/ldap b/handlers/ldap index 242755edcd8b393e2c7b639fbba9ec823d5cf453..5f9040a32ebe056f3f3c24050aa4ada9ab2a2d5f 100644 --- a/handlers/ldap +++ b/handlers/ldap @@ -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 diff --git a/handlers/ldap.helper b/handlers/ldap.helper index 9aecec8c0ec53ea19e4c8e6618d1eb867022c9b1..697c720209595a84c62de09a7bd8fc32a7cd938e 100644 --- a/handlers/ldap.helper +++ b/handlers/ldap.helper @@ -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 diff --git a/handlers/maildir b/handlers/maildir index 49b254217a25a62b2e245d05e01eaa1012cb3424..ab89f7042f90b150ec4355da685f200e559f8950 100644 --- a/handlers/maildir +++ b/handlers/maildir @@ -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 diff --git a/handlers/mysql b/handlers/mysql index b3d0a73b08b709325372211dd8731ee0e2f2ff0c..de4e4c3d2f920d8117c2e960e9c1f5e1619ccf22 100644 --- a/handlers/mysql +++ b/handlers/mysql @@ -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" diff --git a/handlers/pgsql b/handlers/pgsql index fb8fa4fbd54b89301e59052963dabef7a5dd3702..23e2c2b42f0553864846b1fba38c91d5d4469e1f 100644 --- a/handlers/pgsql +++ b/handlers/pgsql @@ -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\"`." diff --git a/handlers/sys b/handlers/sys index 57d9d60859c37d2efba1052b2cbe7295d65b1e0b..ce9c5b03e2d523f267d950dc2186078c9e60aacf 100755 --- a/handlers/sys +++ b/handlers/sys @@ -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 diff --git a/lib/Makefile.am b/lib/Makefile.am index fc2e052294d9237671110a225738776a896e2ac0..9f3a029bad477e83245a204a0626ad9fab64b0aa 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -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 diff --git a/lib/tools.in b/lib/tools.in index 2ec4da05c213df7b832006cdc6cebcc0d69cd27f..37fa2129105ede12e8da22113870056e32a4297b 100644 --- a/lib/tools.in +++ b/lib/tools.in @@ -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" diff --git a/lib/vserver.in b/lib/vserver.in index 8ac7b7e5fa76b18f300c683b271ddbf9d211998e..f65bd4c37a7d7e9c2e6ce09f99a6847e2b530904 100644 --- a/lib/vserver.in +++ b/lib/vserver.in @@ -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 diff --git a/src/Makefile.am b/src/Makefile.am index 44b314845c885980fd215c1c2fa43d124edd8ec3..f0cb69c12ff15061c3a78b8d7c426fbaf46827ab 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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: diff --git a/src/backupninja.in b/src/backupninja.in index 6295198761c3018ceb4add8fdba08d9faf1c02ba..02ffa25b519fc5cd7f860cd580b3c5ca8918169e 100755 --- a/src/backupninja.in +++ b/src/backupninja.in @@ -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 diff --git a/src/ninjahelper.in b/src/ninjahelper.in index 26d28567e17b04a694e4d6e899642a8bf4c492ce..040727baa7eb2de9ac54e1e85843e4ab5f4ae15f 100755 --- a/src/ninjahelper.in +++ b/src/ninjahelper.in @@ -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@"