Class FTPInstall

java.lang.Object
  extended by FTPInstall

 class FTPInstall
extends java.lang.Object

Main class which handles installation of jFTPd from command line. The command line has a fixed syntax and can be computed by automation tools that download the latest version of jFTPd and then deploy them online, overwriting the previous version (but keeping the settings). Creation date: (10/10/2001 4:01:41 PM)


Field Summary
private static java.io.PrintWriter log
           
protected static java.lang.String os_name
           
 
Constructor Summary
FTPInstall()
          Default constructor.
 
Method Summary
static java.lang.String convertArrayToString(java.lang.String[] array)
          Converts an array of Strings into a single String, where the elements are separated by a space.
static void log(java.lang.String message)
          Writes a log message into the installation log file.
static void main(java.lang.String[] args)
          Main install method.
static boolean onAix()
          Checks if the operating system is AIX.
static boolean onLinux()
          Checks if the operating sistem is Linux Creation date: (29-Mar-02 16:02:05)
static boolean onSolaris()
          Checks if the operating sistem is Solaris.
static boolean onWindows()
          Checks if the operating sistem is Windows Creation date: (29-Mar-02 16:09:53)
static java.lang.String prepareFileName(java.lang.String fileName)
          Returns the absolute path for the given filename.
private static void runCommand(java.lang.String command)
          Runs a system command using the Runtime interface and waits for the command to be executed.
private static void runCommand(java.lang.String[] command)
          Runs a system command using the Runtime interface and waits for the command to be executed.
static boolean unixInstall(java.lang.String archiveName, java.lang.String version, java.lang.String swdistDirectory, java.lang.String deploymentDirectory)
          Installs (or updates) a jFTPd server on UNIX systems.
static void unpack(java.io.File archive, java.io.File swdistDir)
          Extracts an archive in the given directory.
static boolean windowsInstall(java.lang.String archiveName, java.lang.String version, java.lang.String swdistDirectory, java.lang.String deploymentDirectory)
          Installs (or updates) a jFTPd server on Windows systems.
private static void writeFile(java.io.InputStream input, java.io.File destination)
          Dumps the content that arrive via the input stream into the specified file.
private static void writeFile(java.lang.String inputName, java.io.File destination)
          Copies a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static java.io.PrintWriter log

os_name

protected static java.lang.String os_name
Constructor Detail

FTPInstall

public FTPInstall()
Default constructor.

Method Detail

convertArrayToString

public static java.lang.String convertArrayToString(java.lang.String[] array)
Converts an array of Strings into a single String, where the elements are separated by a space. Creation date: (08-Aug-02 13:36:19)


log

public static void log(java.lang.String message)
Writes a log message into the installation log file. On Windows, the installation log file is jftpd_install.log and is created in the current working directory where JVM is found at the moment. On other systems (Unix) the installation log file is created in /tmp/jftpd_install.log Creation date: (10/12/2001 3:17:57 PM)

Parameters:
message - the message to be written to file.

main

public static void main(java.lang.String[] args)
Main install method. Takes a couple of arguments from the command line and proceeds with the installation. Creation date: (10/11/2001 5:43:09 PM)

