[CalendarServer-changes] [7080] CalendarServer/trunk/contrib/migration/calendarmigrator.py

source_changes at macosforge.org source_changes at macosforge.org
Thu Feb 24 17:59:43 PST 2011


Revision: 7080
          http://trac.macosforge.org/projects/calendarserver/changeset/7080
Author:   sagen at apple.com
Date:     2011-02-24 17:59:42 -0800 (Thu, 24 Feb 2011)
Log Message:
-----------
Unload calendar service while processing migrated config.

Modified Paths:
--------------
    CalendarServer/trunk/contrib/migration/calendarmigrator.py

Modified: CalendarServer/trunk/contrib/migration/calendarmigrator.py
===================================================================
--- CalendarServer/trunk/contrib/migration/calendarmigrator.py	2011-02-24 20:21:46 UTC (rev 7079)
+++ CalendarServer/trunk/contrib/migration/calendarmigrator.py	2011-02-25 01:59:42 UTC (rev 7080)
@@ -44,6 +44,7 @@
 NEW_SERVER_ROOT = "/Library/Server/Calendar and Contacts"
 RESOURCE_MIGRATION_TRIGGER = "trigger_resource_migration"
 SERVER_ADMIN = "/usr/sbin/serveradmin"
+LAUNCHCTL = "/bin/launchctl"
 
 
 verbatimKeys = """
@@ -203,8 +204,16 @@
     if options.sourceRoot:
 
         if os.path.exists(options.sourceRoot):
+
+            # If calendar service was running on previous system
+            # turn it off while we process configuration.  There
+            # is no need to turn off addressbook because it no longer
+            # has its own launchd plist.
+            enableCalDAV, enableCardDAV = examineRunState(options)
+            if enableCalDAV:
+                unloadService(options, CALDAV_LAUNCHD_KEY)
+
             newServerRootValue = migrateData(options)
-            enableCalDAV, enableCardDAV = examineRunState(options)
             migrateConfiguration(options, newServerRootValue, enableCalDAV,
                 enableCardDAV)
 
@@ -260,6 +269,17 @@
         log("serveradmin exited with %d" % (ret,))
 
 
+def unloadService(options, service):
+    """
+    Use launchctl to unload a service
+    """
+    path = os.path.join(options.targetRoot, LAUNCHD_PREFS_DIR,
+                        "%s.plist" % (service,))
+    log("Unloading %s via launchctl" % (path,))
+    ret = subprocess.call([LAUNCHCTL, "unload", "-w", path])
+    log("launchctl exited with %d" % (ret,))
+
+
 def triggerResourceMigration(newServerRootValue):
     """
     Leave a file in the server root to act as a signal that the server
@@ -418,7 +438,6 @@
     raise ServiceStateError("Neither %s nor %s exist" %
         (overridesPath, prefsPath))
 
-
 def setServiceStateDisabled(target, service, disabled):
     """
     Modifies launchd settings for a service
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110224/4ba82a38/attachment.html>


More information about the calendarserver-changes mailing list