summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaouda Lo <daouda@mandriva.com>2004-11-03 10:43:22 +0000
committerDaouda Lo <daouda@mandriva.com>2004-11-03 10:43:22 +0000
commit61735d954ab9b227daf1546a6dfd963ac4f284bb (patch)
treec7bd169cc3c1a6223f24290cf89cc9dfc3df3ac2
parentfd4a6710006fcb87ac87e7a7ba6cb083fe372104 (diff)
downloadmgaonline-61735d954ab9b227daf1546a6dfd963ac4f284bb.tar
mgaonline-61735d954ab9b227daf1546a6dfd963ac4f284bb.tar.gz
mgaonline-61735d954ab9b227daf1546a6dfd963ac4f284bb.tar.bz2
mgaonline-61735d954ab9b227daf1546a6dfd963ac4f284bb.tar.xz
mgaonline-61735d954ab9b227daf1546a6dfd963ac4f284bb.zip
superseded mdkonline by mdkonline_tui
-rwxr-xr-xmdkonline219
1 files changed, 219 insertions, 0 deletions
diff --git a/mdkonline b/mdkonline
new file mode 100755
index 00000000..2698f637
--- /dev/null
+++ b/mdkonline
@@ -0,0 +1,219 @@
+#!/usr/bin/perl
+################################################################################
+# Mandrakeonline Text User Interface #
+# #
+# Copyright (C) 2001-2002-2003-2004 Mandrakesoft #
+# #
+# Daouda Lo <daouda@mandrakesoft.com> #
+#
+# This program is free software; you can redistribute it and/or modify #
+# it under the terms of the GNU General Public License Version 2 as #
+# published by the Free Software Foundation. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program; if not, write to the Free Software #
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
+################################################################################
+
+use strict;
+use lib qw(/usr/lib/libDrakX /usr/lib/libDrakX/drakfirsttime);
+use standalone;
+
+use interactive;
+use common;
+use wizards;
+use lang;
+
+use Getopt::Long;
+
+BEGIN { unshift @::textdomains, 'mdkonline', 'drakfirstboot' };
+
+use mdkonline;
+use Digest::MD5 qw(md5 md5_hex md5_base64);
+
+my $in = interactive->vnew('su');
+
+my $expert_link = 'http://www.mandrakeexpert.com';
+my $online_link = 'https://www.mandrakeonline.net';
+
+my $confdir = '/root/.MdkOnline';
+my $conffile = "$confdir/mdkupdate";
+my $logfile = '/tmp/mdkonline.log';
+
+#for compatibilities
+mkdir_p($confdir) if !-d $confdir;
+-e '/root/.mdkupdate' and system("mv", "/root/.mdkupdate", $conffile);
+
+$::Wizard_title = N("Mandrakeonline");
+
+my %choices = (
+ account => N("I already have an account"),
+ noaccount => N("I want to subscribe")
+ );
+
+my $choice = $choices{account};
+
+my ($wiz, $login, $nlogin, $password, $npassword, $boxname, $cfmpassword, $email, $is_success, $key, $r, $createaccount, $sendconfres, $country);
+
+GetOptions('login=s' => \$login, 'pass=s' => \$password, 'box=s' => \$boxname, 'country:s' => \$country);
+
+my %countries = map { lang::c2name($_) => $_ } lang::list_countries();
+$country = lang::c2name(lang::read('', $>)->{country});
+
+sub read_conf() {
+ my $wideconf = '/etc/sysconfig/mdkonline';
+ my %t = getVarsFromSh($wideconf);
+ my $host = chomp_(`hostname`);
+ $t{MACHINE} ||= $1 if $host =~ /(\w+)(.*)/;
+ $login = $t{LOGIN}; $boxname = $t{MACHINE}
+}
+sub check_login {
+ my ($log, $pass, $box) = @_;
+ my ($res, $resp);
+ my $pp = md5_hex($pass);
+ $log && $pass && $box or return 0;
+ my $clink = $expert_link . '/firsttimewizard/validusercheck.php' . '?u=' . $log . '&p=' . $pp;
+ $resp = mdkonline::get_from_URL($clink, "MdkOnline_tuiAgent/");
+ $resp->is_success and $res = $resp->content =~ /TRUE/ ? 1 : 0;
+ $res
+}
+sub send_conf {
+ my ($log, $pass, $box) = @_;
+ my $uplink = $online_link . '/wizard.php';
+ my $pp = md5_hex($pass);
+ my $w = $in->wait_message(N("Please wait"), N("Reading configuration\n"));
+ mdkonline::report_config("$confdir/$log.$pp.$box.online.log");
+ my $tag = { submit => "upload_wizard", wizard => ["$confdir/$log.$pp.$box.online.log.bz2.uue"] };
+ undef $w;
+ my $ww = $in->wait_message(N("Please wait"), N("Sending configuration..."));
+ ($sendconfres, $key) = mdkonline::send_config($uplink, $tag);
+ mdkonline::hw_upload($log, $pass, $box);
+ undef $ww;
+ ($sendconfres, $key)
+}
+sub create_new_account {
+ my ($log, $pass, $mail) = @_;
+ my $url = $expert_link . '/online3_CreateAccount.php' . '?desuserid=' . $log . '&despwd=' . $pass . '&user_email=' . $mail;
+ my $ca = mdkonline::subscribe_online($url);
+ $ca
+}
+$wiz = {
+ name => N("Mandrakeonline"),
+ pages => {
+ welcome => {
+ name => N("This assistant will help you to upload your configuration\n(packages, hardware configuration) to a centralized database in\norder to keep you informed about security updates and useful upgrades.\n"),
+ no_back => 1,
+ next => 'choices'
+ },
+ choices => {
+ name => N("Account creation or authentication"),
+ data => [ { val => \$choice, type => 'list', list => [ values %choices ] } ],
+ post => sub { +{ reverse %choices }->{$choice} },
+ },
+ account => {
+ name => N("Enter your Mandrakeonline login, password and machine name:"),
+ pre => sub {
+ read_conf();
+ },
+ data => sub {
+ [
+ { label => N("Login:"), val => \$login },
+ { label => N("Password:"), val => \$password, hidden => 1 },
+ { label => N("Machine name:"), val => \$boxname },
+ ],
+ },
+ post => sub {
+ my $_wait = $in->wait_message(N("Please wait"), N("Connecting to Mandrakeonline website..."));
+ $is_success = check_login($login, $password, $boxname); undef($_wait);
+ "authenticate"
+ },
+ },
+ authenticate => {
+ name => sub {
+ if ($is_success) {
+ N("In order to benefit from Mandrakeonline services,\nwe are about to upload your configuration.\n\nThe Wizard will now send the following information to Mandrakesoft:\n1) the list of packages you have installed on your system,\n2) your hardware configuration.\n\nIf you feel uncomfortable by that idea, or do not want to benefit from this service,\nplease press 'Cancel'. By pressing 'Next', you allow us to keep you informed\nabout security updates and useful upgrades via personalized email alerts.\nFurthermore, you benefit from discounted paid support services on\nwww.mandrakeexpert.com.")
+ } else {
+ N("Connection problem") . " " . N("or") . " " . N("wrong password:") . "\n" . N("Your login or password was wrong.\n Either you'll have to type it again, or you'll need to create an account on Mandrakeonline.\n In the latter case, go back to the first step to connect to Mandrakeonline.\n Be aware that you must also provide a Machine name \n (only alphabetical characters are admitted)")
+ }
+ },
+ no_back => $is_success ? 1 : 0,
+ post => sub {
+ if ($is_success) {
+ ($sendconfres, $key) = send_conf($login, $password, $boxname);
+ "upload"
+ } else { "choices" }
+ }
+ },
+ noaccount => {
+ name => N("Create a Mandrakeonline Account"),
+ data => sub {
+ [
+ { label => N("Login:"), val => \$nlogin },
+ { label => N("Password:"), val => \$npassword, hidden => 1 },
+ { label => N("Confirm Password:"), val => \$cfmpassword, hidden => 1 },
+ { label => N("Mail contact:"), val => \$email },
+ ]
+ },
+ post => sub {
+ $createaccount = $npassword ne $cfmpassword ? N("The passwords do not match\n Please try again\n") : $nlogin eq '' ? N("Please provide a login") : mdkonline::check_valid_email($email) == 0 ? N("Not a valid mail address!\n") : create_new_account($nlogin, $npassword, $email);
+ "createaccount"
+ }
+ },
+ createaccount => {
+ name => sub {
+ $createaccount eq 'OK' ? "\n\n" . N("Mandrakeonline Account successfully created.\nPlease click \"Next\" to authenticate and upload your configuration\n") : $createaccount;
+ },
+ post => sub {
+ $createaccount eq 'OK' ? "account" : "noaccount"
+ }
+ },
+ upload => {
+ name => sub {
+ if ($sendconfres eq 'TRUE' && $key) {
+ "\n\n" . N("Your upload was successful!") . "\n\n" . N("From now you will receive on security and updates \nannouncements thanks to Mandrakeonline.") . "\n\n" . N("Mandrakeonline offers you the ability to automate the updates.\nA program will run regulary in your system waiting for new updates\n");
+ } else {
+ N("Connection problem") . N("Problem occurs when uploading files, please try again")
+ }
+ },
+ data => sub {
+ if ($sendconfres eq 'TRUE' && $key) {
+ [
+ { label => N("Country"), val => \$country, type => "combo", list => [ sort keys %countries ], not_edit => 0 }
+ ]
+ }
+ },
+ post => sub {
+ mdkonline::automated_upgrades($conffile, $login, md5_hex($password), $boxname, $key, $country, 'TRUE');
+ mdkonline::write_wide_conf($login, $boxname, $country);
+ "end"
+ },
+ },
+ end => {
+ name => sub {
+ N("Congratulations") . "\n\n" . N("Your Mandrakeonline account has been successfully configured\n")
+ },
+ end => 1,
+ no_back => 1,
+ next => 0,
+ }
+ }
+ };
+
+if ($login && $password && $boxname) {
+ $is_success = check_login($login, $password, $boxname);
+ if ($is_success) {
+ ($sendconfres, $key) = send_conf($login, $password, $boxname);
+ if ($sendconfres eq 'TRUE' && $key) {
+ mdkonline::automated_upgrades($conffile, $login, md5_hex($password), $boxname, $key, $country, 'TRUE');
+ mdkonline::write_wide_conf($login, $boxname, $country);
+ output($logfile, N("Configuration uploaded successfully"))
+ } else { output($logfile, N("Problem uploading configuration")) }
+ } else { output($logfile, N("Cannot connect to mandrakeonline website: wrong login/password or router/firewall bad settings")) }
+} else {
+ wizards->new->safe_process($wiz, $in);
+}