54 lines
1.2 KiB
Python
54 lines
1.2 KiB
Python
#!/usr/bin/env python3
|
|
|
|
# Generate a colorful "Message Of The Day" using ANSII colors
|
|
# /etc/motd
|
|
# Get ASCII art at https://patorjk.com/software/taag/#p=display&f=Pagga or somewhere else
|
|
|
|
from pathlib import Path
|
|
from random import randint
|
|
|
|
# Config
|
|
DESCRIPTION = "This Is A Debian Server"
|
|
|
|
BG = (36, 36, 36)
|
|
DESC = (18, 117, 130)
|
|
|
|
ASCII_ART = r"""
|
|
░█▀▄░█▀▀░█▀▄░▀█▀░█▀█░█▀█
|
|
░█░█░█▀▀░█▀▄░░█░░█▀█░█░█
|
|
░▀▀░░▀▀▀░▀▀░░▀▀▀░▀░▀░▀░▀
|
|
""".strip()
|
|
|
|
|
|
def fg(r: int, g: int, b: int) -> str:
|
|
return f"\033[38;2;{r};{g};{b}m"
|
|
|
|
|
|
def bg(r: int, g: int, b: int) -> str:
|
|
return f"\033[48;2;{r};{g};{b}m"
|
|
|
|
|
|
RESET = "\033[0m"
|
|
|
|
# Get random RGB colors in the specified range
|
|
ART_FG = fg(
|
|
randint(10, 45), # R
|
|
randint(55, 95), # G
|
|
randint(55, 95), # B
|
|
)
|
|
|
|
ART_BG = bg(*BG)
|
|
DESC_FG = fg(*DESC)
|
|
|
|
motd = "\n".join(
|
|
[
|
|
*(
|
|
f"{ART_FG}{ART_BG} {line} {RESET}"
|
|
for line in ASCII_ART.splitlines()
|
|
),
|
|
f"{DESC_FG}{DESCRIPTION}{RESET}",
|
|
"",
|
|
]
|
|
)
|
|
|
|
Path("/etc/motd").write_text(motd) |