⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 setup.rul.in

📁 Unix/Linux 网络时间协议版本3 Network Time Protocol Version 3 (NTP) distribution for Unix systems
💻 IN
📖 第 1 页 / 共 2 页
字号:
/*---------------------------------------------------------------------------*\
 *  File Name:  SETUP.RUL
 *
 *  Description:  XNTP - NT Install, 
 *                Reworked by Greg Schueman for XNTP.
 *
 *   BIND version by Larry Kahn... using ideas from Paul Wren's (PIW) version.  
 *
\* ----------------------------------------------------------------------------*/

// Next 4 lines defined by mksetup.bat script	
// declare
//	#define APP_NAME2               "XNTPPACKAGE XNTPVERSION Freeware"
//	#define PRODUCT_VERSION         "XNTPVERSIONRel"
//	#define DEINSTALL_KEY           "NTPXNTPVERSION"

	// Constant declarations.
	#define SPACE_REQUIRED          1300000          // Disk space in bytes.
	#define APP_NAME                "NetworkTimeProtocol"
	#define APPBASE_PATH            "\\var\\ntp\\"
	#define UNINSTALL_NAME          "NTP"
	#define PRODUCT_KEY             "xntpd.exe"
	#define NTP_PORT                123
	#define ONETIMESOURCE           1
	#define TWOTIMESOURCES          2
	#define NOTIMEYET               3
	
	// Global variable declarations
	STRING  svDir, szMsg, szFileSet,szTitle,  szMessage, svUninstLogFile;
	STRING  szProgram, szParam, szTemp, szTemp2, szAppPath;
	STRING  svFileName;
	STRING  svTempStr;
	STRING  svModuleDir;
	STRING  svAnswer;
	STRING  dummy;
	
	BOOL    bRemoveNTP, bUpdateModules;
	

	STRING  svNTPAddress;                   // the IP address of "1st" time source
	STRING  svNTPAddress2;                  // the IP address of "2nd" time source
	STRING  szDllNTPInst;
	NUMBER  nReturnValue;
    INT     nReturnValue2;
    INT     nValue;
	
	//--------Custom Dialog in Ishield-------------------------
	BOOL bDone;
	LIST lNames, lAddrs;

	//------- NTPInst.DLL defines------------------------
	#define k_PrivilegeErr                  1
	#define k_CreateKeyErr                  2
	#define k_RestoreKeyErr                 3
	#define k_ErrUnableToOpenWriteOwner     4
	#define k_ErrUnableToSetOwner           5
	#define k_ErrUnableToOpenDAC            6
	#define k_ErrUnableToWriteDACL          7
	#define k_OpenKeyError                  8
	#define k_ModifySetAccountFail          10
	#define k_SCMErr                        11
	#define k_SCMpoErr                      12
	#define k_DeleteServiceFail             13
	#define k_DeleteKeyFail                 14
	#define k_DeleteValueFail               15
	#define k_DirSecurityErr                16
	#define k_DirSetDACLErr                 17
	#define k_DirSetSecurityErr             18
	#define k_SCMpoStopErr                  19
	#define k_SaveKeyErr                    20
	#define k_ServiceUnknownErr             50
	#define k_ServiceDependency             51
	#define k_ServiceDependencyFail         52
	#define k_ServiceLogonFail              53

	#define k_BadPath                       101
	#define k_AccessDenied                  102
	#define k_ServiceExists                 103
	#define k_createservicefailed           104
	#define k_removeservicefailed           105
	#define k_ServicenoExists               106
	
	//--------Function declarations----------------------------
	prototype SetupScreen                   ();
	prototype CheckRequirements             ();
	prototype RemoveNTP                     ();
	prototype UpdateModules                 ();
	
	prototype ReportError                   (INT, BYREF STRING);
	prototype DoConfigType                  ();
	prototype CreateConfigFiles             (INT);
	prototype InstallNTPFiles               (STRING, INT);
	prototype RegisterEventlogMessages	    (STRING);
	prototype CheckForService               ();
	prototype GetImagePath                  (BYREF STRING);
	prototype LaunchAppAndWait              (STRING,STRING, INT);
	prototype ReverseOctet                  (BYREF STRING, STRING);
	prototype FixDirectory                  (BYREF STRING, STRING);
       

//--------------------------------------------------------------------------
program

StartHere:
    Disable( BACKGROUND );

    dummy = "   ";
    // Set default registry tree
    RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);

    // Set up the installation screen.
    SetupScreen();
    Enable( DIALOGCACHE );

	TARGETDIR = SUPPORTDIR;
	szDllNTPInst = SUPPORTDIR ^ "NTPDLL.DLL";  // NTP-specific helper library

    svDir = WINSYSDISK + "\\";
    
    // Module locations, XNTP - NT location
	svModuleDir = WINDISK^"\\win32app\\ntp";


OfferReadmeFile:

if (AskYesNo("Would you like to see the readme file before proceeding? \n",NO ) = YES) then
	LaunchAppAndWait("NOTEPAD",SUPPORTDIR ^ "README.NT",1);
