How to run a script at startup?

I am using the red network with a wifi antenna, which means my wan is an SSID, but whenever the system boots, I have to do a couple of steps before I can connect to the internet, first, I have to go to the tab network, in Assign MAC Address, change the mac, hit save and reconnect, then go to the system tab, and in Wireless Client, and there deactivate and activate the SSID, after all that, ipfire connects to the SSID and I manage to have Internet.
What I need is a script that runs at startup, but I don’t know where to put it, with chatgpt I can get the script, put it in the file /etc/sysconfig/rc.local but it does not work, here is the script

ifconfig red0 hw ether 94:5c:9a:b6:fd:90

ifconfig red0 down
sleep 3
ifconfig red0 up

curl -s -k -u user:password -X POST ‘https://10.0.0.1:444/cgi-bin/wirelessclient.cgi’ -d ‘disable_ssid=SSID’
sleep 3
curl -s -k -u user:password -X POST ‘https://10.0.0.1:444/cgi-bin/wirelessclient.cgi’ -d ‘enable_ssid=SSID’

I know that in the curl you have to change user:password and the ssid name, I just put it like this for privacy.

Maybe this can help you: wiki.ipfire.org - fcron

1 Like

Hello @renlord welcome to our community.

the script does not work in rc.local or it does not work at all? You need to have a script that when manually run, works according to expectations. Only after you have a functioning script we can discuss when it should be called in the boot sequence. I other words, you should be able to reboot, connect to the console, call the script and get online before discussing where to put the script.

1 Like

One thing this piece of text lacks to be a script is the shebang in the first line.
This should be generated by ChatGPT!

BTW, what is the reason for this complicated wireless initialization? Should it be put into network start scripts, if necessary?

2 Likes

Didn’t some one have a similar problem
With a cellular connection on red.
With the adapter using random mac addresses?
Can’t find it.

Do you think about it?

2 Likes

This is what made me think of this post.
Thanks @tphz

1 Like