我运行Linux的卡莉的滚动发布之前完成,并已开始编写由rc.local中启动时执行的脚本,那将是允许用户更新计算机的主机名。可以rc.local中等待bash脚本启动
rc.local中:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
/root/hostnameBoot
exit 0
hostnameBoot脚本:
#!/bin/bash
# /etc/init.d/hostnameBoot
# Solution Added
exec < /dev/tty0
echo "Enter desired hostname:"
read hostname
echo "New hostname: $hostname"
#exit 0
正如你所看到的,目前hostnameBoot提示用户输入一个新的主机名,然后将主机名返回给用户。
一旦启动,rc.local中执行脚本,但不会提示用户输入一个新的主机名。
样引导输出:
- misc boot info -
Enter desired hostname:
New hostname:
样品引导输出显示全部一次,并且不允许用户输入一个新的主机名。一旦显示这些行,系统就会继续登录屏幕。系统的期望行为将允许用户有时间输入新的主机名,然后用先前提交的输入来呈现。
注:该脚本是不是最终产品,它只是一个使用rc.local中来触发脚本概念证明。
这可能是更适合[unix.se。 –