[arch-general] Set ip lan address /etc/environment

Leonid Isaev leonid.isaev at jila.colorado.edu
Tue Jun 5 00:13:19 UTC 2018


On Fri, Jun 01, 2018 at 08:48:03AM +0200, Maykel Franco via arch-general wrote:
> 2018-05-31 12:01 GMT+02:00 Leonid Isaev via arch-general
> <arch-general at archlinux.org>:
> > On Thu, May 31, 2018 at 10:44:25AM +0100, Ralph Corderoy wrote:
> >> Hi Maykel,
> >>
> >> > I need define variable called ip with current ip address machine...
> >> > And when reboot machine, the variable ip always has ip address.
> >>
> >> Yes, I think we all figured that bit out.  :-)
> >> But why;  what's going to be using that IP-address environment variable,
> >> and when?
> >
> > Indeed. Is it for consumption of users whose shell you don't know? Is it for
> > scripts, like cron jobs?
> >
> > In the former case, see what is in /etc/shells, and drop a script to
> > /etc/profile.d, one for each shell. But that will be for login shells. In the
> > latter case, I am afraid you need to define it each time...
> >
> > Finally, a bit of a puzzle, what are you going to do when the network goes
> > down, i.e. should the variable be unset or updated? In other words, how certain
> > are you that the IP address remains unchanged throughout the machine uptime?
> >
> > --
> > Leonid Isaev
> 
> I need this for docker. I have docker services in which I use
> variables and I want to pass the always updated ip variable. If the
> network goes, it is not a problem, it will always have the same fixed
> static ip. But this way I leave docker generalized for any pc.

I don't understand: "the always updated ip variable" implies that it can
change, no? In that case, storing it in a variable, won't track the changes. If
the IP is really static, it must exist in some file, like netctl profile...

Anyways, I think a better way is to write a shell function, like my_ip() that
simply prints the IP address to stdout...

Cheers,
-- 
Leonid Isaev


More information about the arch-general mailing list