2 # Functions for installing packages from the redhat network
4 $up2date_config = "/etc/sysconfig/rhn/up2date";
5 $rhn_sysconfig = "/etc/sysconfig/rhn/rhnsd";
7 sub list_update_system_commands
12 # update_system_install([package])
13 # Install some package with up2date
14 sub update_system_install
16 local $update = $_[0] || $in{'update'};
18 print "<b>",&text('rhn_install', "<tt>up2date $update</tt>"),"</b><p>\n";
20 &additional_log('exec', undef, "up2date \"$update\"");
21 local $qm = quotemeta($update);
22 &open_execute_command(CMD, "up2date $qm", 2);
25 while(s/^[^\015]+\015([^\012])/$1/) { }
26 $got_error++ if (/error|failed/i);
27 if (/installing.*\/([^\/\s]+)\-([^\-]+)\-([^\-]+)\.rpm/i) {
35 print "<b>$text{'rhn_failed'}</b><p>\n";
39 print "<b>$text{'rhn_ok'}</b><p>\n";
44 # update_system_form()
45 # Show a form for configuring the redhat update agent
46 sub update_system_form
48 print &ui_subheading($text{'rhn_form'});
49 print &ui_form_start("rhn_check.cgi");
50 print &ui_table_start($text{'rhn_header'}, undef, 2);
53 &foreign_require("init", "init-lib.pl");
54 local $auto = &init::action_status("rhnsd");
55 print &ui_table_row($text{'rhn_auto'},
56 &ui_yesno_radio("auto", $auto == 2 ? 1 : 0));
60 &read_env_file($rhn_sysconfig, \%rhnsd);
61 print &ui_table_row($text{'rhn_interval'},
62 &ui_textbox("interval", $rhnsd{'INTERVAL'}, 5)." ".$text{'rhn_secs'});
65 local $conf = &read_up2date_config();
66 local $prx = $conf->{'pkgProxy'} ? $conf->{'pkgProxy'}->{'value'}
67 : $conf->{'httpProxy'}->{'value'};
68 print &ui_table_row($text{'rhn_proxy'},
69 &ui_radio("proxy_on", $conf->{'enableProxy'}->{'value'} ? 1 : 0,
70 [ [ 0, $text{'rhn_none'} ],
71 [ 1, &ui_textbox("proxy", $prx, 40) ] ]));
74 print &ui_table_row($text{'rhn_skip'},
76 join("\n", split(/;/, $conf->{'pkgSkipList'}->{'value'})), 5, 40));
78 print &ui_table_end();
79 print &ui_form_end([ [ undef, $text{'rhn_apply'} ],
80 [ "now", $text{'rhn_now'} ] ]);
83 # read_up2date_config()
84 sub read_up2date_config
88 &open_readfile(CONF, $up2date_config);
91 if (/^([^=\s]+)=(.*)$/) {
92 $conf{$1} = { 'name' => $1,
102 # save_up2date_config(&config, name, value)
103 sub save_up2date_config
105 local $lref = &read_file_lines($up2date_config);
106 local $old = $_[0]->{$_[1]};
108 $lref->[$old->{'line'}] = "$_[1]=$_[2]";
112 # update_system_available()
113 # Returns a list of packages available from RHN
114 sub update_system_available
117 open(UP2DATE, "up2date -l --showall |");
120 if (/^(\S+)\-([^\-]+)\-([^\-]+)\.([^\.]+)$/) {
121 push(@rv, { 'name' => $1,
122 'version' => "$2-$3",