]> git.proxmox.com Git - pve-installer.git/commitdiff
switch "mailto" over to central config
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 20 Jun 2023 07:20:32 +0000 (09:20 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 20 Jun 2023 07:20:32 +0000 (09:20 +0200)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Proxmox/Install/Config.pm
proxinstall

index ef85bcbb563342044cf08b6b6192399fb1d1a498..f5a9cda5a43406834d519192e4980f1cbf6581d5 100644 (file)
@@ -36,6 +36,7 @@ my sub init_cfg {
 
        # root credentials & details
        password => undef,
+       mailto => 'mail@example.invalid',
     };
 
     # TODO add disksel$i => undef entries
@@ -139,4 +140,7 @@ sub get_keymap { return get('keymap'); }
 sub set_password { set_key('password', $_[0]); }
 sub get_password { return get('password'); }
 
+sub set_mailto { set_key('mailto', $_[0]); }
+sub get_mailto { return get('mailto'); }
+
 1;
index 798c980132231164ca3bfd9ab8de67074b6b25a6..983528e537581dbf54b2c81271b080a0028214d1 100755 (executable)
@@ -107,14 +107,11 @@ my ($dnsserver, $ipconf_entry_dns);
 my $hostname = 'proxmox';
 my $domain = 'domain.tld';
 my $ipconf;
-my $mailto = 'mail@example.invalid';
 my $autoreboot_seconds = 5;
 
 # TODO: single source of config state
 my $config = {
     # TODO: add all the user-provided options for previous button
-    mailto => $mailto,
-
     mngmt_nic => undef,
     hostname => $hostname,
     fqdn => undef,
@@ -1164,6 +1161,7 @@ _EOD
        my $octets = encode("utf-8", Proxmox::Install::Config::get_password());
        run_command("chroot $targetdir /usr/sbin/chpasswd", undef, "root:$octets\n");
 
+       my $mailto = Proxmox::Install::Config::get_mailto();
        if ($iso_env->{product} eq 'pmg') {
            # save admin email
            file_write_all("$targetdir/etc/pmg/pmg.conf", "section: admin\n\temail ${mailto}\n");
@@ -1695,7 +1693,7 @@ sub create_ack_view {
        __country__ => $iso_env->{locales}->{country}->{$country}->{name},
        __timezone__ => Proxmox::Install::Config::get_timezone(),
        __keymap__ => Proxmox::Install::Config::get_keymap(),
-       __mailto__ => $mailto,
+       __mailto__ => Proxmox::Install::Config::get_mailto(),
        __interface__ => $ipconf->{ifaces}->{$ipconf->{selected}}->{name},
        __hostname__ => $hostname,
        __ip__ => $ipaddress,
@@ -1850,7 +1848,7 @@ sub create_password_view {
     $hbox3->pack_start($label, 0, 0, 10);
     my $eme = Gtk3::Entry->new();
     $eme->set_size_request(200, -1);
-    $eme->set_text($mailto);
+    $eme->set_text(Proxmox::Install::Config::get_mailto());
     $hbox3->pack_start($eme, 0, 0, 0);
 
 
@@ -1881,8 +1879,7 @@ sub create_password_view {
 
        my $t3 = $eme->get_text;
        if ($t3 !~ m/^[\w\+\-\~]+(\.[\w\+\-\~]+)*@[a-zA-Z0-9\-]+(\.[a-zA-Z0-9\-]+)*$/) {
-           Proxmox::UI::message("Email does not look like a valid address" .
-                            " (user\@domain.tld)");
+           Proxmox::UI::message("Email does not look like a valid address (user\@domain.tld)");
            $eme->grab_focus();
            return;
        }
@@ -1894,7 +1891,7 @@ sub create_password_view {
        }
 
        Proxmox::Install::Config::set_password($t1);
-       $mailto = $t3;
+       Proxmox::Install::Config::set_mailto($t3);
 
        $step_number++;
        create_ipconf_view();