if ! ifconfig $interface 2> /dev/null >> /dev/null; then
echo "cp_get_ifaddr: $interface: No such interface" 1>&2
CP_ECHO_RETURN="$echo_return"
- return 1
+ return 2
fi
ifaddr="`/sbin/ifconfig $interface | awk '/inet/{ printf("%s\n",substr($2,index($2,":")+1)) }'`"
if [ -z $ifaddr ]; then
- echo "cp_get_ifaddr: $interface: No such ipaddress" 1>&2
+ echo "cp_get_ifaddr: $interface: No ip address found" 1>&2
CP_ECHO_RETURN="$echo_return"
return 1
fi
ifmask="`/sbin/ifconfig $interface | awk '/Mask/{if($3~/Mask/)a=$3;else if ($4~/Mask/)a=$4;printf ("%s\n", substr(a,index(a,":")+1))}'`"
if [ -z "$ifmask" ]; then
- echo "cp_get_ifmask: $interface: No such netmask" 1>&2
+ echo "cp_get_ifmask: $interface: No netmask found" 1>&2
CP_ECHO_RETURN="$echo_return"
return 1
fi
cp_get_ifaddr "$interface"
ipaddress="$RET"
if [ -z $ipaddress ]; then
- echo "cp_get_netaddr: $interface: No such ipaddress" 1>&2
+ echo "cp_get_netaddr: $interface: No IP address found" 1>&2
CP_ECHO_RETURN="$echo_return"
return 1
fi
cp_get_ifmask "$interface"
netmask="$RET"
if [ -z $netmask ]; then
- echo "cp_get_netaddr: $interface: No such netmask" 1>&2
+ echo "cp_get_netaddr: $interface: No netmask found" 1>&2
CP_ECHO_RETURN="$echo_return"
return 1
fi
fi
if [ ! -f "$1" ]; then
echo "cp_backup_conffile: $1: No such file" 1>&2
- return 1
+ return 2
fi
if [ -z "$2" ]; then
file_bak="/var/backups/`basename $1`.bak"
#
cp_check_and_sed() {
[ "$CP_SCRIPT_DEBUG" ] && set -vx
- local s sedcmd ret i
+ local s sedcmd grepret ret i
s="$1"
shift
sedcmd="$1"
for i in "$@"
do
[ -e "$i" ] || continue
- egrep -q "$s" "$i" || continue
+ if ! egrep -q "$s" "$i"; then
+ grepret=1
+ continue
+ fi
[ -h "$i" ] && i=$(readlink -f "$i")
sed "$sedcmd" "$i" > "$i.dpkg-tmp"
if ! cmp -s "$i" "$i.dpkg-tmp" 2>&1 >/dev/null; then
fi
ret=0
done
+ [ "$ret" -eq 2 -a "$grepret"] && ret=1 || true
return $ret
}
if [ ! -f /etc/ldap/slapd.conf ]; then
echo "cp_get_ldap_suffix: /etc/ldap/slapd.conf: No such file" >&2
- return 1
+ return 2
fi
RET="`awk '/^suffix/ { exit }
if [ ! -f /etc/ldap/slapd.conf ]; then
echo "cp_get_ldap_realm: /etc/ldap/slapd.conf: No such file" >&2
- return 1
+ return 2
fi
cp_get_ldap_suffix || true