nano /etc/network/if-up.d/update_loginscreen;
chmod +x /etc/network/if-up.d/update_loginscreen;
#!/usr/bin/perl
use strict;
use warnings;
# Disable default proxmox banner
system("systemctl disable pvebanner.service");
system("rm /etc/issue");
system("clear");
my @network_interface_array = &sub_get_interfaces();
my @pveinfo_array = &sub_get_pveversion();
# Set Colors
my $black = "\033[0;30m";
my $gray_dark = "\033[1;30m";
my $red = "\033[0;31m";
my $red_light = "\033[1;31m";
my $green = "\033[0;32m";
my $green_light = "\033[1;32m";
my $brown = "\033[0;33m";
my $yellow = "\033[1;33m";
my $blue = "\033[0;34m";
my $blue_light = "\033[1;34m";
my $purple = "\033[0;35m";
my $light_purple = "\033[1;35m";
my $cyan = "\033[0;36m";
my $cyan_light = "\033[1;36m";
my $white2 = "\033[1;40m";
my $white = "\033[1;37m";
my $nocolor = "\033[0m";
# Configue Line
my $color_line = sprintf("%s%s%s", $yellow, "_" x 78, $nocolor);
# Create Banner
my $proxmox_logo = "";
$proxmox_logo = sprintf("%s %s██████╗ %s██████╗ %s ██████╗ %s██╗ ██╗%s███╗ ███╗%s ██████╗ %s██╗ ██╗%s\n",$proxmox_logo, $white,$white,$white,$brown,$white,$white,$brown,$nocolor);
$proxmox_logo = sprintf("%s %s██╔══██╗%s██╔══██╗%s██╔═══██╗%s╚██╗██╔╝%s████╗ ████║%s██╔═══██╗%s╚██╗██╔╝%s\n",$proxmox_logo, $white,$white,$white,$brown,$white,$white,$brown,$nocolor);
$proxmox_logo = sprintf("%s %s██████╔╝%s██████╔╝%s██║ ██║%s ╚███╔╝ %s██╔████╔██║%s██║ ██║%s ╚███╔╝ %s\n",$proxmox_logo, $white,$white,$white,$brown,$white,$white,$brown,$nocolor);
$proxmox_logo = sprintf("%s %s██╔═══╝ %s██╔══██╗%s██║ ██║%s ██╔██╗ %s██║╚██╔╝██║%s██║ ██║%s ██╔██╗ %s\n",$proxmox_logo, $white,$white,$white,$brown,$white,$white,$brown,$nocolor);
$proxmox_logo = sprintf("%s %s██║ %s██║ ██║%s╚██████╔╝%s██╔╝ ██╗%s██║ ╚═╝ ██║%s╚██████╔╝%s██╔╝ ██╗%s\n",$proxmox_logo, $white,$white,$white,$brown,$white,$white,$brown,$nocolor);
$proxmox_logo = sprintf("%s %s╚═╝ %s╚═╝ ╚═╝%s ╚═════╝ %s╚═╝ ╚═╝%s╚═╝ ╚═╝%s ╚═════╝ %s╚═╝ ╚═╝%s\n",$proxmox_logo, $white,$white,$white,$brown,$white,$white,$brown,$nocolor);
# Create Message String
my $message = sprintf("%s\n\n%s%s\n",$color_line,$proxmox_logo,$color_line);
# Print PVE Infos
if (@pveinfo_array) {
$message = sprintf("%s%s Version:%s %s%s%-5s%s %sBuild:%s %s%s%-5s%s %sKernel:%s %s%s%-5s%s\n\n", $message, $brown, $nocolor, $blue_light, $pveinfo_array[0], "", $nocolor, $brown, $nocolor, $blue_light, $pveinfo_array[1], "", $nocolor, $brown, $nocolor, $blue_light, $pveinfo_array[2], "", $nocolor);
}
$message = sprintf ("%s%s Welcome to the Proxmox Virtual Environment Server%s\n", $message, $brown, $nocolor);
# Print Network Infos
if (@network_interface_array) {
$message = sprintf("%s%s Please use your web browser to configure this server - connect to:%s\n\n", $message, $brown, $nocolor);
for ( my $i=0; $i < @network_interface_array; $i+=2) {
$message = sprintf("%s%s [%s] %shttps://%s%s%s%s:8006%s\n",$message, $cyan, $network_interface_array[$i], $green_light, $red_light, $network_interface_array[$i+1],$nocolor, $green_light, $nocolor)
}
}
else {
$message = sprintf("%s%s WARNING: No Network Connection found !!!%s\n", $message, $red, $nocolor);
}
$message = sprintf("%s\n", $message);
# Write Message to Console for Test
print ($message);
# Write to Issue File
my $filenamepath = "/etc/issue";
if (open (FILE_HANDLE,">$filenamepath")) {
printf (FILE_HANDLE "%s", $message);
close (FILE_HANDLE);
}
else {
printf ("[ERROR] in %s:%s -\> can not open file \"%s\" !!!\n", __FILE__, __LINE__, $filenamepath);
}
exit (0);
#########################################################################################################
# SubRoutines
#########################################################################################################
sub sub_get_pveversion {
my @pveversion;
my $cmd_out = &sub_get_cmd_output("pveversion");
if ((defined $cmd_out) && ($cmd_out =~ /pve-manager\/(.*?)\/(.*?)\s\(running kernel:\s(.*?)\)/)) {
push (@pveversion,$1); # 7.4-3
push (@pveversion,$2); # 9002ab8a
push (@pveversion,$3); # 5.15.107-2-pve
}
return(@pveversion);
}
sub sub_get_interfaces {
my @network_interface_ip_array;
my $cmd_out = &sub_get_cmd_output("ip -o l");
if ((defined $cmd_out) && ($cmd_out =~ /[\d].*?:\s([\w\d]*)?:/)) {
my (@network_interface_array) = $cmd_out =~ /[\d].*?:\s([\w\d]*)?:/g;
foreach my $network_interface (sort @network_interface_array) {
if ((defined $network_interface) && ($network_interface ne "lo")) {
my $ip = &get_interface_address($network_interface);
if ($ip) {
push (@network_interface_ip_array,$network_interface);
push (@network_interface_ip_array,$ip);
}
}
}
}
return(@network_interface_ip_array);
}
sub get_interface_address {
my $iface = $_[0];
my $ReturnValue = 0;
if (defined $iface) {
my $cmd = sprintf("ip -4 addr show dev %s", $iface);
my $cmd_out = &sub_get_cmd_output($cmd);
if ((defined $cmd_out) && ($cmd_out =~ /inet\s((?:(?:25[0-5]|(?:2[0-4]|1\d|[1-9]|)\d)\.?\b){4})\/[\d]{2}/)) {
$ReturnValue = $1;
}
}
return($ReturnValue);
}
sub sub_get_cmd_output {
my $command = $_[0];
my $command_out = "";
if (defined $command) {
open (CMD_HANDLE, "${command} 2>nul|");
undef $/;
$command_out = <CMD_HANDLE>;
$/="\n";
close (CMD_HANDLE);
}
return($command_out);
}
Hi, how can I apply this to my instance? Do I copy the code & make a new file with Nano, then run the Bash commands? Any clarification is appreciated. Thanks!Hi, i create today my own welcome script.
It reads the current IPs and other Infos with RegEx
View attachment 50410
Bash:nano /etc/network/if-up.d/update_loginscreen; chmod +x /etc/network/if-up.d/update_loginscreen;
Perl:#!/usr/bin/perl use strict; use warnings; # Disable default proxmox banner system("systemctl disable pvebanner.service"); system("rm /etc/issue"); system("clear"); my @network_interface_array = &sub_get_interfaces(); my @pveinfo_array = &sub_get_pveversion(); # Set Colors my $black = "\033[0;30m"; my $gray_dark = "\033[1;30m"; my $red = "\033[0;31m"; my $red_light = "\033[1;31m"; my $green = "\033[0;32m"; my $green_light = "\033[1;32m"; my $brown = "\033[0;33m"; my $yellow = "\033[1;33m"; my $blue = "\033[0;34m"; my $blue_light = "\033[1;34m"; my $purple = "\033[0;35m"; my $light_purple = "\033[1;35m"; my $cyan = "\033[0;36m"; my $cyan_light = "\033[1;36m"; my $white2 = "\033[1;40m"; my $white = "\033[1;37m"; my $nocolor = "\033[0m"; # Configue Line my $color_line = sprintf("%s%s%s", $yellow, "_" x 78, $nocolor); # Create Banner my $proxmox_logo = ""; $proxmox_logo = sprintf("%s %s██████╗ %s██████╗ %s ██████╗ %s██╗ ██╗%s███╗ ███╗%s ██████╗ %s██╗ ██╗%s\n",$proxmox_logo, $white,$white,$white,$brown,$white,$white,$brown,$nocolor); $proxmox_logo = sprintf("%s %s██╔══██╗%s██╔══██╗%s██╔═══██╗%s╚██╗██╔╝%s████╗ ████║%s██╔═══██╗%s╚██╗██╔╝%s\n",$proxmox_logo, $white,$white,$white,$brown,$white,$white,$brown,$nocolor); $proxmox_logo = sprintf("%s %s██████╔╝%s██████╔╝%s██║ ██║%s ╚███╔╝ %s██╔████╔██║%s██║ ██║%s ╚███╔╝ %s\n",$proxmox_logo, $white,$white,$white,$brown,$white,$white,$brown,$nocolor); $proxmox_logo = sprintf("%s %s██╔═══╝ %s██╔══██╗%s██║ ██║%s ██╔██╗ %s██║╚██╔╝██║%s██║ ██║%s ██╔██╗ %s\n",$proxmox_logo, $white,$white,$white,$brown,$white,$white,$brown,$nocolor); $proxmox_logo = sprintf("%s %s██║ %s██║ ██║%s╚██████╔╝%s██╔╝ ██╗%s██║ ╚═╝ ██║%s╚██████╔╝%s██╔╝ ██╗%s\n",$proxmox_logo, $white,$white,$white,$brown,$white,$white,$brown,$nocolor); $proxmox_logo = sprintf("%s %s╚═╝ %s╚═╝ ╚═╝%s ╚═════╝ %s╚═╝ ╚═╝%s╚═╝ ╚═╝%s ╚═════╝ %s╚═╝ ╚═╝%s\n",$proxmox_logo, $white,$white,$white,$brown,$white,$white,$brown,$nocolor); # Create Message String my $message = sprintf("%s\n\n%s%s\n",$color_line,$proxmox_logo,$color_line); # Print PVE Infos if (@pveinfo_array) { $message = sprintf("%s%s Version:%s %s%s%-5s%s %sBuild:%s %s%s%-5s%s %sKernel:%s %s%s%-5s%s\n\n", $message, $brown, $nocolor, $blue_light, $pveinfo_array[0], "", $nocolor, $brown, $nocolor, $blue_light, $pveinfo_array[1], "", $nocolor, $brown, $nocolor, $blue_light, $pveinfo_array[2], "", $nocolor); } $message = sprintf ("%s%s Welcome to the Proxmox Virtual Environment Server%s\n", $message, $brown, $nocolor); # Print Network Infos if (@network_interface_array) { $message = sprintf("%s%s Please use your web browser to configure this server - connect to:%s\n\n", $message, $brown, $nocolor); for ( my $i=0; $i < @network_interface_array; $i+=2) { $message = sprintf("%s%s [%s] %shttps://%s%s%s%s:8006%s\n",$message, $cyan, $network_interface_array[$i], $green_light, $red_light, $network_interface_array[$i+1],$nocolor, $green_light, $nocolor) } } else { $message = sprintf("%s%s WARNING: No Network Connection found !!!%s\n", $message, $red, $nocolor); } $message = sprintf("%s\n", $message); # Write Message to Console for Test print ($message); # Write to Issue File my $filenamepath = "/etc/issue"; if (open (FILE_HANDLE,">$filenamepath")) { printf (FILE_HANDLE "%s", $message); close (FILE_HANDLE); } else { printf ("[ERROR] in %s:%s -\> can not open file \"%s\" !!!\n", __FILE__, __LINE__, $filenamepath); } exit (0); ######################################################################################################### # SubRoutines ######################################################################################################### sub sub_get_pveversion { my @pveversion; my $cmd_out = &sub_get_cmd_output("pveversion"); if ((defined $cmd_out) && ($cmd_out =~ /pve-manager\/(.*?)\/(.*?)\s\(running kernel:\s(.*?)\)/)) { push (@pveversion,$1); # 7.4-3 push (@pveversion,$2); # 9002ab8a push (@pveversion,$3); # 5.15.107-2-pve } return(@pveversion); } sub sub_get_interfaces { my @network_interface_ip_array; my $cmd_out = &sub_get_cmd_output("ip -o l"); if ((defined $cmd_out) && ($cmd_out =~ /[\d].*?:\s([\w\d]*)?:/)) { my (@network_interface_array) = $cmd_out =~ /[\d].*?:\s([\w\d]*)?:/g; foreach my $network_interface (sort @network_interface_array) { if ((defined $network_interface) && ($network_interface ne "lo")) { my $ip = &get_interface_address($network_interface); if ($ip) { push (@network_interface_ip_array,$network_interface); push (@network_interface_ip_array,$ip); } } } } return(@network_interface_ip_array); } sub get_interface_address { my $iface = $_[0]; my $ReturnValue = 0; if (defined $iface) { my $cmd = sprintf("ip -4 addr show dev %s", $iface); my $cmd_out = &sub_get_cmd_output($cmd); if ((defined $cmd_out) && ($cmd_out =~ /inet\s((?:(?:25[0-5]|(?:2[0-4]|1\d|[1-9]|)\d)\.?\b){4})\/[\d]{2}/)) { $ReturnValue = $1; } } return($ReturnValue); } sub sub_get_cmd_output { my $command = $_[0]; my $command_out = ""; if (defined $command) { open (CMD_HANDLE, "${command} 2>nul|"); undef $/; $command_out = <CMD_HANDLE>; $/="\n"; close (CMD_HANDLE); } return($command_out); }
# do not run non-interactively
[ -z "$PS1" ] && return
# do not run in non-bash
[ -z "$BASH" ] && return
# do not run in tmux
[ ! -z "$TMUX" ] && return
# check if we are inside SSH or on a real tty
TTY=$(tty)
if [ ! -z "$SSH_TTY" ] || [[ ${TTY##*/} == "tty"[0-9]+$ ]]
then
echo "superduper output"
fi
Hi, how can I apply this to my instance? Do I copy the code & make a new file with Nano, then run the Bash commands? Any clarification is appreciated. Thanks!
Edit: I am running PVE 8.2.2 for reference.
mkdir /opt/scripts;
sh -c 'echo "" > /opt/scripts/update_loginscreen.pl';
chmod +x /opt/scripts/update_loginscreen.pl;
ln -s /opt/scripts/update_loginscreen.pl /etc/network/if-up.d/update_loginscreen;
nano /opt/scripts/update_loginscreen.pl;
#!/usr/bin/perl
use strict;
use warnings;
# Disable default proxmox banner
system("systemctl disable pvebanner.service");
system("rm /etc/issue");
system("clear");
my @network_interface_array = &sub_get_interfaces();
my @pveinfo_array = &sub_get_pveversion();
# Set Colors
my $black = "\033[0;30m";
my $gray_dark = "\033[1;30m";
my $red = "\033[0;31m";
my $red_light = "\033[1;31m";
my $green = "\033[0;32m";
my $green_light = "\033[1;32m";
my $brown = "\033[0;33m";
my $yellow = "\033[1;33m";
my $blue = "\033[0;34m";
my $blue_light = "\033[1;34m";
my $purple = "\033[0;35m";
my $light_purple = "\033[1;35m";
my $cyan = "\033[0;36m";
my $cyan_light = "\033[1;36m";
my $white2 = "\033[1;40m";
my $white = "\033[1;37m";
my $nocolor = "\033[0m";
# Configue Line
my $color_line = sprintf("%s%s%s", $yellow, "_" x 78, $nocolor);
# Create Banner
my $proxmox_logo = "";
$proxmox_logo = sprintf("%s %s██████╗ %s██████╗ %s ██████╗ %s██╗ ██╗%s███╗ ███╗%s ██████╗ %s██╗ ██╗%s\n",$proxmox_logo, $white,$white,$white,$brown,$white,$white,$brown,$nocolor);
$proxmox_logo = sprintf("%s %s██╔══██╗%s██╔══██╗%s██╔═══██╗%s╚██╗██╔╝%s████╗ ████║%s██╔═══██╗%s╚██╗██╔╝%s\n",$proxmox_logo, $white,$white,$white,$brown,$white,$white,$brown,$nocolor);
$proxmox_logo = sprintf("%s %s██████╔╝%s██████╔╝%s██║ ██║%s ╚███╔╝ %s██╔████╔██║%s██║ ██║%s ╚███╔╝ %s\n",$proxmox_logo, $white,$white,$white,$brown,$white,$white,$brown,$nocolor);
$proxmox_logo = sprintf("%s %s██╔═══╝ %s██╔══██╗%s██║ ██║%s ██╔██╗ %s██║╚██╔╝██║%s██║ ██║%s ██╔██╗ %s\n",$proxmox_logo, $white,$white,$white,$brown,$white,$white,$brown,$nocolor);
$proxmox_logo = sprintf("%s %s██║ %s██║ ██║%s╚██████╔╝%s██╔╝ ██╗%s██║ ╚═╝ ██║%s╚██████╔╝%s██╔╝ ██╗%s\n",$proxmox_logo, $white,$white,$white,$brown,$white,$white,$brown,$nocolor);
$proxmox_logo = sprintf("%s %s╚═╝ %s╚═╝ ╚═╝%s ╚═════╝ %s╚═╝ ╚═╝%s╚═╝ ╚═╝%s ╚═════╝ %s╚═╝ ╚═╝%s\n",$proxmox_logo, $white,$white,$white,$brown,$white,$white,$brown,$nocolor);
# Create Message String
my $message = sprintf("%s\n\n%s%s\n",$color_line,$proxmox_logo,$color_line);
# Print PVE Infos
if (@pveinfo_array) {
$message = sprintf("%s%s Version:%s %s%s%-5s%s %sBuild:%s %s%s%-5s%s %sKernel:%s %s%s%-5s%s\n\n", $message, $brown, $nocolor, $blue_light, $pveinfo_array[0], "", $nocolor, $brown, $nocolor, $blue_light, $pveinfo_array[1], "", $nocolor, $brown, $nocolor, $blue_light, $pveinfo_array[2], "", $nocolor);
}
$message = sprintf ("%s%s Welcome to the Proxmox Virtual Environment Server%s\n", $message, $brown, $nocolor);
# Print Network Infos
if (@network_interface_array) {
$message = sprintf("%s%s Please use your web browser to configure this server - connect to:%s\n\n", $message, $brown, $nocolor);
for ( my $i=0; $i < @network_interface_array; $i+=2) {
$message = sprintf("%s%s [%s] %shttps://%s%s%s%s:8006%s\n",$message, $cyan, $network_interface_array[$i], $green_light, $red_light, $network_interface_array[$i+1],$nocolor, $green_light, $nocolor)
}
}
else {
$message = sprintf("%s%s WARNING: No Network Connection found !!!%s\n", $message, $red, $nocolor);
}
$message = sprintf("%s\n", $message);
# Write Message to Console for Test
print ($message);
# Write to Issue File
my $filenamepath = "/etc/issue";
if (open (FILE_HANDLE,">$filenamepath")) {
printf (FILE_HANDLE "%s", $message);
close (FILE_HANDLE);
}
else {
printf ("[ERROR] in %s:%s -\> can not open file \"%s\" !!!\n", __FILE__, __LINE__, $filenamepath);
}
exit (0);
#########################################################################################################
# SubRoutines
#########################################################################################################
sub sub_get_pveversion {
my @pveversion;
my $cmd_out = &sub_get_cmd_output("pveversion");
if ((defined $cmd_out) && ($cmd_out =~ /pve-manager\/(.*?)\/(.*?)\s\(running kernel:\s(.*?)\)/)) {
push (@pveversion,$1); # 7.4-3
push (@pveversion,$2); # 9002ab8a
push (@pveversion,$3); # 5.15.107-2-pve
}
return(@pveversion);
}
sub sub_get_interfaces {
my @network_interface_ip_array;
my $cmd_out = &sub_get_cmd_output("ip -o l");
if ((defined $cmd_out) && ($cmd_out =~ /[\d].*?:\s([\w\d]*)?:/)) {
my (@network_interface_array) = $cmd_out =~ /[\d].*?:\s([\w\d]*)?:/g;
foreach my $network_interface (sort @network_interface_array) {
if ((defined $network_interface) && ($network_interface ne "lo")) {
my $ip = &get_interface_address($network_interface);
if ($ip) {
push (@network_interface_ip_array,$network_interface);
push (@network_interface_ip_array,$ip);
}
}
}
}
return(@network_interface_ip_array);
}
sub get_interface_address {
my $iface = $_[0];
my $ReturnValue = 0;
if (defined $iface) {
my $cmd = sprintf("ip -4 addr show dev %s", $iface);
my $cmd_out = &sub_get_cmd_output($cmd);
if ((defined $cmd_out) && ($cmd_out =~ /inet\s((?:(?:25[0-5]|(?:2[0-4]|1\d|[1-9]|)\d)\.?\b){4})\/[\d]{2}/)) {
$ReturnValue = $1;
}
}
return($ReturnValue);
}
sub sub_get_cmd_output {
my $command = $_[0];
my $command_out = "";
if (defined $command) {
open (CMD_HANDLE, "${command} 2>nul|");
undef $/;
$command_out = <CMD_HANDLE>;
$/="\n";
close (CMD_HANDLE);
}
return($command_out);
}
Just install a post-apt or post-dpkg hook to fix it right after each update.The problem is that everytime Proxmox update pvebanner will be overwritten. I haven't found a good solution for this yet.
Try this for your own logo : https://fsymbols.com/generators/tarty/I really like your text logo ... can you provide a version that actually shows the product name? It's Proxmox VE, not just Proxmox, which is the company name. I tried to regenerate the text logo, yet I cannot find a figlet font to do so.
However, there is still this line that appears:
Linux pve 6.8.4-2-pve #1 SMP PREEMPT_DYNAMIC PMX 6.8.4-2 (2024-04-10T17:36Z) x86_64
It seems to be a "uname -a" output, but I can't find a way to remove it.
Do you know how to do this ?
touch $HOME/.hushlogin