Parameters:
args - Arguments taken from command line:
file name of new archive to be deployed (such as jftpd-1.2.16.0)
the version of the new archive (used in creating the directory in which the archive will be unpacked)
swdist directory
deploy directory (each archive is unpacked in a [deploy directory]/jftpd-[version]. On Unix systems a symbolic link is then created from [deploy directory]/jftpd to [deploy directory]/jftpd-[version].

onAix

public static boolean onAix()
Checks if the operating system is AIX.

Returns:
true if the operating system is AIX.

onLinux

public static boolean onLinux()
Checks if the operating sistem is Linux Creation date: (29-Mar-02 16:02:05)

Returns:
true if the operating system is Linux.

onSolaris

public static boolean onSolaris()
Checks if the operating sistem is Solaris. Creation date: (29-Mar-02 16:09:53)

Returns:
true if the operating system is Solaris

onWindows

public static boolean onWindows()
Checks if the operating sistem is Windows Creation date: (29-Mar-02 16:09:53)

Returns:
true if the operating system is Windows

prepareFileName

public static java.lang.String prepareFileName(java.lang.String fileName)
Returns the absolute path for the given filename. Creation date: (08-Aug-02 13:25:18)

Returns:
absolute path to the filename (transforms a relative file name into its absolute path)

runCommand

private static void runCommand(java.lang.String[] command)
                        throws java.io.IOException
Runs a system command using the Runtime interface and waits for the command to be executed. You need to pass the command as an array of [command, arg1, arg2...] Creation date: (01-Aug-02 13:07:01)

Throws:
java.io.IOException - thrown when there's a failure running the command.

runCommand

private static void runCommand(java.lang.String command)
                        throws java.io.IOException
Runs a system command using the Runtime interface and waits for the command to be executed. You need to pass the command as a String of "command arg1 arg2 ..." Creation date: (01-Aug-02 13:07:01)

Throws:
java.io.IOException - thrown when there's a failure running the command.

unixInstall

public static boolean unixInstall(java.lang.String archiveName,
                                  java.lang.String version,
                                  java.lang.String swdistDirectory,
                                  java.lang.String deploymentDirectory)
                           throws java.io.IOException
Installs (or updates) a jFTPd server on UNIX systems. This method conservers the settings of the previous installation (such as users.dat file, configurations, etc).
unpack the archive file into [installDirectory][jftpd-version]
starts up jFTPd (and killing a previous running jFTPd) using the built in scripts found in the archive
adds jFTPd as a service in /etc/rc.d/rc2.d/S99jftpd.ksh
Creation date: (10/11/2001 4:17:07 PM)

Parameters:
archiveName - archive file name (must be a tar.gz file)
version - extracts the archive into [deploymentDirectory][jftpd-version]
swdistDirectory - directory where the archive can be unpacked (a temp dir for example)
deploymentDirectory - extracts the archive into [deploymentDirectory][jftpd-version]
Returns:
true if installation went OK.
Throws:
java.io.IOException - Thrown if something goes wrong with the installation.

unpack

public static void unpack(java.io.File archive,
                          java.io.File swdistDir)
                   throws java.io.IOException
Extracts an archive in the given directory. Creation date: (10/11/2001 2:34:39 PM)

Parameters:
archive - java.io.File archive to be extracted
installdir - java.io.File directory where to extract.
Throws:
java.io.IOException - The exception description.

windowsInstall

public static boolean windowsInstall(java.lang.String archiveName,
                                     java.lang.String version,
                                     java.lang.String swdistDirectory,
                                     java.lang.String deploymentDirectory)
                              throws java.io.IOException
Installs (or updates) a jFTPd server on Windows systems. This method conservers the settings of the previous installation (such as users.dat file, configurations, etc).
unpack the archive file into [installDirectory][jftpd-version]
starts up jFTPd (and stopping a previous running jFTPd)
Creation date: (10/11/2001 4:17:07 PM)

Parameters:
archiveName - archive file name (must be a tar.gz file)
version - extracts the archive into [deploymentDirectory][jftpd-version]
swdistDirectory - directory where the archive can be unpacked (a temp dir for example)
deploymentDirectory - extracts the archive into [deploymentDirectory][jftpd-version]
Returns:
true if installation went OK.
Throws:
java.io.IOException - Thrown if something goes wrong with the installation.

writeFile

private static void writeFile(java.io.InputStream input,
                              java.io.File destination)
Dumps the content that arrive via the input stream into the specified file. Used internally by the unpack method. Creation date: (10/11/2001 3:47:44 PM)

Parameters:
input - java.io.InputStream
destination - java.io.File
Throws:
java.io.IOException - The exception description.

writeFile

private static void writeFile(java.lang.String inputName,
                              java.io.File destination)
Copies a file. Creation date: (10/11/2001 3:47:44 PM)

Parameters:
input - java.lang.String - input file name.
destination - java.io.File - destination
Throws:
java.io.IOException - The exception description.