endif;
	
CheckForService1:
    // Look for service
    if (CheckForService() != 0) then                    // Not clean install
	Disable(BACKBUTTON);
		bUpdateModules = TRUE;
	szMessage = "Setup has determined that the NTP - NT service is\n" +
		    "already present.  Do you want to:\n";
	AskOptions(EXCLUSIVE, szMessage,
                
		   "&Remove NTP service", bRemoveNTP,
		   "&Update NTP to this version", bUpdateModules);
				   
	Enable(BACKBUTTON);
	if (bRemoveNTP) then
		if (AskYesNo("Are you certain you wish to remove the NTP service\n" +
				 "and registry entries? \n",NO ) = YES) then
		   RemoveNTP();
		endif;
	endif;
	if (bUpdateModules) then
			UpdateModules();
	endif;
	exit;
    endif;           
// install drops through

DoCleanInstall:

    // Defaults

    // Create a Welcome dialog.
WelcomeDlg:
    Disable( BACKBUTTON );
    Welcome( "", 0 );
    Enable( BACKBUTTON );
 
    // Test target system for proper configuration.
    CheckRequirements();

ModuleDir:  
    if (AskDestPath("Network Time Protocol Server program file location",
		    "Choose the directory for storage of the NTP support files",
		    svModuleDir,0) = BACK) then
       goto WelcomeDlg;
    endif;
	
ThatsItDoIt:    
    
	InstallNTPFiles(svModuleDir,0);  // uncompress & place files in directories
	
GetConfigurationType:
    Disable(BACKBUTTON);
	TARGETDIR = svModuleDir;                // point back to ntp directory

	SetStatusWindow( 85, "Creating Configuration Files..." );
	DoConfigType();                         // do the configuration for user-spec'd type
    Enable(BACKBUTTON);

RegistryInit:

	SetStatusWindow( 90, "Creating NTP Service..." );
    
CreateService:
        // was svModuleDir^"\\xntpd.exe"
        nReturnValue2 = CallDLLFx(szDllNTPInst,"CreateNTPService",nValue,WINSYSDIR^"\\xntpd.exe");
	if (nReturnValue2 != 0) then
		ReportError(nReturnValue2,szMessage);
		szMessage = "Unable to install NTP - NT Service entry in Service Control Manager.\n" + szMessage;
		MessageBox(szMessage,SEVERE);
		exit;
	endif;


	SetStatusWindow( 95, "Adding Additional Registry Keys..." );

        nReturnValue2 = CallDLLFx(szDllNTPInst,"addKeysToRegistry",nValue,dummy);
	if (nReturnValue2 != 0) then
		szMessage = "Unable to add the Depend on service key in the NT registry\n";
		MessageBox(szMessage,SEVERE);
		exit;
	endif;


	SetStatusWindow( 98, "Starting the Service..." );

StartService:
    nReturnValue2 = CallDLLFx(szDllNTPInst,"StartNTPService",nValue,dummy);
    if (nReturnValue2 != 0) then
		ReportError(nReturnValue2,szMessage);
		szMessage = "Unable to start the NTP - NT Service.\n" + szMessage;
		MessageBox(szMessage,SEVERE);
		exit;
    endif;

   	// Announce setup complete and offer to read README file.e
   	FinalInstallProcess:
   	SetStatusWindow( 100, "Installation complete." );
   	Delay( 2 );

   	if (AskYesNo("Setup is complete.  The NTP service is running.\n"+
				"Do you want to look at the documentation for NTP?\n",
				 YES) = YES) then
	    LaunchAppAndWait("WRITE.EXE",TARGETDIR ^ "ntpog.wri",1);
   	endif;
exit;


/*---------------------------------------------------------------------------*\
 *
 * Function:  InstallNTPFiles()
 *
 *  Purpose:  Uncompress the IShield package, and put files in the directory
 *            passed as an argument.
 *
 *              This function used both for new installations, and for the 
 *              "update modules" function.
 *
\*---------------------------------------------------------------------------*/
function InstallNTPFiles(svInstDir,updateonly)
	NUMBER  nResult;
	STRING szBitmapPath;
