我有一个用于安装服务器的无人值守脚本。在脚本的开头有一个sudo apt-get dist-upgrade --yes. dist 升级的最后有一个令人讨厌的用户输入屏幕,要求重新启动服务:

是否可以自动接受服务重新启动或禁用此屏幕?它破坏了我的整个剧本。另外我担心它可能会让我的服务器在更新时卡在某个时刻......
与 apt-get Upgrade 的结果相同
编辑:我尝试过但没有成功:
#!/bin/bash
sudo apt-get update
sudo apt-get remove apt-listchanges --assume-yes --force-yes &&
#using export is important since some of the commands in the script will fire in a subshell
export DEBIAN_FRONTEND=noninteractive &&
export APT_LISTCHANGES_FRONTEND=none &&
#lib6c was an issue for me as it ignored the DEBIAN_FRONTEND environment variable and fired a prompt anyway. This should fix it
echo 'libc6 libraries/restart-without-asking boolean true' | debconf-set-selections &&
echo "executing …Run Code Online (Sandbox Code Playgroud) 我有一个服务器,里面有不同类型的脚本。
这些脚本将使用不同的 shell 打开,例如:
sh ./do_one_thing.sh
bash ./do_another_thing.sh
Run Code Online (Sandbox Code Playgroud)
该.sh扩展对我来说很危险,特别是如果我很长时间没有连接到服务器的话。或者如果有不熟悉的人需要替身。
我可能会不小心执行sh ./do_another_thing.sh
如果我命名我的脚本会有什么不同吗do_another_thing.bash?这将创造又一层的万无一失。
另外,我想知道开头的 shebang 行除了提醒管理员 ( #!/bin/bash) 之外还有什么用处(如果它被覆盖的sh ./do_another_thing.sh话)。在我看来,必须有一种更合适的方法来执行脚本,识别 shebang。
我写了一个硬盘自动挂载程序。
该软件使用 ssh 向目标计算机发出请求。这个想法是新安装的硬盘会自动添加到 fstab 中。
我已经让一切工作正常,fstab 行实体已准备好附加到文件中。
我试图在我的软件中添加这样的内容:
command.RunCommandSudo($"echo \"{mountstring}\" >> /etc/fstab");
Run Code Online (Sandbox Code Playgroud)
产生以下格式的 ssh 查询:
sudo echo "UUID=X /mnt/test ext4 defaults 0 1" >> /etc/fstab
Run Code Online (Sandbox Code Playgroud)
=> 权限被拒绝
怎样才是合适的方式呢?我怀疑自动化软件的适当方法是通过文本编辑器(例如nano)?
我发现了几个与失败后处于只读模式的文件系统以及如何使它们再次可写相关的问题。我想达到完全相反的效果。
我有 3.5 英寸硬盘,格式化为 ext4,上面有存档文件。
硬盘是内部驱动器,上面是纯数据,没有操作系统。(就像数据备份)
我想使文件系统只读,而不是只读安装或更改文件的权限。
这可能吗?如果可能的话,如何实现?
command-line ×2
apt ×1
bash ×1
ext4 ×1
filesystem ×1
fstab ×1
mount ×1
permissions ×1
read-only ×1
scripts ×1
server ×1
services ×1
ssh ×1
updates ×1
upgrade ×1