【发布时间】:2021-07-14 10:56:12
【问题描述】:
我正在使用 preseed 来自动安装 debian。
我希望能够在 Debian 安装结束时运行一个名为“run.sh”的脚本:
#!/bin/bash
touch /root/example.txt
echo $(hostname -I | cut -d"." -f 4) > /root/example.txt
我尝试了几个我通过 google 找到的模型(我将这些命令添加到 preseed.cfg):
d-i late_command string cp -a /cdrom/preseed/run.sh /target/root; chmod 777 /root/run.sh; /root/run.sh;
d-i preseed/late_command string \
in-target cp run.sh /root/ && in-target chmod 755 /root/run.sh \
cd /target; \
chmod +x ./run.sh; \
chroot ./ ./run.sh;
我已经尝试了我所看到的一切并且我想到了,在任何情况下我都没有成功。我所取得的最大成就是一个红屏,并显示文件“run.sh”已损坏
I just saw a similar question from 2015
更新:
这些命令有效
d-i preseed/late_command string mkdir -p /target/root/one
d-i preseed/late_command string cp /cdrom/files/jitsi/run.sh /target/root/; chmod +x /target/root/run.sh;
【问题讨论】:
-
我之前没有尝试过类似的东西,所以无法验证我的假设是否正确;但对我来说,
in-target cp run.sh /root/毫无意义,因为它假定 run.sh 已经存在于目标环境中的某个地方。你试过cp run.sh /target/root/和chmod 755 /target/root/run.sh(没有in-target)吗? -
理论上应该和
d-i late_command string cp -a /cdrom/preseed/run.sh /target/root一样,是的,我试过了。在 Ubuntu 上可以,但在 Debian 上不行
标签: linux bash ubuntu installation debian