private static boolean performPreemptiveSystemCheck() {

    File tmpDir = DirectorySettings.getTmpDirectory();
    File cacheDir = DirectorySettings.getCacheDirectory();
    File medsavantDir = DirectorySettings.getMedSavantDirectory();

    System.out.println("Directory information:");
    System.out.println(
        "  TMP DIRECTORY: " + tmpDir.getAbsolutePath() + " has permissions " + permissions(tmpDir));
    System.out.println(
        "  MEDSAVANT DIRECTORY: "
            + medsavantDir.getAbsolutePath()
            + " has permissions "
            + permissions(medsavantDir));
    System.out.println(
        "  CACHE DIRECTORY: "
            + cacheDir.getAbsolutePath()
            + " has permissions "
            + permissions(cacheDir));
    System.out.println();

    boolean passed = true;

    if (!completelyPermissive(tmpDir)) {
      System.out.println(
          "ERROR: "
              + tmpDir.getAbsolutePath()
              + " does not have appropriate permissions (require rwx)");
      passed = false;
    }

    if (!completelyPermissive(medsavantDir)) {
      System.out.println(
          "ERROR: "
              + medsavantDir.getAbsolutePath()
              + " does not have appropriate permissions (require rwx)");
      passed = false;
    }
    if (!completelyPermissive(cacheDir)) {
      System.out.println(
          "ERROR: "
              + cacheDir.getAbsolutePath()
              + " does not have appropriate permissions (require rwx)");
      passed = false;
    }
    try {
      File cacheNow = DirectorySettings.generateDateStampDirectory(cacheDir);
      if (!completelyPermissive(cacheNow)) {
        System.out.println(
            "ERROR: Directories created inside "
                + cacheDir
                + " do not have appropriate permissions (require rwx)");
        passed = false;
      }
    } catch (IOException ex) {
      System.out.println("ERROR: Couldn't create directory inside " + cacheDir.getAbsolutePath());
      passed = false;
    }

    try {
      File tmpNow = DirectorySettings.generateDateStampDirectory(tmpDir);
      if (!completelyPermissive(tmpNow)) {
        System.out.println(
            "ERROR: Directories created inside "
                + tmpDir
                + " do not have appropriate permissions (require rwx)");
        passed = false;
      }
    } catch (IOException ex) {
      System.out.println("ERROR: Couldn't create directory inside " + tmpDir.getAbsolutePath());
      passed = false;
    }

    return passed;
  }
  public static void main(String args[]) {

    System.out.println("== MedSavant Server Engine ==\n");

    try {

      /** Override with commands from the command line */
      Getopt g = new Getopt("MedSavantServerEngine", args, "c:l:h:p:u:e:");
      //
      int c;

      String user = "******";
      String password = null;
      String host = "localhost";
      int port = 5029;

      // print usage
      if (args.length > 0 && args[0].equals("--help")) {
        System.out.println(
            "java -jar -Djava.rmi.server.hostname=<hostname> MedSavantServerEngine.jar { [-c CONFIG_FILE] } or { [-l RMI_PORT] [-h DATABASE_HOST] [-p DATABASE_PORT] [-u DATABASE_ROOT_USER] [-e ADMIN_EMAIL] }");
        System.out.println(
            "\n\tCONFIG_FILE should be a file containing any number of these keys:\n"
                + "\t\tdb-user - the database user\n"
                + "\t\tdb-password - the database password\n"
                + "\t\tdb-host - the database host\n"
                + "\t\tdb-port - the database port\n"
                + "\t\tlisten-on-port - the port on which clients will connect\n"
                + "\t\temail - the email address to send important notifications\n"
                + "\t\ttmp-dir - the directory to use for temporary files\n"
                + "\t\tms-dir - the directory to use to store permanent files\n");
        return;
      }

      while ((c = g.getopt()) != -1) {
        switch (c) {
          case 'c':
            String configFileName = g.getOptarg();
            System.out.println(
                "Loading configuration from "
                    + (new File(configFileName)).getAbsolutePath()
                    + " ...");

            Properties prop = new Properties();
            try {
              prop.load(new FileInputStream(configFileName));
              if (prop.containsKey("db-user")) {
                user = prop.getProperty("db-user");
              }
              if (prop.containsKey("db-password")) {
                password = prop.getProperty("db-password");
              }
              if (prop.containsKey("db-host")) {
                host = prop.getProperty("db-host");
              }
              if (prop.containsKey("db-port")) {
                port = Integer.parseInt(prop.getProperty("db-port"));
              }
              if (prop.containsKey("listen-on-port")) {
                int listenOnPort = Integer.parseInt(prop.getProperty("listen-on-port"));
                MedSavantServerUnicastRemoteObject.setListenPort(listenOnPort);
                // MedSavantServerUnicastRemoteObject.setExportPort(listenOnPort + 1);
              }
              if (prop.containsKey("email")) {
                EmailLogger.setMailRecipient(prop.getProperty("email"));
              }
              if (prop.containsKey("tmp-dir")) {
                DirectorySettings.setTmpDirectory(prop.getProperty("tmp-dir"));
              }
              if (prop.containsKey("ms-dir")) {
                DirectorySettings.setMedSavantDirectory(prop.getProperty("ms-dir"));
              }

            } catch (Exception e) {
              System.out.println("ERROR: Could not load properties file " + configFileName);
            }
            break;
          case 'h':
            System.out.println("Host " + g.getOptarg());
            host = g.getOptarg();
            break;
          case 'p':
            port = Integer.parseInt(g.getOptarg());
            break;
          case 'l':
            int listenOnPort = Integer.parseInt(g.getOptarg());
            MedSavantServerUnicastRemoteObject.setListenPort(listenOnPort);
            // MedSavantServerUnicastRemoteObject.setExportPort(listenOnPort + 1);
            break;
          case 'u':
            user = g.getOptarg();
            break;
          case 'e':
            EmailLogger.setMailRecipient(g.getOptarg());
            break;
          case '?':
            break; // getopt() already printed an error
          default:
            System.out.print("getopt() returned " + c + "\n");
        }
      }

      new MedSavantServerEngine(host, port, user, password);
    } catch (Exception e) {
      e.printStackTrace();
      System.exit(1);
    }
  }