Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not hardcode eth0 in traits/network/client-mode/files/etc/config/network #8

Open
probonopd opened this issue Dec 28, 2015 · 6 comments

Comments

@probonopd
Copy link

I have a couple of devices, and the name of the main Ethernet port is different on each one: eth0, eth0.1, eth1.

Bad things happen if the image contains the wrong name in /etc/configuration/network. For example, the A5-V11 router uses eth0.1 rather than eth0 or eth1, so be aware of that in order for the wired Ethernet to work. You need to change /etc/configuration/network accordingly or the device will not be accessible after flashing without using a serial adapter to unbrick (or possibly OpenWrt Failsafe).

I see there has been work in this area
51a66f7

Is it possible to configure https://github.com/krebscode/minikrebs/blob/master/traits/network/client-mode/files/etc/config/network in a way that it does not hardcode eth0?

<makefu> firstrun.d ist eigentlich recht cool
<probono> wo finde ich die doku oder ein beispiel?
<makefu> dort kann man auch shell libs laden die sowas supporten
<makefu> ummm in einen von den aktuelleren traits
<makefu> funzt so
<makefu> datei in <trait>/files//etc/firstrun.d/44_my_script 
<makefu> wird ausgeführt beim ersten lauf
<makefu> (und danach nicht mehr)
<makefu> ausser es explodiert
@probonopd
Copy link
Author

There are files like ./builder/target/linux/ar71xx/base-files/etc/uci-defaults/02_network which seem to have the required information, I am just not sure how to make use of them for the https://github.com/krebscode/minikrebs/blob/master/traits/network/client-mode/files/etc/config/network file.

@makefu
Copy link

makefu commented Jan 4, 2016

Sorry for the delay, network/client-mode uses an old way to handle configuration (directly writes to /etc/config/network ).
New traits use the firstrun.d facility to write uci configuration.

For a sample see https://github.com/krebscode/minikrebs/blob/master/traits/network/wifi-client/files/etc/firstrun.d/10_wifi_client
in /etc/firstrun.d you write files which will be evaluated 'once' (or throw an error). In these scripts you can call uci to configure and store the changes.

Regards

@probonopd
Copy link
Author

How is that different from using target/linux/ar71xx/base-files/etc/uci-defaults/ or files/etc/uci-defaults/ which seems to be the official OpenWrt way of doing things?

See http://wiki.openwrt.org/doc/uci#defaults:

To set some system defaults the first time the device boots, create a script in the folder /etc/uci-defaults/.

All scripts in that folder are automatically executed by /etc/init.d/boot and if they exited with code 0 deleted afterwards (scripts that did not exit with code 0 are not deleted and will be re-executed during the next boot until they also successfully exit).

In a live router you can see the existing uci-defaults scripts in /rom/etc/uci-defaults , as /etc/uci-defaults itself is typically empty (after all scripts have been run ok and have been deleted).

Probably the OpenWrt way is to drop a file into etc/uci-defaults which does additional configuration after the OpenWrt-provided scripts there have run.

Please see what I have written at probonopd#1 (comment) - not tested yet, though (I don't have a serial console available right now for testing in case it goes bad...)

@makefu
Copy link

makefu commented Jan 5, 2016

oh oh, it seems i have rebuilt something which existed before in openwrt anyway :
But the idea is the same, write a script dump it in etc/uci-default and it will evaluate on first boot.
Thanks for the heads-up.

@makefu makefu closed this as completed in 3ab133d May 10, 2016
@probonopd
Copy link
Author

I don't see how this commit closes this issue...

@makefu makefu reopened this May 15, 2016
@makefu
Copy link

makefu commented May 15, 2016

somehow while merging your code github decided to close this issue ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants