import ca.tecreations.*;
import ca.tecreations.apps.deploy.*;
import ca.tecreations.net.*;
/**
 *
 * @author Tim
 */
public class DeployLogin2 {
    
    public static void main(String[] args) {
        String projectDir = "Login2";
        ProjectPath.setProjectDir(projectDir);
        Deploy deploy = Deploy.launch(ProjectPath.instance);
        String propsPath = ProjectPath.getPropertiesPath() + projectDir + ".properties";
        deploy.setPropertiesPath(propsPath);
         
        deploy.setMakeSecure(false);
        
        String prjsHome = ProjectPath.getProjectsHome();
        if (prjsHome == null) {
            System.err.println("ProjectsHome is not set... Validator...");
        } else {
            String prjPath = ProjectPath.getProjectsHome() + projectDir + File.separator;
            deploy.construct(prjPath);
        }
        deploy.setIncludeSources(true);
        deploy.setIncludeClasses(true);
        deploy.setIncludeJars(false);
        deploy.setFilenamePrefix(projectDir);
        deploy.setAppendDate(false);
        deploy.setAppendTime(false);
        deploy.setMainClass("app.ClientApplication");
        deploy.setRemoteActive(true);
        deploy.setRemoteHost("tecreations.ca");
        deploy.setRemotePort("52820");
        deploy.setRemoteKeyStorePass("storepass".toCharArray());
        String lanIP = Internet.getLanIP();
        System.out.println("Lan IP: " + lanIP);
        if (NameService.instance.getByName("Living Room").equals(lanIP)) {
            deploy.setRemoteKeyStore("D:\\security\\client_keystore");
            deploy.setRemoteTrustStore("D:\\security\\client_truststore");
        } else if (NameService.instance.getByName("Office").equals(lanIP)) {
            deploy.setRemoteKeyStore("F:\\security\\client_keystore");
            deploy.setRemoteTrustStore("F:\\security\\client_truststore");
        } else {
            System.out.println("Using lanIP: " + lanIP + " livingRoom: " + NameService.getInstance().getByName("Living Room"));
            
            System.exit(0);
            deploy.setRemoteKeyStore("DeployEngine.main: Invalid keystore");
            deploy.setRemoteTrustStore("DeployEngine.main: Invalid truststore");
        }
        deploy.setRemoteServerPath("/home/tim/");
        boolean commit = true;
        if (commit) {
            deploy.commitRemote();
            System.exit(0);
        }
    }
    
}
