[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: sed append in preseed/late_command



On 06/11/12 08:01 AM, Philip Hands wrote:
Jack Bates <q34yzh@nottheoilrig.com> writes:
Hi,

How can I use sed in preseed/late_command to insert a new line, two
lines after the line which contains "<!-- Volume definitions -->", in
pam_mount.conf.xml?

Normally I'd use something like the following, but I think the sed
append command must be terminated with a newline?

  > in-target sed -i '/<!-- Volume definitions -->/ {
  >     n
  >     a <volume fstype="cifs" mountpoint="~/earth"
path="students/%(USER)" pgrp="users" server="earth.lan" />
  >   }' etc/security/pam_mount.conf.xml

Is there any way to express this script ^ without newline characters? Is
there any way to embed newline characters in preseed/late_command
value?

You may be able to do:

   in-target sed -i "$(echo '/<!-- Volume definitions -->/ {\nn\na <volume fstype="cifs" mountpoint="~/earth" path="students/%(USER)" pgrp="users" server="earth.lan" />\n}')" etc/security/pam_mount.conf.xml

also, I don't see why you need to run this in the target chroot, so you
can probably avoid some quoting problems with something like:

   sed -i "$(echo '/<!-- Volume definitions -->/ {\nn\na <volume fstype="cifs" mountpoint="~/earth" path="students/%(USER)" pgrp="users" server="earth.lan" />\n}')" /target/etc/security/pam_mount.conf.xml

or, even, just as you'd normally do it, with the embedded newlines
(which you were presumably avoiding because of the in-target, which you
don't need as it turns out)

Thank you very much Philip, good point that in-target isn't required. But how do you put embedded newline characters in preseed/late_command value? My experiments with something like the following, in preseed.cfg, failed to work:

> d-i preseed/late_command string sed -i '/<!-- Volume definitions -->/ { n\n a <volume fstype="cifs" mountpoint="~/earth" path="students/%(USER)" pgrp="users" server="earth.lan" />\n }' target/etc/security/pam_mount.conf.xml


Reply to: