Yaribz / SPADS

SpringRTS Perl Autohost for Dedicated Server
GNU General Public License v3.0
17 stars 16 forks source link

installer not working in non interactive mode #48

Closed cghislai closed 5 years ago

cghislai commented 5 years ago

The installer fails in non-interactive mode due to the last 3 questions:

$conf{lobbyLogin}=promptString("$currentStep/$nbSteps - Please enter the autohost lobby login (the lobby account must already exist)");
$currentStep++;
$conf{lobbyPassword}=promptString("$currentStep/$nbSteps - Please enter the autohost lobby password");
$currentStep++;
$conf{owner}=promptString("$currentStep/$nbSteps - Please enter the lobby login of the autohost owner");
$currentStep++;

These statements should be run only if the $conf entries are empty and the installer is running in interactive mode. So that we can pass them as arguments or edit the config file afterwards.

cghislai commented 5 years ago

workaround:

 perl spadsInstaller.pl 
 sed -i 's/^\$conf{lobbyLogin}.*$//' spadsInstaller.pl 
 sed -i 's/^\$conf{lobbyPassword}.*$//' spadsInstaller.pl 
 sed -i 's/^\$conf{owner}.*$//' spadsInstaller.pl 
 sed -i 's/spadsInstaller\.pl //' spadsInstaller.pl 
 perl spadsInstaller.pl
Yaribz commented 5 years ago

I'm not sure I understand your request. Why don't you just use the standard way of passing STDIN arguments to programs in non-interactive mode instead of patching the binary ?

In your case, for the 3 parameters which seem to cause you trouble:

echo "lobbyLoginValue
lobbyPasswordValue
ownerValue" | perl spadsInstaller.pl
cghislai commented 5 years ago

This is indeed another way to work around that. I tried using \n rather than an actual line break which is probably why it failed and I opted for sed. It would be nice if that workaround was not mandatory though.

Yaribz commented 5 years ago

I don't understand why you call that a workaround ? The installer isn't supposed to be used in a non-interactive way for full SPADS install, however you can use it this way as any other console program, by piping inputs.

cghislai commented 5 years ago

Ok looking at the code, i saw that there was a nonInteractive variable used in most place except those 3, thus I thought this was a supported feature and that those 3 last input not working was a bug. If this is not supported then thats ok this can be closed

Yaribz commented 5 years ago

Ah ok I understand now. Actually there is indeed some special handling for non-interactive mode, in order to avoid being stuck in re-ask loop in case of invalid value provided, but that's about all.

I think you might have been confused by a mechanism in place which allows the installer to relaunch itself during auto-updates and library path adjustments for example. This mechanism makes it possible to start the installer from a specific step without re-asking the questions from the beginning. In this case indeed some configuration values are passed as parameters so that they don't need to be re-asked to the user, but it's just internal functioning not officially exposed to the end user. That's why this mechanism doesn't handle the parameters you listed: the installer doesn't need to restart itself once it has reached these steps.