mac address

This commit is contained in:
2026-02-15 13:54:55 +00:00
parent d20f9d156e
commit 3390145cf7
+13 -5
View File
@@ -108,23 +108,31 @@ download_file() {
# Função para configurar o endereço MAC # Função para configurar o endereço MAC
configure_mac() { configure_mac() {
local mac_script="$SCRIPT_DIR/set_mac_wifi.sh" local mac_script="$SCRIPT_DIR/set_mac_wifi.sh"
local new_mac=$1
if [ ! -f "$mac_script" ]; then if [ ! -f "$mac_script" ]; then
log "${RED}MAC address script not found${NC}" log "${RED}MAC address script not found${NC}"
return 1 return 1
fi fi
# If MAC address was provided as parameter, pass it to the script # Validate MAC address format if provided
if [ -n "$1" ]; then if [ -n "$new_mac" ]; then
if bash "$mac_script" "$1"; then if validate_mac "$new_mac"; then
log "${GREEN}MAC address configuration completed successfully${NC}" # Normalize to use colons
new_mac=$(echo "$new_mac" | tr '-' ':')
if bash "$mac_script" "$new_mac"; then
log "${GREEN}MAC address configuration completed successfully with $new_mac${NC}"
return 0 return 0
else else
log "${RED}Failed to execute MAC address configuration script${NC}" log "${RED}Failed to execute MAC address configuration script${NC}"
return 1 return 1
fi fi
else else
# If no MAC address was provided, run the script without parameters log "${RED}Invalid MAC address format: $new_mac. Please use format XX:XX:XX:XX:XX:XX or XX-XX-XX-XX-XX-XX${NC}"
return 1
fi
else
# If no MAC address was provided, run the script to generate one automatically
if bash "$mac_script"; then if bash "$mac_script"; then
log "${GREEN}MAC address configuration completed successfully${NC}" log "${GREEN}MAC address configuration completed successfully${NC}"
return 0 return 0