mirror of
https://github.com/myvesta/vesta
synced 2025-08-19 21:04:07 -07:00
Fixed bug on ip removal
This commit is contained in:
parent
ee1fb98337
commit
d21cea188e
2 changed files with 11 additions and 21 deletions
|
@ -46,11 +46,17 @@ user="$(get_ip_value '$OWNER')"
|
||||||
ip_status="$(get_ip_value '$STATUS')"
|
ip_status="$(get_ip_value '$STATUS')"
|
||||||
|
|
||||||
# Deleting interface
|
# Deleting interface
|
||||||
get_current_interface
|
interface=$(/sbin/ifconfig |grep -B1 "addr:$ip "|head -n 1 |cut -f 1 -d ' ')
|
||||||
/sbin/ifconfig "$interface" down
|
if [ ! -z "$interface" ] && [ -z "$(echo $interface|cut -s -f2 -d :)" ]; then
|
||||||
|
echo "Error: Main IP on interface"
|
||||||
# Deleting startup script
|
log_event "$E_FORBIDEN" "$EVENT"
|
||||||
rm -f $iconf-$interface
|
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
|
# Deleting vesta ip
|
||||||
rm -f $VESTA/data/ips/$ip
|
rm -f $VESTA/data/ips/$ip
|
||||||
|
|
16
func/ip.sh
16
func/ip.sh
|
@ -172,22 +172,6 @@ get_ip_value() {
|
||||||
echo "$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 ip vesta configuration
|
||||||
create_vesta_ip() {
|
create_vesta_ip() {
|
||||||
ip_data="OWNER='$user'"
|
ip_data="OWNER='$user'"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue