5

I would like to know if it is possible to pipe commands together in a preseed file.

Something Like:

d-i preseed/late_command string yes N | apt-get install package -y

(I realize this is a somewhat bad example. I just wanted to know if/how it would work.)

aseq
  • 4,550
  • 1
  • 22
  • 46
Nick P.
  • 83
  • 1
  • 1
  • 7

2 Answers2

12

I do that at the last stage, these are some examples to give you an idea:

d-i preseed/late_command string \
cd /target/etc/apt/; \
wget http://repo.example.com/sources_new.list; \
mv sources_new.list sources.list; \
echo 'Acquire::http::Proxy "http://proxy.example.org";' >> apt.conf; \
ls . > temp; \
cat temp | grep -cq string; \
cd /; \
in-target apt-get update; \
in-target apt-get -y upgrade; \
in-target apt-get -y dist-upgrade; \
in-target tasksel install desktop; \
in-target apt-get -y install sudo \
less \
ssh \
icedove \
lynx \
xscreensaver;

So the target filesystem by default is located at /target and you can move around and copy and delete files, edit files and if you want to run a command in the target filesystem you use "in-target" before the command.

For more documentation see: http://d-i.alioth.debian.org/manual/en.amd64/apbs05.html#preseed-hooks

aseq
  • 4,550
  • 1
  • 22
  • 46
  • 1
    Sure, but there are no piped commands in your example. "cat file | grep "thing" > newFile" – Nick P. May 17 '12 at 19:27
  • See my answer for an updated example, albeit useless in this case. :-) – aseq May 17 '12 at 19:53
  • 1
    Just for being sure, would this also work dropping multile `d-i preseed/late_command` or is there a specific reason you put everything in one? – pdu Oct 07 '12 at 20:45
  • I think you can not, however since you can string commands together as I showed in my answer this shouldn't be a problem. See also http://us.generation-nt.com/answer/possible-create-more-than-one-preseed-late-command-help-206863512.html – aseq Oct 08 '12 at 20:52
3

You can pass the commands via /bin/sh. This allows you to use pipes. Example:

in-target /bin/sh -c -- 'blkid /dev/sda1 | xargs -n1 | grep "^UUID=" >/tmp/uuid-sda1.txt'
Brad Solomon
  • 105
  • 5