Esempio n. 1
0
//
// Check cluster state status
//
int					checkClusterState()
{
	HCLUSTER 		hClust;
	DWORD			pdwClusterState;
	
	if (GetNodeClusterState(NULL, &pdwClusterState) != ERROR_SUCCESS)
	{
		warnError(L"Error 0x%x executing GetClusterInformation entry point.", GetLastError());
        return I_FALSE;
	}
	switch (pdwClusterState)
	{
		case ClusterStateNotInstalled :
			warnError(L"Windows Clustering is not installed.");
			return I_FALSE;
		case ClusterStateNotConfigured :
			warnError(L"Windows Clustering is not configured.");
			return I_FALSE;
		case ClusterStateNotRunning :
		case ClusterStateRunning :
			break ;
	}	
	hClust = OpenCluster(NULL);
	if (hClust == NULL)
	{
		warnError(L"Error 0x%x executing OpenCluster entry point.", GetLastError());
        return I_FALSE;
	}
	CloseCluster(hClust);
	return I_TRUE;
}
Esempio n. 2
0
int					getClusterGroups(cluster_t *pcluster)
{
	HCLUSTER 		hClust;
	HCLUSENUM 		hClusEnum;
	DWORD			dwIndex;
	DWORD			dwType;
	LPWSTR 			lpszName;			
	DWORD			cchName;
	
	hClust = OpenCluster(NULL);
	if (hClust == NULL)
	{
		warnError(L"Error 0x%x executing OpenCluster entry point.", GetLastError());
        return I_FALSE;
	}
	if ((hClusEnum = ClusterOpenEnum(hClust, CLUSTER_ENUM_GROUP)) == NULL)
	{
		warnError(L"Error 0x%x executing OpenCluster entry point.", GetLastError());
		CloseCluster(hClust);
        return I_FALSE;
	}
	if ((lpszName = LocalAlloc(LPTR, BUFFER_SIZE * sizeof(TCHAR))) == NULL)
		fatalError(L"Fatal Error 0x%x executing LocalAlloc entry point.", GetLastError());
	cchName = BUFFER_SIZE;
	for (dwIndex = 0; ClusterEnum(hClusEnum, dwIndex, &dwType, lpszName, &cchName) == ERROR_SUCCESS; dwIndex++)
	{
		getGroupState(pcluster, hClust, lpszName);
		cchName = BUFFER_SIZE;
	}
	LocalFree(lpszName);
	ClusterCloseEnum(hClusEnum);
	CloseCluster(hClust);
	return I_TRUE;
}
Esempio n. 3
0
UINT __stdcall 
ingres_cluster_unregister_service(MSIHANDLE hInstall) 
{
	HCLUSTER hCluster;
	HRESOURCE hResource;
	WCHAR wszResourceName[256];
	char szResourceName[256];
	char szInstallCode[3];
	DWORD dwSize;
	INSTALLSTATE iInstalled, iAction;
	char szBuf[256];

	MsiGetFeatureState(hInstall, "IngresDBMS", &iInstalled, &iAction);
	if(iAction != INSTALLSTATE_ABSENT)
		return ERROR_SUCCESS;

	dwSize=sizeof(szBuf); *szBuf=0;
	if (!MsiGetProperty(hInstall, "INGRES_CLUSTER_RESOURCE_INUSE", szBuf, &dwSize) 
		&& !strcmp(szBuf, "1"))
		return ERROR_SUCCESS;

	dwSize=sizeof(szResourceName); *szResourceName=0;
	MsiGetProperty(hInstall, "INGRES_CLUSTER_RESOURCE", szResourceName, &dwSize);
	mbstowcs(wszResourceName, szResourceName, sizeof(szResourceName));
	dwSize=sizeof(szInstallCode); *szInstallCode=0;
	MsiGetProperty(hInstall, "II_INSTALLATION", szInstallCode, &dwSize);

	hCluster = OpenCluster(NULL);
	if(hCluster)
	{
		hResource = OpenClusterResource(hCluster, wszResourceName);
		if(hResource)
		{
			if (!DeleteClusterResource(hResource))
				SetupRegistryKeys(hResource, szInstallCode, FALSE);
			CloseClusterResource(hResource);
		}
		CloseCluster(hCluster);
	}

	return ERROR_SUCCESS;
}
Esempio n. 4
0
/** 
 ** This routine will handle upgrade/modify installs only.
 ** This dialog will only be displayed if ingres is being modified or upgraded.
 */
