. 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.
# 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
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)
### 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
[ -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
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
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
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
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)."
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"
# 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\"`."
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
# 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
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
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
#
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"
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
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:
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
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
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
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@"
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
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@"