Changeset 1856


Ignore:
Timestamp:
23/09/2007 10:18:20 (4 years ago)
Author:
chris
Message:

Use the specified service name when installing and removing the service.

Pass the service name on the service command line, and use it for event
log messages.

Location:
box/chris/general/bin/bbackupd
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • box/chris/general/bin/bbackupd/BackupDaemon.cpp

    r1855 r1856  
    129129        , mInstallService(false), 
    130130          mRemoveService(false), 
    131           mRunAsService(false) 
     131          mRunAsService(false), 
     132          mServiceName("bbackupd") 
    132133        #endif 
    133134{ 
     
    348349        if (mInstallService) 
    349350        { 
    350                 return InstallService(rConfigFileName.c_str()); 
     351                return InstallService(rConfigFileName.c_str(), mServiceName); 
    351352        } 
    352353 
    353354        if (mRemoveService) 
    354355        { 
    355                 return RemoveService(); 
    356         } 
     356                return RemoveService(mServiceName); 
     357        } 
     358 
     359        Logging::SetProgramName("Box Backup (" + mServiceName + ")"); 
    357360 
    358361        int returnCode; 
  • box/chris/general/bin/bbackupd/Win32ServiceFunctions.cpp

    r1853 r1856  
    200200} 
    201201 
    202 int InstallService(const char* pConfigFileName) 
     202int InstallService(const char* pConfigFileName, const std::string& rServiceName) 
    203203{ 
    204204        if (pConfigFileName != NULL) 
     
    236236 
    237237        std::string cmdWithArgs(cmd); 
    238         cmdWithArgs += " -s"; 
     238        cmdWithArgs += " -s -S \"" + rServiceName + "\""; 
    239239 
    240240        if (pConfigFileName != NULL) 
     
    245245        } 
    246246 
     247        std::string serviceDesc = "Box Backup (" + rServiceName + ")"; 
     248 
    247249        SC_HANDLE newService = CreateService( 
    248250                scm,  
    249                 SERVICE_NAME,  
    250                 "Box Backup",  
     251                rServiceName.c_str(), 
     252                serviceDesc.c_str(), 
    251253                SERVICE_ALL_ACCESS,  
    252254                SERVICE_WIN32_OWN_PROCESS,  
     
    313315} 
    314316 
    315 int RemoveService(void) 
     317int RemoveService(const std::string& rServiceName) 
    316318{ 
    317319        SC_HANDLE scm = OpenSCManager(0,0,SC_MANAGER_CREATE_SERVICE); 
     
    324326        } 
    325327 
    326         SC_HANDLE service = OpenService(scm, SERVICE_NAME,  
     328        SC_HANDLE service = OpenService(scm, rServiceName.c_str(),  
    327329                SERVICE_ALL_ACCESS|DELETE); 
    328330        DWORD err = GetLastError(); 
  • box/chris/general/bin/bbackupd/Win32ServiceFunctions.h

    r1853 r1856  
    1313#define WIN32SERVICEFUNCTIONS_H 
    1414 
    15 int RemoveService  (void); 
    16 int InstallService (const char* pConfigFilePath); 
     15int RemoveService  (const std::string& rServiceName); 
     16int InstallService (const char* pConfigFilePath, const std::string& rServiceName); 
    1717int OurService     (const char* pConfigFileName); 
    1818 
Note: See TracChangeset for help on using the changeset viewer.