Skip to content

Commit

Permalink
Fixed bug on ip removal
Browse files Browse the repository at this point in the history
  • Loading branch information
serghey-rodin committed Feb 20, 2013
1 parent ee1fb98 commit d21cea1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 21 deletions.
16 changes: 11 additions & 5 deletions bin/v-delete-sys-ip
Expand Up @@ -46,11 +46,17 @@ user="$(get_ip_value '$OWNER')"
ip_status="$(get_ip_value '$STATUS')"

# Deleting interface
get_current_interface
/sbin/ifconfig "$interface" down

# Deleting startup script
rm -f $iconf-$interface
interface=$(/sbin/ifconfig |grep -B1 "addr:$ip "|head -n 1 |cut -f 1 -d ' ')
if [ ! -z "$interface" ] && [ -z "$(echo $interface|cut -s -f2 -d :)" ]; then
echo "Error: Main IP on interface"
log_event "$E_FORBIDEN" "$EVENT"
exit $E_FORBIDEN
fi
if [ ! -z "$interface" ]; then
/sbin/ifconfig "$interface" down
iconf='/etc/sysconfig/network-scripts/ifcfg'
rm -f $iconf-$interface
fi

# Deleting vesta ip
rm -f $VESTA/data/ips/$ip
Expand Down
16 changes: 0 additions & 16 deletions func/ip.sh
Expand Up @@ -172,22 +172,6 @@ get_ip_value() {
echo "$value"
}

# Get current ip interface
get_current_interface() {
i=$(/sbin/ifconfig |grep -B1 "addr:$ip "|head -n 1 |cut -f 1 -d ' ')
if [ -z "$i" ]; then
echo "Error: interface for ip $ip not found"
log_event "$E_NOTEXIST" "$EVENT"
exit $E_NOTEXIST
fi
if [ -z "$(echo $i | cut -s -f 2 -d :)" ]; then
echo "Error: Main IP on interface"
log_event "$E_FORBIDEN" "$EVENT"
exit $E_FORBIDEN
fi
interface="$i"
}

# Create ip vesta configuration
create_vesta_ip() {
ip_data="OWNER='$user'"
Expand Down

0 comments on commit d21cea1

Please sign in to comment.