Linux 在不记录的情况下向连接的显示器显示消息

标签 linux user-interface x11

您好,我正在尝试保护我构建的 Linux 计算机。 我想防止人们克隆硬盘驱动器。 我有一个脚本,在启动时与 init 一起运行,并且每 1 小时运行一次。

脚本是这样的。它有硬编码的硬盘驱动器序列号、主板序列号和一些其他序列号。脚本根据硬编码序列检查硬盘驱动器和母驱动器的编号序列。如果不匹配。它向系统发送停止消息,然后系统关闭。

现在我想在停止系统之前在连接的显示器/监视器上显示一条消息。显然,发生这种情况时用户将无法登录。所以我正在寻找一种无需登录即可将消息发送到屏幕的方法。

这是脚本片段。

#!/bin/bash
$coded-hdserial="W4837486938473ASD534354"
$coded-mbserial="XFD6345-32423-IRJDFJDF-234823729"

$check-hdserial=`smartctl -i /dev/sda | grep "Serial Number" | awk -F ":" {'print $2'} |  sed -e 's/^[ \t]*//'`
$check-mbserial=`lshw | grep -A 15 "*-core" | grep "serial:" | awk -F ":" {'print $2'} |sed -e 's/^[ \t]*//' | tr -d '.'`

if 
$coded-hdserial == $check-hdserial
then
echo "OK" >/dev/null 2>&1
else
echo "This copy of the software cannot be validated, it may be is a counterfeit. Therefore you cannot continue to enjoy the privilege to use this software. Please contact the support for further information. 

This system will now be shut down. Further attempts to make counterfeit or duplicate copies of this system will initiate the self destruction and you will loose all data."
halt in 1 minute
fi

if 
$coded-mbserial == $check-mbserial
then
echo "OK" >/dev/null 2>&1
else
echo "This copy of the software cannot be validated, it may be is a counterfeit. Therefore you cannot continue to enjoy the privilege to use this software. Please contact the support for further information. 

This system will now be shut down. Further attempts to make counterfeit or duplicate copies of this system will initiate the self destruction and you will loose all data."
halt in 1 minute
fi

我的问题是如何向连接的显示器显示一条漂亮的警告消息。或者可能是屏幕上显示带有警告的 JPG 图像。

最佳答案

查看内核对帧缓冲区设备的支持,您可以将原始像素数据(例如位图图像文件中的原始像素数据)转储到该设备。这就是 GRand Unified Bootloader (GRUB) 创建图形启动菜单的方式。不需要 X,但您不会获得实际的对话框窗口。如果您想要一个轻量级的 ASCII 艺术交互式菜单系统,请查看像 ncurses 这样的 Curses 实现。

关于Linux 在不记录的情况下向连接的显示器显示消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32407914/

相关文章:

python-3.x - Python - 无法使用 Menu.quit 从 Tkinter 退出

python - Pyplot "cannot connect to X server localhost:10.0"尽管 ioff() 和 matplotlib.use ('Agg' )

x11 - 如何通过 Xlib 观察连接显示器的变化?

mysql - 用于 MySQL 数据(非结构)的 Linux diff 和 patch 命令行实用程序

linux - Ansible - 如何在 lineinfile 模块中使用三元函数?

android - 是否可以在 Android 上构建类似 WebOS 的 UI 应用程序

java - JInternalFrame 置于前面并聚焦

python - 如何使用 Python 在 LINUX 上识别 USB 调制解调器/开发

java - 在 Linux 中使用 java 通过 java.io.File 导入创建文件?

multithreading - XInitThreads() 的缺点是什么?