Bosscheesemo
Posts: 5
Joined: Tue Jul 10, 2018 10:06 pm

Autopopulate /etc/network/interfaces

Tue Jul 10, 2018 10:18 pm

Ok so once or twice a year I'm usually forced to reset my Pi 2 B+ to factory defaults, usually because I want to try something and want to start with a fresh slate.

I gotta say though, it's a hassle setting the network settings to the way I like them every single time, and my settings are a little intricate. I've got static IP stuff for both a hardwired connection and a WiFi connection, notes, comments, alternate configs that are usually commented out but occasionally used. Is there a script I could run after each fresh install that automatically populates the network interfaces file with my already established IP settings and comments?

Thanks yo

bertlea
Posts: 180
Joined: Wed Dec 07, 2016 6:33 am
Location: Hong Kong

Re: Autopopulate /etc/network/interfaces

Wed Jul 11, 2018 3:31 am

Since you have done that before, I believe it is better (and safer) if you try to record steps and make that script yourself. I think it is just make changes / replace some configuration files (such as wpa_supplicant.conf) and do some network interface reset or even reboot.

PhatFil
Posts: 509
Joined: Thu Apr 13, 2017 3:55 pm

Re: Autopopulate /etc/network/interfaces

Wed Jul 11, 2018 4:55 am

if its a single file why not simply copy it onto the boot disk/sd when prep-ing it with an empty ssh file as part of the new setup?

Bosscheesemo
Posts: 5
Joined: Tue Jul 10, 2018 10:06 pm

Re: Autopopulate /etc/network/interfaces

Thu Jul 12, 2018 2:25 am

bertlea wrote:
Wed Jul 11, 2018 3:31 am
Since you have done that before, I believe it is better (and safer) if you try to record steps and make that script yourself. I think it is just make changes / replace some configuration files (such as wpa_supplicant.conf) and do some network interface reset or even reboot.
Yeah that script is exactly what I'm figuring out how to make right now with my question. I've got all the other parts to this script, I just need to know how to make a script that directly changes the interfaces page then resets the interfaces.

Bosscheesemo
Posts: 5
Joined: Tue Jul 10, 2018 10:06 pm

Re: Autopopulate /etc/network/interfaces

Thu Jul 12, 2018 2:30 am

PhatFil wrote:
Wed Jul 11, 2018 4:55 am
if its a single file why not simply copy it onto the boot disk/sd when prep-ing it with an empty ssh file as part of the new setup?
Because tedious things like that are exactly what computers are for. I want to save myself time in the long run and not even have to bother with even that much work. There's going to come a time when I'm not going to have time. I'm just going to need to tell the machine to reinstall then expect all of my settings to be intact from go.

bertlea
Posts: 180
Joined: Wed Dec 07, 2016 6:33 am
Location: Hong Kong

Re: Autopopulate /etc/network/interfaces

Thu Jul 12, 2018 6:06 am

Yeah that script is exactly what I'm figuring out how to make right now with my question. I've got all the other parts to this script, I just need to know how to make a script that directly changes the interfaces page then resets the interfaces.
May be you can list the steps you got. Hide the true IP and MAC addresses by using fake ones. Then tell us what script language you prefer to use, such as bash. If you got some partial success, then tell us the details where you got problems. I found there are many knowledgeable people here willing to help.

The reason I think this is better way is because I doubt there is a universal script for all kinds of automatic network configurations ready for you to use directly.

Return to “Advanced users”