Hi Daniel, Quoting Daniel Lezcano (daniel.lezc...@free.fr): > >>>+echo "Tweaking configuration" > >>>+cp $lxc_path/$lxc_orig/config $lxc_path/$lxc_new/config > >>>+sed -i '/lxc.utsname/d' $lxc_path/$lxc_new/config > >>>+echo "lxc.utsname = $hostname">> $lxc_path/$lxc_new/config > >>We should not assume lxc.utsname is in the configuration file in > >>order to not write a hostname in all the cases. > >>The user may want to let the container to setup itself the hostname. > >What do you think is the best way to do this? We could allow the user > >to specify a 'firstboot' script, which gets copied into root directory > >of the container. Maybe boot the container when it's done, run > >/firstboot.sh, and shut down. Or just let that happen when the user > >first boots. We could use a /etc/init.d/lxc-firstboot script, but > >that will only work if the container's init system actually looks at > >sysvinit scripts. Obviously sysvinit and upstart do, and I must > >assume that systemd does. lxc-init I assume doesn't. > > Mmh, that's look a bit complicate for the user. I was thinking about > something simpler like: > > grep -q "lxc.utsname" $lxc_path/$lxc_new/config > if [ $? == 0 ]; then > sed -e "s/lxc.utsname/lxc.utsname=$hostname" $lxc_path/$lxc_new/config > else > echo "lxc.utsname = $hostname">> $lxc_path/$lxc_new/config > fi
I started changing my code to this, but now am wondering how this differs from what I was doing, which was: sed -i '/lxc.utsname/d' $lxc_path/$lxc_new/config echo "lxc.utsname = $hostname" >> $lxc_path/$lxc_new/config The only difference is that in mine, if the original config had a hostname at top of file, it'll now be at bottom of file. But with both your snippets and mine, the 'lxc.utsname = new_hostname' will be the one and only utsname in the config. If you still think it's worth changing I'll do so, but I like that mine is shorter. -serge ------------------------------------------------------------------------------ EditLive Enterprise is the world's most technically advanced content authoring tool. Experience the power of Track Changes, Inline Image Editing and ensure content is compliant with Accessibility Checking. http://p.sf.net/sfu/ephox-dev2dev _______________________________________________ Lxc-users mailing list Lxc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/lxc-users