我想在 SSH 上制作一个很酷的横幅/motd 显示,我已经完成了一部分。我决定用 Python 制作“横幅”部分,因为我有使用“colorama”库(颜色文本)的经验。当我运行时,run-parts /etc/update-motd.d/
它会显示颜色,但当我登录时,它只是纯白色,没有添加任何颜色。
我希望在 SSH 登录时显示时应用颜色。
附言:我是社区的新人,请批评我:D
横幅.py
from colorama import init
from colorama import Fore
init()
print(Fore.YELLOW + ''' __ ___ _ _ ''' + Fore.WHITE + ''' _____ _ _ ''')
print(Fore.YELLOW + ''' \ \ / (_) | | | |''' + Fore.WHITE + ''' / ____| | | | ''')
print(Fore.YELLOW + ''' \ \ / / _ _ __| |_ _ _ __ _| |''' + Fore.WHITE + ''' | (___ | |_ __ _ ___| | __ ''')
print(Fore.YELLOW + ''' \ \/ / | | '__| __| | | |/ _` | |''' + Fore.WHITE + ''' \___ \| __/ _` |/ __| |/ / ''')
print(Fore.YELLOW + ''' \ / | | | | |_| |_| | (_| | |''' + Fore.WHITE + ''' ____) | || (_| | (__| < ''')
print(Fore.YELLOW + ''' \/ |_|_| \__|\__,_|\__,_|_|''' + Fore.WHITE + ''' |_____/ \__\__,_|\___|_|\_\ ''')
00-标题-/etc/update.motd.d 中的文件 - Python 应该在其中执行
#!/bin/sh
[ -r /etc/lsb-release ] && . /etc/lsb-release
if [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then
# Fall back to using the very slow lsb_release utility
DISTRIB_DESCRIPTION=$(lsb_release -s -d)
fi
python3 /etc/update-motd.d/banner.py
printf "\nRunning %s (%s %s %s)\n" "$DISTRIB_DESCRIPTION" "$(uname -o)" "$(uname -r)" "$(uname -m)"