Skip to content

Commit d21cea1

Browse files
committed
Fixed bug on ip removal
1 parent ee1fb98 commit d21cea1

File tree

2 files changed

+11
-21
lines changed

2 files changed

+11
-21
lines changed

bin/v-delete-sys-ip

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,17 @@ user="$(get_ip_value '$OWNER')"
4646
ip_status="$(get_ip_value '$STATUS')"
4747

4848
# Deleting interface
49-
get_current_interface
50-
/sbin/ifconfig "$interface" down
51-
52-
# Deleting startup script
53-
rm -f $iconf-$interface
49+
interface=$(/sbin/ifconfig |grep -B1 "addr:$ip "|head -n 1 |cut -f 1 -d ' ')
50+
if [ ! -z "$interface" ] && [ -z "$(echo $interface|cut -s -f2 -d :)" ]; then
51+
echo "Error: Main IP on interface"
52+
log_event "$E_FORBIDEN" "$EVENT"
53+
exit $E_FORBIDEN
54+
fi
55+
if [ ! -z "$interface" ]; then
56+
/sbin/ifconfig "$interface" down
57+
iconf='/etc/sysconfig/network-scripts/ifcfg'
58+
rm -f $iconf-$interface
59+
fi
5460

5561
# Deleting vesta ip
5662
rm -f $VESTA/data/ips/$ip

func/ip.sh

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -172,22 +172,6 @@ get_ip_value() {
172172
echo "$value"
173173
}
174174

175-
# Get current ip interface
176-
get_current_interface() {
177-
i=$(/sbin/ifconfig |grep -B1 "addr:$ip "|head -n 1 |cut -f 1 -d ' ')
178-
if [ -z "$i" ]; then
179-
echo "Error: interface for ip $ip not found"
180-
log_event "$E_NOTEXIST" "$EVENT"
181-
exit $E_NOTEXIST
182-
fi
183-
if [ -z "$(echo $i | cut -s -f 2 -d :)" ]; then
184-
echo "Error: Main IP on interface"
185-
log_event "$E_FORBIDEN" "$EVENT"
186-
exit $E_FORBIDEN
187-
fi
188-
interface="$i"
189-
}
190-
191175
# Create ip vesta configuration
192176
create_vesta_ip() {
193177
ip_data="OWNER='$user'"

0 commit comments

Comments
 (0)