大网数据广告活动
服务器运维问答

Passing variables to use in the preseed file for a Debian Jessie installation

· 52CE 我爱测

Is it possible to add a variable via the boot prompt to the Debian installer, so that variable can be used in a preseed file? In particular, I'm trying to solve the following problem: We have a pretty extensive post-install scrip…

问题原文

原帖链接 · Tim Stoop · CC BY-SA 3.0

Is it possible to add a variable via the boot prompt to the Debian installer, so that variable can be used in a preseed file?

In particular, I'm trying to solve the following problem:

We have a pretty extensive post-install script that is generally downloaded from a server. But now I want to create Packer images and keep the post-install script in version control together with the other Packer files. For accessing the preseed, I can do "preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg" in the boot command. But now I want the installer to download the post-install script from that same location.

Currently, the post-install hook looks like this:

d-i preseed/late_command string wget -q -O /tmp/postinstall.sh http://our.public.server/postinstall.jessie.sh ; sh /tmp/postinstall.sh

Ideally, I'd like to do something like:

d-i preseed/late_command string wget -q -O /tmp/postinstall.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/postinstall.jessie.sh ; sh /tmp/postinstall.sh

But of course the Debian installer will not replace those with the required values. So I was thinking that it might be possible to pass environment variable-like variables to the installer that we can use in the preseed file.

Any hints or tips are appreciated!

EDIT: Tried adding the late_command to the boot command, but that didn't get picked up.

EDIT: Tried preseed/run, but it runs in a different environment which does not allow the in-target command.

EDIT: This can be a workaround: How do I pipe commands together in a debian preseed file? But I'd prefer to have the script in a separate file. If it's not possible, it's not possible, though.

已采纳解答

原帖链接 · Tim Stoop · CC BY-SA 3.0

Ok, I solved it myself (with some help from @lieter_). Not too proud of it, but it works:

d-i preseed/late_command string wget -q -O /tmp/postinstall.sh http://`cat /proc/cmdline | sed 's/.*url=\([^ ]\+\).*/\1/'`/d-i/jessie/postinstall.sh ; sh /tmp/postinstall.sh

This does what I need, since we always add a url= to our command line when installing.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2015-10-28)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。