【问题标题】:Run script after Debian installation is completeDebian安装完成后运行脚本
【发布时间】: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


【解决方案1】:

尝试执行时它不起作用的原因肯定是因为没有声明路由。你可以使用这个失败:

d-i preseed/late_command string cp /cdrom/files/jitsi/run.sh /target/root/; chmod +x /target/root/run.sh; in-target /bin/bash /root/run.sh

【讨论】:

    猜你喜欢
    • 2015-05-02
    • 1970-01-01
    • 2016-12-29
    • 1970-01-01
    • 1970-01-01
    • 2011-08-22
    • 1970-01-01
    • 2016-02-06
    • 1970-01-01
    相关资源
    最近更新 更多