Debian安装完成后运行脚本



我正在使用预设来自动安装debian
我希望能够运行一个名为";run.sh";在Debian安装结束时:

#!/bin/bash
touch /root/example.txt
echo $(hostname -I | cut -d"." -f 4) > /root/example.txt

我已经尝试了我在谷歌上找到的几个模型(我将这些命令添加到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";已损坏

我刚刚看到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;

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

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

最新更新