projects
/
carnet-tools-cn.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
0246b1c
)
r21:
author
Ivan Rako
<Ivan.Rako@CARNet.hr>
Tue, 22 Mar 2005 14:31:48 +0000
(14:31 +0000)
committer
Ivan Rako
<Ivan.Rako@CARNet.hr>
Tue, 22 Mar 2005 14:31:48 +0000
(14:31 +0000)
functions.sh
patch
|
blob
|
history
diff --git
a/functions.sh
b/functions.sh
index
5bb7ae6
..
2f91b82
100644
(file)
--- a/
functions.sh
+++ b/
functions.sh
@@
-1,7
+1,11
@@
# by ddzeko & ico, Fri, 18 Mar 2005 14:44:08 +0100
cp_get_ifaddr() {
[ "$CP_SCRIPT_DEBUG" ] && set -vx
# by ddzeko & ico, Fri, 18 Mar 2005 14:44:08 +0100
cp_get_ifaddr() {
[ "$CP_SCRIPT_DEBUG" ] && set -vx
- local ifaddr interface
+ local ifaddr interface echo_return
+ echo_return="$CP_ECHO_RETURN" # since we're making our own calls
+ # in our own way we need to set CP_ECHO_RETURN the way we want it
+ # but preserving initial state so it could be used afterwards
+ CP_ECHO_RETURN=""
interface="$1"
if [ -z "$interface" ]; then
interface="$1"
if [ -z "$interface" ]; then
@@
-12,6
+16,7
@@
cp_get_ifaddr() {
if ! ifconfig $interface 2> /dev/null >> /dev/null; then
echo "cp_get_ifaddr: $interface: No such interface" 1>&2
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
fi
return 1
fi
@@
-19,17
+24,23
@@
cp_get_ifaddr() {
if [ -z $ifaddr ]; then
echo "cp_get_ifaddr: $interface: No such ipaddress" 1>&2
if [ -z $ifaddr ]; then
echo "cp_get_ifaddr: $interface: No such ipaddress" 1>&2
+ CP_ECHO_RETURN="$echo_return"
return 1
fi
RET="$ifaddr"
return 1
fi
RET="$ifaddr"
- [ -z "$CP_ECHO_RETURN" ] || echo $RET
+ [ -z "$echo_return" ] || echo $RET
+ CP_ECHO_RETURN="$echo_return"
}
# by ddzeko & ico, Fri, 18 Mar 2005 14:44:08 +0100
cp_get_ifmask() {
[ "$CP_SCRIPT_DEBUG" ] && set -vx
}
# by ddzeko & ico, Fri, 18 Mar 2005 14:44:08 +0100
cp_get_ifmask() {
[ "$CP_SCRIPT_DEBUG" ] && set -vx
- local ifmask interface
+ local ifmask interface echo_return
+ echo_return="$CP_ECHO_RETURN" # since we're making our own calls
+ # in our own way we need to set CP_ECHO_RETURN the way we want it
+ # but preserving initial state so it could be used afterwards
+ CP_ECHO_RETURN=""
interface="$1"
if [ -z "$interface" ]; then
interface="$1"
if [ -z "$interface" ]; then
@@
-40,6
+51,7
@@
cp_get_ifmask() {
if ! ifconfig $interface 2> /dev/null >> /dev/null; then
echo "cp_get_ifmask: $interface: No such interface" 1>&2
if ! ifconfig $interface 2> /dev/null >> /dev/null; then
echo "cp_get_ifmask: $interface: No such interface" 1>&2
+ CP_ECHO_RETURN="$echo_return"
return 1
fi
return 1
fi
@@
-47,15
+59,23
@@
cp_get_ifmask() {
if [ -z "$ifmask" ]; then
echo "cp_get_ifmask: $interface: No such netmask" 1>&2
if [ -z "$ifmask" ]; then
echo "cp_get_ifmask: $interface: No such netmask" 1>&2
+ CP_ECHO_RETURN="$echo_return"
return 1
fi
RET="$ifmask"
return 1
fi
RET="$ifmask"
- [ -z "$CP_ECHO_RETURN" ] || echo $RET
+ [ -z "$echo_return" ] || echo $RET
+ CP_ECHO_RETURN="$echo_return"
}
# by ddzeko, Mon, 21 Mar 2005 07:00:22 +0100
cp_get_ifdefault() {
}
# by ddzeko, Mon, 21 Mar 2005 07:00:22 +0100
cp_get_ifdefault() {
+ local echo_return
+ echo_return="$CP_ECHO_RETURN" # since we're making our own calls
+ # in our own way we need to set CP_ECHO_RETURN the way we want it
+ # but preserving initial state so it could be used afterwards
+ CP_ECHO_RETURN=""
+
[ "$CP_SCRIPT_DEBUG" ] && set -vx
RET=""
case $1 in
[ "$CP_SCRIPT_DEBUG" ] && set -vx
RET=""
case $1 in
@@
-64,7
+84,8
@@
cp_get_ifdefault() {
*) echo "cp_get_ifdefault: Argument required (dev or addr)" >&2 ;;
esac
[ -z "$RET" -a "$1" -a "$CP_VERBOSE" ] && echo "cp_get_ifdefault: No default route" >&2
*) echo "cp_get_ifdefault: Argument required (dev or addr)" >&2 ;;
esac
[ -z "$RET" -a "$1" -a "$CP_VERBOSE" ] && echo "cp_get_ifdefault: No default route" >&2
- [ -z "$CP_ECHO_RETURN" ] || echo $RET
+ [ -z "$echo_return" ] || echo $RET
+ CP_ECHO_RETURN="$echo_return"
[ -z "$RET" ] && return 1
}
[ -z "$RET" ] && return 1
}
@@
-86,19
+107,23
@@
cp_get_netaddr() {
if ! ifconfig $interface 2> /dev/null >> /dev/null; then
echo "cp_get_netaddr: $interface: No such interface" 1>&2
if ! ifconfig $interface 2> /dev/null >> /dev/null; then
echo "cp_get_netaddr: $interface: No such interface" 1>&2
- goto return1
+ 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
fi
cp_get_ifaddr "$interface"
ipaddress="$RET"
if [ -z $ipaddress ]; then
echo "cp_get_netaddr: $interface: No such ipaddress" 1>&2
- goto return1
+ 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
fi
cp_get_ifmask "$interface"
netmask="$RET"
if [ -z $netmask ]; then
echo "cp_get_netaddr: $interface: No such netmask" 1>&2
+ CP_ECHO_RETURN="$echo_return"
+ return 1
fi
if [ "$netmask" = "255.255.255.255" ]; then
fi
if [ "$netmask" = "255.255.255.255" ]; then
@@
-110,11
+135,6
@@
cp_get_netaddr() {
RET="$cidr"
[ -z "$echo_return" ] || echo $RET
CP_ECHO_RETURN="$echo_return"
RET="$cidr"
[ -z "$echo_return" ] || echo $RET
CP_ECHO_RETURN="$echo_return"
- return 0
-
- return1:
- CP_ECHO_RETURN="$echo_return"
- return 1
}
# by ico, Tue, 15 Mar 2005 14:04:21 +0100
}
# by ico, Tue, 15 Mar 2005 14:04:21 +0100
@@
-123,7
+143,6
@@
cp_backup_conffile() {
local file_bak
if [ -z "$1" ]; then
local file_bak
if [ -z "$1" ]; then
- echo "Usage: cp_backup_conffile <file>" 1>&2
return 1
fi
if [ ! -f "$1" ]; then
return 1
fi
if [ ! -f "$1" ]; then
@@
-224,7
+243,6
@@
cp_safe_file_replace () {
[ "$CP_SCRIPT_DEBUG" ] && set -vx
local new old
if [ -z "$2" ]; then
[ "$CP_SCRIPT_DEBUG" ] && set -vx
local new old
if [ -z "$2" ]; then
- echo "Usage: cp_safe_file_replace <new-file> <target-file>" 1>&2
return 1
fi
new="$1"
return 1
fi
new="$1"