首页 > 解决方案 > Ubuntu Preseed 和模板

问题描述

我正在从 Ubuntu 18.04.1 上的预置文件加载和执行这个 bash 文件。安装工作完美,我的 bash 文件已下载并执行,但出现错误。

错误消息:“激活/询问不存在”。我尝试对此进行故障排除并阅读 debconf 开发配置,但无法真正确定我做错了什么。有任何想法吗?谢谢

编辑:如果我在安装和 wget 期间进入 shell,chmod 这个 post.sh 脚本,一切正常。有任何想法吗?

#!/bin/sh

# Library to interact with debconf.
. /usr/share/debconf/confmodule

# Create the template file
cat > /tmp/activate.template <<EOL
Template: activation/title
Type: text
Description: Activate

Template: activation/ask
Type: string
Description: Enter Activation Code
EOL

# Load your template
debconf-loadtemplate activation /tmp/activate.template

# Set title for dialogue box
db_settitle activation/title

# Input activation code
db_input critical activation/ask
db_go

# Fetch input from user
db_get activation/ask

# Save it to a file
echo "$RET" > /root/answer.value

#Error message: activation/ask does not exist

模板已重命名,因此不必担心那里的不匹配。谢谢

错误

标签: bashubuntu-18.04debconf

解决方案


这与脚本的执行方式有关。

d-i preseed/late_command string \
in-target /usr/bin/wget -O /root/post.sh http://<ip>/preseed/post.sh; \
in-target /bin/chmod +x /root/post.sh; \
in-target /bin/bash /root/post.sh

推荐阅读