# The 'init' step takes care of a couple common questions and initialization steps before the install can actually start. # We first want to determine if the user will be running Psychostats on this local machine or somewhere else, and if the stats # will be displayed on the local machine or on a remote webserver. sub step_init_init { return 1; # step_init should always be first (1 is the lowest/first step to run) } sub step_init { my $in = $conf->{install}; # short-cut for [install] section of config $in->{initialized} = 0 unless exists $in->{initialized}; $in->{skipinit} = 0 unless exists $in->{skipinit}; $in->{webhost} = "localhost" unless exists $in->{webhost}; # $in->{themedir} = catfile(getcwd(), 'themes') unless exists $in->{themedir}; $in->{ftpuser} = ($OS eq 'MSWin32' ? $c->{ $conf->{savetype} }{username} || 'unknown' : getpwuid($>) || $conf->{ $conf->{savetype} }{username}) unless exists $in->{ftpuser}; $in->{ftpport} = 21 unless exists $in->{ftpport}; $in->{ftppass} = "" unless exists $in->{ftppass}; $in->{ftppasv} = 0 unless exists $in->{ftppasv}; goto VERIFY if $args->{verify}; # easy/lazy method to jump ahead if all we want to do is verify settings return -1 if $in->{skipinit}; # skip initialize step ... STARTOVER: %{$wiz->{data}} = ( %{$wiz->{data}}, %$in ); # merge [install] information into data $wiz->{data}{webhostip} = gethostip($in->{webhost}) || 'DNS lookup failed'; $wiz->wraptext($lang->{init_start}); $wiz->wraptext($lang->{init_info1}); if ($in->{webhost} ne 'localhost') { $wiz->wraptext($lang->{init_info2}); $wiz->wraptext($lang->{init_info3}) if $in->{ftpchroot}; $wiz->wraptext($lang->{init_info4}); } unless ($wiz->prompt_yesno(!$in->{initialized}, $lang->{yn_change})) { $wiz->{got_ftp} = 1; # force this, so the rest of the install won't ask $wiz->{got_ftpchroot} = 1; return; } $wiz->get_ftp_info($in); $in->{initialized} = 1; # we now consider ourselves initialized # confupdate($conf,0,1); VERIFY: %{$wiz->{data}} = ( %{$wiz->{data}}, %$in ); my $ftpvalid = 0; if ($in->{webhost} ne 'localhost') { $wiz->wraptext($lang->{init_verify}); $wiz->wraptext($lang->{init_vftp}); } while ($in->{webhost} ne 'localhost' and !$ftpvalid) { if (!$wiz->ftpconnect) { last if $wiz->prompt_yesno(1,$lang->{yn_change}) == 0; # last if we don't want to try anymore $wiz->get_ftp_info($in,undef,1); confupdate($conf,0,1); } else { # $wiz->get_ftp_chroot_prefix($in) if $wiz->{ftproot} eq '/'; $ftpvalid = 1; } } =pod # the section below is commented out (up to the =cut) if ($ftpvalid and $in->{webhost} ne 'localhost') { my $pathvalid = 0; my $ftp = $wiz->{ftp}; while (!$pathvalid) { $wiz->ftpcwdroot; # reset dir to original ftp dir when we logged in if (!$ftp->cwd($in->{themedir}) and !$ftp->mkdir($in->{themedir}, 1)) { chomp($wiz->{data}{error} = $ftp->message); $wiz->wraptext($lang->{ftperror}); if ($wiz->prompt_yesno(1,$lang->{yn_change})) { $wiz->get_installdir($in); next; } $wiz->wraptext($lang->{init_baddir}); exit(1); } else { $pathvalid = 1; $wiz->{ftp}->cwd($in->{themedir}); # change into the install dir ... $in->{themedir} = $wiz->{ftp}->pwd; # ... this will give us a full absolute directory $wiz->{data}{themedir} = $in->{themedir}; $wiz->wraptext($lang->{init_gooddir}); } } } =cut # unless ($args->{verify}) { confupdate($conf, $ftpvalid, 1); # } return 1; } 1;