I have a project where pi's have a particular (and peculiar) communcation purpose. It is irrelevant to the question.
What is relevant is that these go thru intermediate hands (like dealers) who set up id/comm protocols for end clients so they may communicate with them. No problem so far. Everything works as needed, and is pretty fine tuned. On DHCP.
Problem is that we are finding end users requiring static ip's pre assigned to the device (for various reasons). Some are corporate and it's not negotiable.
But by the time these ship to the intermediary (who ships to end user), ssh, tvservice, hdmi, are all disabled. The only communication is timed thru a port and via usbsticks which contain whitelisted configuration files at initial startup. So, the intermediary is on a network, creates a config.txt on usb and it is mounted @reboot cron for security codes, port handshake tests, etc. Two minutes, an entry into their excel to remember their security codes, and it's done. That's all they have to, or can, do.
So... for the static IP "needers", I have just made what I asssumed was a working routine for handling static IP assignments using a similar onboot routine to parse the info on a staticIP.txt file, that mimics by script the basic methods of changing to a static ip, that everyone uses. But instead of directly editing /etc/network/interfaces and /etc/resolv.cong by editor it does by script and shell, 1) copying the original two files, 2) trying to create tmp files to replace, and 3) swapping them out and restarting networking. And variations of that paradigm. It works by hand with text editors, but not by this scripting method. (all else does work - there's lots of decrypting/parsing already there - it's not a programming problem) But The Debian will not let itself be blinded - it finds the words gateway and netmask sees the intended IP's, tells me they're invalid, REPLACES THE IPs DURING THE TEXT INSERTION to what is current, and so now I'm back at square 2. (try it - I even created a simple string 'nameserver 8.8.8.8', and tried to write it alone (as a user and as root) to a hello_world.txt file, in /home, and it came out nameserver 192.168.1.0 (or close to that).) Same with gateway and netmask - I do not need to be near the interfaces file, the generated text string get's clobbered or edited, depending on my attempt.
Now this is with only ssh on (so I can write and test) - ssh will be off when it ships, but this needs work and more understanding. I imagine I'll end up prepping it so a flag warns @reboot there is a final script to run to edit these files - as the last setting at the intermediary place, so that when it reboots at the end user area, were the address, gateway, netmask, and nameservers are appropriate, the editing will be hopefully be allowed/completed. Remember - Once it leave my hands it is all automated and cut off from all normal communications.
So... How can I do this easier, (I can edit by hand to a static on one of our office networks - just not by user or sudo script). I will be trying removing it from a network for the final setup, I will try a number of things, but my intermediaries (consider them like "dealers") will not have any sophisticated abilities other than proper formatting of configuration and test files. Simple files - they wont be able to format a perfect /interfaces copy, cant expect that - I'll just be asking them to put in the appropriate address, gateway, etc. They wont want to turn off their DHCP, or do anything to their pretty much normal office networks where they set these up.
TO sum up (or clairfy): how to pre-setup a static IP, so when the pi is shipped, it is ready to work at the remote site. The OS sabotages attempts I'm trying. HDMI is already off, so I'm working on an image that will allow SSH only until I turn it off for duplication. I ultimately must use scripts for this - no problem. Perhaps some further insight into what (DHCLIENT prob) is stream correcting my input. I will be doing testing (trying the same scripts offline, etc), but I figure I'd put this out there now in case I'm missing something so simple that it's hard.
IFF this post ends up in an inappropriate place, MODS- feel free to move it.
Thanks





