Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I have my own CGI archive website with a few free scripts people can download. I was just thinking how much nicer it would be for the users if I wrote a script to install each of them.

My question is, how do most of them work? I've only come across a few scripts that install themselves.

My first idea was having an install.cgi just print a basic web form asking for all the required information (passwords, absolute paths to files, etc). (they upload the original script themself). Then once they submit, the form verifies that every location they included works and the script itself is in the right place. Then the install script opens the original script and sets the configurations.

My other idea was to have the installer WRITE the entire script. Maybe this route would be easier as I wouldn't have to be careful with regexes to ensure everything is being written properly. This to me sounds like the best bet but some of my scripts actually have 6 or more separate CGI files with them. It seems the first idea would be better for this amount of scripts in one package.

Any ideas or suggestions?

Replies are listed 'Best First'.
Re: Automated script installation
by Errto (Vicar) on Jan 15, 2005 at 05:43 UTC

    My only experience here is with some older versions of IMP. Granted that's PHP not Perl, but the same basic issues apply of how do you package a web application for easy installation. They did it the first way you suggest. The steps were 1) unpack the distribution into a directory on your web root 2) acccess the site from localhost and fill in the form they give you 3) let the script triggered by that form create all the config files, copy stuff to the appropriate place, etc.

    OTOH, IMP subsequently abandoned that approach and now the installation consists of unpacking, running a script on the console that prompts you for the relevant questions, and further editing config files manually as needed.

Re: Automated script installation
by brian_d_foy (Abbot) on Jan 15, 2005 at 20:59 UTC

    The tricky part of web installations is that many web servers don't allow CGI scripts to install anything (nor should they). Usually a CGI script does not have the necessary permissions to do what you will need.

    You can install scripts the same way that you can install modules, though. Perl distributions just aren't for modules, you know. ;)

    I wrote scriptdist to build distributions around scripts (and wrote about it in the May 2004 issue of The Perl Journal). Once you do that, you can add the various prompts and checking to your Makefile.PL. Once you have the distribution, you could even install it with CPAN.pm.

    --
    brian d foy <bdfoy@cpan.org>
Re: Automated script installation
by chanio (Priest) on Jan 15, 2005 at 04:06 UTC

    I vote 4 Ur 1st idea!

    You could ask for the user's config data before downloading your scripts (all packed in a tgz file).

    You could then check that the user is writing the correct data in every field.

    To choose a local path you could add a button for something to be uploaded and then just keep the directory structure without uploading anything. If the user is going to upload your scripts into another site, you could ask the user to create a mirror directory structure in his PC before configuring his script.

    Check wrong paths, tainted data, etc.

    Finally, you could add that config file (full of line comments) to the zipped pack to download.

    You could even ask the user for some 'extra data' not needed for your scripts, just for your records! (email address for posting your news, etc.)