+
+sub prompt
+{
+ my($question, $default, $option) = @_;
+
+ $default = $opts{$option} if ( defined($opts{$option}) );
+ if ( $opts{batch} ) {
+ print("$question [$default]\n");
+ return $default;
+ }
+ print("$question [$default]? ");
+ my $reply = <STDIN>;
+ $reply =~ s/[\n\r]*//g;
+ return $reply if ( $reply !~ /^$/ );
+ return $default;
+}
+
+__END__
+
+=head1 SYNOPSIS
+
+configure.pl [options]
+
+=head1 DESCRIPTION
+
+configure.pl is a script that is used to install or upgrade a BackupPC
+installation. It is usually run interactively without arguments. It
+also supports a batch mode where all the options can be specified
+via the command-line.
+
+For upgrading BackupPC you need to make sure that BackupPC is not
+running prior to running BackupPC.
+
+Typically configure.pl needs to run as the super user (root).
+
+=head1 OPTIONS
+
+=over 8
+
+=item B<--batch>
+
+Run configure.pl in batch mode. configure.pl will run without
+prompting the user. The other command-line options are used
+to specify the settings that the user is usually prompted for.
+
+=item B<--bin-path PROG=PATH>
+
+Specify the path for various external programs that BackupPC
+uses. Several --bin-path options may be specified. configure.pl
+usually finds sensible defaults based on searching the PATH.
+The format is:
+
+ --bin-path PROG=PATH
+
+where PROG is one of perl, tar, smbclient, nmblookup, rsync, ping,
+df, ssh, sendmail, hostname, split, par2, cat, gzip, bzip2 and
+PATH is that full path to that program.
+
+Examples
+
+ --bin-path cat=/bin/cat --bin-path bzip2=/home/user/bzip2
+
+=item B<--config-path CONFIG_PATH>
+
+Path to the existing config.pl configuration file for BackupPC.
+This option should be specified for batch upgrades to an
+existing installation. The option should be omitted when
+doing a batch new install.
+
+=item B<--cgi-dir CGI_DIR>
+
+Path to Apache's cgi-bin directory where the BackupPC_Admin
+script will be installed. This option only needs to be
+specified for a batch new install.
+
+=item B<--data-dir DATA_DIR>
+
+Path to the BackupPC data directory. This is where all the backup
+data is stored, and it should be on a large file system. This option
+only needs to be specified for a batch new install.
+
+Example:
+
+ --data-dir /data/BackupPC
+
+=item B<--dest-dir DEST_DIR>
+
+An optional prefix to apply to all installation directories.
+Usually this is not needed, but certain auto-installers like
+to stage an install in a temporary directory, and then copy
+the files to their real destination. This option can be used
+to specify the temporary directory prefix. Note that if you
+specify this option, BackupPC won't run correctly if you try
+to run it from below the --dest-dir directory, since all the
+paths are set assuming BackupPC is installed in the intended
+final locations.
+
+=item B<--help|?>
+
+Print a brief help message and exits.
+
+=item B<--hostname HOSTNAME>
+
+Host name (this machine's name) on which BackupPC is being installed.
+This option only needs to be specified for a batch new install.
+
+=item B<--html-dir HTML_DIR>
+
+Path to an Apache html directory where various BackupPC image files
+and the CSS files will be installed. This is typically a directory
+below Apache's DocumentRoot directory. This option only needs to be
+specified for a batch new install.
+
+Example:
+
+ --html-dir /usr/local/apache/htdocs/BackupPC
+
+=item B<--html-dir-url URL>
+
+The URL (without http://hostname) required to access the BackupPC html
+directory specified with the --html-dir option. This option only needs
+to be specified for a batch new install.
+
+Example:
+
+ --html-dir-url /BackupPC
+
+=item B<--install-dir INSTALL_DIR>
+
+Installation directory for BackupPC scripts, libraries, and
+documentation. This option only needs to be specified for a
+batch new install.
+
+Example:
+
+ --install-dir /usr/local/BackupPC
+
+=item B<--man>
+
+Prints the manual page and exits.
+
+=item B<--uid-ignore>
+
+configure.pl verifies that the script is being run as the super user
+(root). Without the --uid-ignore option, in batch mode the script will
+exit with an error if not run as the super user, and in interactive mode
+the user will be prompted. Specifying this option will cause the script
+to continue even if the user id is not root.
+
+=head1 EXAMPLES
+
+For a standard interactive install, run without arguments:
+
+ configure.pl
+
+For a batch new install you need to specify answers to all the
+questions that are normally prompted:
+
+ configure.pl \
+ --batch \
+ --cgi-dir /var/www/cgi-bin/BackupPC \
+ --data-dir /data/BackupPC \
+ --hostname myHost \
+ --html-dir /var/www/html/BackupPC \
+ --html-dir-url /BackupPC \
+ --install-dir /usr/local/BackupPC
+
+For a batch upgrade, you only need to specify the path to the
+configuration file:
+
+ configure.pl --batch --config-path /data/BackupPC/conf/config.pl
+
+=head1 AUTHOR
+
+Craig Barratt <cbarratt@users.sourceforge.net>
+
+=head1 COPYRIGHT
+
+Copyright (C) 2001-2004 Craig Barratt.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+=cut