in reply to Installer Program

Depending upon the directions which you take with development, this could be a bigger project than anticipated. If I were tackling this project my first task would be to develop a schema of installation steps, both prior to and following the copying of files, allowing for the searching for dependencies and execution of external script or configuration components - This schema to my mind would need to be modular in fashion so that installation behaviour can be defined by a series of definition or configuration files such that your installer script would offer you the greatest flexibility without having to go back and constantly modify/update it.

On to your specific questions however ...

  1. What's the fastest/most efficient (without wasting memory) way to check if a module is installed?

    To my mind, the quickest would be to actually try and use the module - For example:

    eval { require $module; } if ($@) { # handling for when module fails to load }

    This approach to module and library handling is discussed in the perlfunc:require man page.

     

  2. What happens when a program tries to use 'CPAN' but noone has configured it?

    The init method from the module CPAN::FirstTime is invoked which attempts to configure the CPAN module by prompting the user for information and writing a CPAN::Config configuration file.

     

  3. Is there any way to determine the path to sendmail? Or is there a common default path?

    While the majority of sendmail installations use the target location of /usr/sbin/sendmail, this is not absolute and should not be relied upon. A better way would be to search for the sendmail binary within your script, making use of the File::Find module. However, for better cross-platform compatibility, it may be better still to prompt the user for the local network mail server and communicate directly via SMTP - The advantage which this has is that your script installation is not dependent upon a local sendmail installation for execution and offers greater flexibility to administrators who may wish to impose local mail security policies.

     

Good luck! :-)

 

Replies are listed 'Best First'.
Re: Re: Installer Program
by Molt (Chaplain) on May 20, 2002 at 10:02 UTC

    Note that the File::Find method may not be overly secure if used in a simplistic way. People with any kind of write access can happily drop any program into their space and call it 'Sendmail', and if you're just relying on the filename (or even on it acting vaguely like Sendmail.. it's not overly tricky to do a basic impersonation to hide evilcode) then you're going to end up calling unknown and untrusted code.

    Even without this it's possible that you'd end up calling an old version kept around for compatibility reasons or so on.

    Possibly the best way to handle this, in my opinion, would be to ask the user installing the script which version of Sendmail to use and offering /usr/bin/sendmail as a default if it exists.

Re: Re: Installer Program
by Flame (Deacon) on May 20, 2002 at 20:07 UTC
    Ok, time to expand on my problem then, this installer is run from the web. (Most of the people running it won't have TelNet acess) So how do I get CPAN to work if it hasn't been set up?



    "Weird things happen, get used to it."

    Flame ~ Lead Programmer: GMS