support reading hostname from file

also tolerate not finding the hostname (fill localhost)

address #428
This commit is contained in:
Jaromil 2021-11-30 13:05:02 +01:00
parent 41a7d92ce5
commit 7ef9499160

8
tomb
View File

@ -2389,7 +2389,13 @@ mount_tomb() {
_update_control_file "${tombmount}/.uid" $_UID
_update_control_file "${tombmount}/.tty" $_TTY
# also the hostname
_update_control_file "${tombmount}/.host" `hostname`
if command -v hostname >/dev/null; then
_update_control_file "${tombmount}/.host" `hostname`
elif [[ -r /etc/hostname ]]; then
_update_control_file "${tombmount}/.host" $(_cat /etc/hostname)
else
_update_control_file "${tombmount}/.host" localhost
fi
# and the "last time opened" information
# in minutes since 1970, this is printed at next open
_update_control_file "${tombmount}/.last" `date +%s`