begin
	// szBitmapPath = SUPPORTDIR^"ishield.bmp";
	// PlaceBitmap(szBitmapPath,1,10,10,UPPER_RIGHT);

	// Insure that directories have sufficient permissions
	//	ReleaseModuleDirSecurity(svInstDir);
    
	szFileSet = "NetworkTimeProtocolServer";
	FileSetBeginDefine(szFileSet);

	TARGETDIR = WINSYSDIR;
	SetStatusWindow( -1, "Copying modules..." );
    //	MessageBox("decompressing data.z: sourcedir = " + SRCDIR + " target dir = " +
    //                  TARGETDIR,INFORMATION);
    //  change this to comp update date eventually

    if (updateonly != 0)  // update case
    then
	  // uncomment if adding a Control Panel Applet to package
 	  //nResult = CompressGet("data.z","*.cpl",COMP_UPDATE_DATE);
      //if (nResult < 0) then
      //   NumToStr( szTemp, nResult );
	  //   MessageBox("File Decompression1 failed! ecode = " + szTemp, SEVERE);
	  //   exit;
	  // endif;

 	  nResult = CompressGet("data.z","*.exe",COMP_UPDATE_DATE);
      if (nResult < 0) then
         NumToStr( szTemp, nResult );
		 MessageBox("File Decompression2 failed! ecode = " + szTemp, SEVERE);
		 exit;
	  endif;

    else // not update install all
 	  nResult = CompressGet("data.z","*.exe",COMP_UPDATE_DATE);
      if (nResult < 0) then
         NumToStr( szTemp, nResult );
		 MessageBox("File Decompression2 failed! ecode = " + szTemp, SEVERE);
		 exit;
	  endif;

	  TARGETDIR = svInstDir;  // set destination directory

 	  nResult = CompressGet("data.z","readme.nt",COMP_UPDATE_DATE);
      if (nResult < 0) then
         NumToStr( szTemp, nResult );
		 MessageBox("File Decompression3 failed! ecode = " + szTemp, SEVERE);
		 exit;
      endif;

 	  nResult = CompressGet("data.z","ntpog.wri",COMP_UPDATE_DATE);
      if (nResult < 0) then
         NumToStr( szTemp, nResult );
		 MessageBox("File Decompression4 failed! ecode = " + szTemp, SEVERE);
		 exit;
      endif;

    endif; // Decompress File end

	FileSetEndDefine(szFileSet);
	
    // Set up progress indicator and information gauge.
    Disable( DIALOGCACHE );
    Enable( STATUSDLG );

    StatusUpdate( ON, 80 );

    // Perform the file set.
    SetStatusWindow( 0, "Copying program files..." );
    nResult = FileSetPerformEz( szFileSet, 0 );

    switch (nResult)
	    case FS_DONE:      // Successful completion.
	    case FS_CREATEDIR: // Create directory error.
		MessageBox( "Unable to create a directory under " + TARGETDIR + "."+
			"Please check write access to this directory.", SEVERE );
		exit;
	default:               // Group all other errors under default label.
		NumToStr( szTemp, nResult );
		MessageBox( "General file transfer error."+
			"Please check your target location and try again."+
			"\n\n Error Number:"+ szTemp +
			"\n Related File: "+ ERRORFILENAME,SEVERE);
		exit;
    endswitch;
	
	RegisterEventlogMessages(svInstDir);	// put EventLog reg entries in
end;


/*---------------------------------------------------------------------------*\
 *
 * Function:  RegisterEventlogMessages
 *
 *  Purpose:  Put an entry under the Eventlog registry information, so that
 *            it understands where to find messages that come from NTP.
 *
 *  History:  PIW	Created		12/14/95
 *
\*---------------------------------------------------------------------------*/
#define	EVENTLOG_ENTRY "\\SYSTEM\\CurrentControlSet\\Services\\Eventlog\\Application\\NTP"
#define	SERVICE_ENTRY  "\\SYSTEM\\CurrentControlSet\\Services\\NetworkTimeProtocol"

function RegisterEventlogMessages(svTemp)
	NUMBER nvSize;
begin
	RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
	RegDBSetKeyValueEx(EVENTLOG_ENTRY,"EventMessageFile",
				REGDB_STRING,svTemp^"xntpd.exe",nvSize);
	RegDBSetKeyValueEx(EVENTLOG_ENTRY,"TypeSupported",REGDB_NUMBER,"7",nvSize);
end;


/*---------------------------------------------------------------------------*\
 *
 * Function:  DoConfigType
 *
 *  Purpose:  Find out what type of installation the user is planning,
 *            and then create and/or show the configuration files to them.
 *
\*---------------------------------------------------------------------------*/
function DoConfigType()
	BOOL bSingleSourceNTP,bSecondarySourceNTP, bNoSourceNTP;
begin
	bSingleSourceNTP = FALSE;
	bSecondarySourceNTP = TRUE;
	bNoSourceNTP = FALSE;
    szMessage = "For creation of configuration files, please select the setup\n" +
		"you want for NTP.  Do you want to set up a:\n";
    AskOptions(EXCLUSIVE, szMessage,
	       "&Single Time Source", bSingleSourceNTP,
	       "&Two Time Sources", bSecondarySourceNTP,
		   "&Specify No Time Sources", bNoSourceNTP);
			   
    Enable(BACKBUTTON);
    if (bSingleSourceNTP) then
	    szMessage = "Please enter the IP address of the Time Source.\n";
	    AskText(szMessage, svNTPAddress, svNTPAddress);
		CreateConfigFiles(ONETIMESOURCE);   // create ntp.conf
    endif;
	
    if (bSecondarySourceNTP) then
	    szMessage = "Please enter the IP address of the First Time Source from\n" +
		    "which you will RECEIVE synchronization\n";
	    AskText(szMessage, svNTPAddress, svNTPAddress);
		szMessage = "Please enter the IP address of the Second Time Source from\n" +
			"which you will RECEIVE synchronization\n";

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -