My goal is to set a specific mac address per user that gets assigned when a given user logs in.
I have a shell script that reads a config file and sets the mac address correctly when executed from a terminal session while logged in.
I have tried using the "Startup Applications" to run this, but with no effect.
I have also tried adding it to /etc/init.d with a symbolic link to /etc/rc5.d, but this also seems to have no effect.
For reference: here is my current script
#!/bin/bash
#Set config file name
input_file=set_user_address_config
tail -n +2 "$input_file" | while IFS=, read -r new_usr new_mac _
do
sudo ip link set dev enp86s0 down
echo "network down"
echo "logname: $(logname)"
echo "id: $(id)"
echo "whoami: $(whoami)"
echo "new_usr: $new_usr"
printf "new_mac: $new_mac \n\n"
if [ "$(logname)" = "$new_usr" ]
then
sudo ip link set dev enp86s0 address "$new_mac"
echo "mac changed to $new_mac"
else
printf "User didn't match' \n\n"
fi
done
sudo ip link set dev enp86s0 up