mac address
This commit is contained in:
Vendored
+15
-7
@@ -108,23 +108,31 @@ download_file() {
|
||||
# Função para configurar o endereço MAC
|
||||
configure_mac() {
|
||||
local mac_script="$SCRIPT_DIR/set_mac_wifi.sh"
|
||||
local new_mac=$1
|
||||
|
||||
if [ ! -f "$mac_script" ]; then
|
||||
log "${RED}MAC address script not found${NC}"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# If MAC address was provided as parameter, pass it to the script
|
||||
if [ -n "$1" ]; then
|
||||
if bash "$mac_script" "$1"; then
|
||||
log "${GREEN}MAC address configuration completed successfully${NC}"
|
||||
return 0
|
||||
# Validate MAC address format if provided
|
||||
if [ -n "$new_mac" ]; then
|
||||
if validate_mac "$new_mac"; then
|
||||
# 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
|
||||
else
|
||||
log "${RED}Failed to execute MAC address configuration script${NC}"
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
log "${RED}Failed to execute MAC address configuration script${NC}"
|
||||
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 without parameters
|
||||
# If no MAC address was provided, run the script to generate one automatically
|
||||
if bash "$mac_script"; then
|
||||
log "${GREEN}MAC address configuration completed successfully${NC}"
|
||||
return 0
|
||||
|
||||
Reference in New Issue
Block a user