]> git.proxmox.com Git - pmg-api.git/blame - src/bin/pmgbanner
pmgbanner: don't die if getting addr fails but running in container
[pmg-api.git] / src / bin / pmgbanner
CommitLineData
1635608e
DM
1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use PVE::INotify;
b468a858 7use PVE::Tools;
1635608e
DM
8use PMG::Cluster;
9
b468a858
TL
10sub detect_container {
11
12 my $ct;
13 if (-f '/run/systemd/container') {
14 $ct = PVE::Tools::file_read_firstline('/run/systemd/container');
15 }
16 return $ct;
17}
18
1635608e 19my $nodename = PVE::INotify::nodename();
b468a858
TL
20my $localip = eval { PMG::Cluster::remote_node_ip($nodename, 1) };
21if (my $err = $@) { # FIXME: HACK: cope better with managed CTs and DHCP
22 my $in_ct = detect_container();
23 die $err if !$in_ct;
24 warn "ignore failure to get local IP of $nodename, we're in a container ($in_ct)\n";
25 $localip = '<uknown>';
26}
1635608e
DM
27
28my $xline = '-' x 78;
29
30my $banner = '';
31
32if ($localip) {
33 $banner .= <<__EOBANNER;
34
35$xline
36
37Welcome to the Proxmox Mail Gateway. Please use your web browser to
38configure this server - connect to:
39
40 https://${localip}:8006/
41
42$xline
43
44__EOBANNER
45
46}
47
48open(ISSUE, ">/etc/issue");
49
50print ISSUE $banner;
51
52close(ISSUE);
53
54exit (0);