BOOL
InstanceList::OnWizardFinish()
{
	char code[3];
	char ach[2048], ii_system[1024];
	int flag=0;
	BOOL bInstalled=FALSE;

	sprintf(code, "%s", m_iicode);
	thePreInstall.m_InstallCode=m_iicode;
	if(strlen(code)!=2 || !isalpha(code[0]) || !isalnum(code[1]))
	{
		Error(IDS_INVALIDINSTALLATIONCODE, code);
		return FALSE;
	}

	CInstallation *inst=NULL;
	for(int i=0; i<thePreInstall.m_Installations.GetSize(); i++)
	{
		inst=(CInstallation *) thePreInstall.m_Installations.GetAt(i);
		if (inst && !thePreInstall.m_InstallCode.CompareNoCase(inst->m_id))
		{
			bInstalled=TRUE;
			sprintf(ii_system, "%s", inst->m_path);
			thePreInstall.m_UpgradeType=CompareIngresVersion(ii_system);
			if (thePreInstall.m_DBATools)
				thePreInstall.m_UpgradeType=inst->m_UpgradeCode;
			if (inst->m_ver25)
			{
				thePreInstall.m_Ver25 ="1";
				thePreInstall.m_EmbeddedRelease =inst->m_embedded;
			}
			break;
		}
	}

	if (!(bInstalled && (!thePreInstall.m_Ver25.Compare("1") || thePreInstall.m_UpgradeType)))
		goto Label;

	char buf[2048], szInstallCode[3];
	char szKey[256], szResName[256];
	int idx;
	HKEY hKey;
	BOOL bCluster;

	sprintf(szInstallCode, thePreInstall.m_InstallCode.GetBuffer(3));
	if (_stricmp(szInstallCode, "II"))
	{
		/* Compute the GUID index from the installation code */
		idx = (toupper(szInstallCode[0]) - 'A') * 26 + toupper(szInstallCode[1]) - 'A';
		if (idx <= 0)
			idx = (toupper(szInstallCode[0]) - 'A') * 26 + toupper(szInstallCode[1]) - '0';

		sprintf(szKey, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{A78D%04X-2979-11D5-BDFA-00B0D0AD4485}",idx);
	}
	else 
		sprintf(szKey, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{A78D00D8-2979-11D5-BDFA-00B0D0AD4485}");
	thePreInstall.m_InstallCode.ReleaseBuffer();

	bCluster=FALSE;
	if(!RegOpenKeyEx(HKEY_LOCAL_MACHINE, szKey, 0, KEY_QUERY_VALUE, &hKey))
	{
		char szData[2];
		DWORD dwSize;

		dwSize=sizeof(szData); *szData=0;
		if (!RegQueryValueEx(hKey,"IngresClusterInstall", NULL, NULL, (BYTE *)szData, &dwSize) && !strcmp(szData, "1"))
			bCluster=TRUE;
		dwSize=sizeof(szResName); *szResName=0;
		if (!RegQueryValueEx(hKey,"IngresClusterResource", NULL, NULL, (BYTE *)szResName, &dwSize))
			sprintf(szResName, "Ingres Service [ %s ]", szInstallCode);
		RegCloseKey(hKey);
	}
				
	SetEnvironmentVariable("II_SYSTEM", ii_system);
	GetEnvironmentVariable("PATH", buf, sizeof(buf));
	sprintf(ach, "%s\\ingres\\bin;%s\\ingres\\utility;%s", ii_system, ii_system, buf);
	SetEnvironmentVariable("PATH", ach);

	while(IngresAlreadyRunning()==1)
	{
		thePreInstall.m_RestartIngres=1;

		MessageBeep(MB_ICONEXCLAMATION);
		if(!flag && AskUserYN(IDS_INGRESRUNNING))
		{
			CWaitCursor wait;

			flag=1;
			if (!bCluster)
			{
				sprintf(ach, "\"%s\\ingres\\bin\\winstart.exe\"", ii_installpath);
				Execute(ach, "/stop", FALSE);
				Sleep(1000);
				while(WinstartRunning())
				{
					Sleep(1000);
					GetParent()->UpdateWindow();
				}
			}
			else
			{
				HCLUSTER hCluster = NULL;
				HRESOURCE hResource = NULL;
				WCHAR lpwResourceName[256];

				hCluster = OpenCluster(NULL);
				if (hCluster)
				{
					mbstowcs(lpwResourceName, szResName, 256);
					hResource = OpenClusterResource(hCluster, lpwResourceName);
					if (hResource)
					{
						OfflineClusterResource(hResource);
						CloseClusterResource(hResource);
					}
				}
				while (IngresAlreadyRunning()==1)
					Sleep(1000);

			}
		}
		else
		{
			GotoDlgCtrl(&m_list);
			return FALSE;
		}
	}

	sprintf(ach, "\"%s\\ingres\\bin\\ivm.exe\"", ii_installpath);
	if (!Execute(ach, "-stop", FALSE))
	{
		sprintf(ach, "\"%s\\ingres\\vdba\\ivm.exe\"", ii_installpath);
		Execute(ach, "-stop", FALSE);
	}

	if(IngresAlreadyRunning()==0)
	{
		if ((thePreInstall.m_UpgradeType ==1 || thePreInstall.m_UpgradeType ==2) && 			!thePreInstall.m_DBATools)
		{
			CString charset;
			if (IsPre92Release(inst->m_ReleaseVer))
			{
			Local_NMgtIngAt("II_CHARSET", inst->m_path, charset);
			if (charset.IsEmpty())
			{
				char charsetinst[MAX_PATH];
				sprintf(charsetinst, "II_CHARSET%s", inst->m_id);
				Local_NMgtIngAt(charsetinst, inst->m_path, charset);
			}
			if (!charset.IsEmpty() && charset.CompareNoCase("UTF8")==0)
			{
				Error(IDS_BLOCKUPGRADE, code);
				return FALSE;
			}
			}
			if (thePreInstall.m_Ver25.Compare("1"))
			{
				if(!AskUserYN(IDS_UPGRADE))
				{
					thePreInstall.m_UpgradeType=0;
				}
			}
			else
			{
				if (!AskUserYN(IDS_MUSTUPGRADEVER25, thePreInstall.m_InstallCode))
				{
					GotoDlgCtrl(&m_list);
					return FALSE;
				}
			}
		}
	}

Label:
	if(!thePreInstall.LaunchWindowsInstaller(!bInstalled))
		exit(0);

	return TRUE;
}