Update menu-ip

This commit is contained in:
Script Proyect by HP3ICC 2024-12-01 07:20:52 +00:00
parent 4578223a35
commit 9396bb8850
1 changed files with 17 additions and 12 deletions

View File

@ -1,6 +1,11 @@
#!/bin/bash
if [ "$(cat /proc/cpuinfo | grep 'Raspberry')" != "" ]; then
# menu-ip
if dpkg -l | grep -q "network-manager"; then
# Verificar si es un VPS o máquina virtual
if systemd-detect-virt --quiet; then
echo "El sistema está ejecutándose en una máquina virtual."
#exit 0
else
# menu-ip "server"
sudo cat > /bin/menu-ip <<- "EOF"
#!/bin/bash
@ -73,10 +78,11 @@ do
break
fi
if [ "$selected_device" == "eth0" ]; then
device_name="Wired connection 1"
elif [ "$selected_device" == "wlan0" ]; then
# Detectar el nombre del dispositivo basado en la interfaz seleccionada
if [[ "$selected_device" == wlp* ]]; then
device_name=$(nmcli -t -f active,ssid dev wifi | egrep '^yes' | cut -d: -f2)
else
device_name=$(nmcli -t -f name,device con show --active | grep -i "$selected_device" | cut -d: -f1)
fi
choice=$(whiptail --title "Static / DHCP" --menu "Selecciona una opción para $selected_device:" 15 60 4 \
@ -87,8 +93,8 @@ do
case $choice in
1)
# Configurar DHCP para el dispositivo seleccionado
sudo nmcli con mod "$device_name" ipv4.addresses "" ipv4.gateway ""
sudo nmcli con mod "$device_name" ipv4.method auto
sudo nmcli con mod "$device_name" ipv4.addresses ""
sudo nmcli con up "$device_name"
sudo systemctl stop NetworkManager &&
sudo systemctl start NetworkManager
@ -156,13 +162,12 @@ do
done
exit 0
else
whiptail --title "IP Tools" --msgbox "Esta opcion solo esta disponible para Raspberry / This option is only available for Raspberry" 0 50
exit 0
EOF
chmod +x /bin/menu-ip
fi
fi
if [ -f "/bin/menu-ip" ]; then
sudo chmod +x /bin/menu-ip
ln -sf /bin/menu-ip /bin/MENU-IP
chmod +x /bin/MENU*
sudo chmod +x /bin/MENU*
fi