0

We usually use a custom script to setup new FreeBSD machines after system installation, which installs tools from ports tree and sets up system environment. we also need to automate update newly installed FreeBSD-8.2 machines to FreeBSD-8.2p3 by freebsd-update. As I know, freebsd-update doesn't allow me to execute it from a shell script without a "cron" option. So I try to preload a custom program to cheat freebsd-update:

${CAT} > /tmp/isatty.c     <<EOF                                                                                                                                                                                         
int isatty(const int fd) { return 1; }                                                                                                                                                                               
EOF                                                                                                                                                                                                                  
${CC} -shared -fPIC -o /tmp/isatty.so     /tmp/isatty.c                                                                                                                                                                          
${ENV} LD_PRELOAD=/tmp/isatty.so LESS="-E" ${FREEBSD_UPDATE} fetch install < /dev/null   

with this tweak, I can sucessfully run freebsd-update from my custom script, but after the freebsd-installer fetched files from update server, I got this error message:

Fetching metadata signature for 8.3-RELEASE from update5.FreeBSD.org... done.
Fetching metadata index... done.
Fetching 2 metadata files... gunzip: standard input is a terminal -- ignoring
metadata is corrupt.

Do I have any chance to solve this?

vyegorov
  • 21,787
  • 7
  • 59
  • 73
  • Not sure if this is possible on FreeBSD or if it would actually help, but on Linux you could try redirecting the script's input from `/dev/tty` – Michał Kosmulski May 10 '12 at 18:11

2 Answers2

0

You set up your LD_PRELOAD which will also be picked up by any and all processes that freebsd-update spawns. The better solution would be to create a modified version of freebsd-update that would allow you to run it from the command line without requiring user interaction.

X-Istence
  • 16,324
  • 6
  • 57
  • 74
0

This utility may be what you need: empty - run processes and applications under pseudo-terminal (PTY)

This way you should be able start freebsd-update from script.

ArtemB
  • 3,496
  • 17
  • 18