[CalendarServer-changes] [6676] CalendarServer/trunk/contrib/migration/calendarmigrator.py
source_changes at macosforge.org
source_changes at macosforge.org
Wed Dec 8 09:37:27 PST 2010
Revision: 6676
http://trac.macosforge.org/projects/calendarserver/changeset/6676
Author: sagen at apple.com
Date: 2010-12-08 09:37:22 -0800 (Wed, 08 Dec 2010)
Log Message:
-----------
During migration, convert the calendar and addressbook run states from
previous system into EnableCalDAV and EnableCardDAV plist keys.
Modified Paths:
--------------
CalendarServer/trunk/contrib/migration/calendarmigrator.py
Modified: CalendarServer/trunk/contrib/migration/calendarmigrator.py
===================================================================
--- CalendarServer/trunk/contrib/migration/calendarmigrator.py 2010-12-07 19:58:58 UTC (rev 6675)
+++ CalendarServer/trunk/contrib/migration/calendarmigrator.py 2010-12-08 17:37:22 UTC (rev 6676)
@@ -30,7 +30,8 @@
from plistlib import readPlist, writePlist
-LAUNCHD_KEY = "org.calendarserver.calendarserver"
+CALDAV_LAUNCHD_KEY = "org.calendarserver.calendarserver"
+CARDDAV_LAUNCHD_KEY = "org.addressbookserver.addressbookserver"
LOG = "/Library/Logs/Migration/calendarmigrator.log"
SERVICE_NAME = "calendar"
LAUNCHD_OVERRIDES = "var/db/launchd.db/com.apple.launchd/overrides.plist"
@@ -201,8 +202,10 @@
if os.path.exists(options.sourceRoot):
newServerRootValue = migrateData(options)
- migrateConfiguration(options, newServerRootValue)
- migrateRunState(options)
+ enableCalDAV, enableCardDAV = examineRunState(options)
+ migrateConfiguration(options, newServerRootValue, enableCalDAV,
+ enableCardDAV)
+ setRunState(options, enableCalDAV, enableCardDAV)
triggerResourceMigration(newServerRootValue)
else:
@@ -210,23 +213,51 @@
sys.exit(1)
-def migrateRunState(options):
+def examineRunState(options):
"""
- Try to determine whether server was running in previous system, then
- modify the launchd settings in the new system.
+ Try to determine whether the CalDAV and CardDAV services were running in
+ previous system.
+
+ @return: a tuple of booleans: whether CalDAV was enabled, and whether
+ CardDAV was enabled
"""
+ enableCalDAV = False
+ enableCardDAV = False
+
try:
- disabled = isServiceDisabled(options.sourceRoot, LAUNCHD_KEY)
- log("Service '%s' was previously %s" %
- (LAUNCHD_KEY, "disabled" if disabled else "enabled"))
+ disabled = isServiceDisabled(options.sourceRoot, CALDAV_LAUNCHD_KEY)
+ enableCalDAV = not disabled
+ log("Calendar service '%s' was previously %s" %
+ (CALDAV_LAUNCHD_KEY, "disabled" if disabled else "enabled"))
except ServiceStateError, e:
- log("Couldn't determine previous state of service '%s': %s" %
- (LAUNCHD_KEY, e))
- return
+ log("Couldn't determine previous state of calendar service '%s': %s" %
+ (CALDAV_LAUNCHD_KEY, e))
- setServiceStateDisabled(options.targetRoot, LAUNCHD_KEY, disabled)
+ try:
+ disabled = isServiceDisabled(options.sourceRoot, CARDDAV_LAUNCHD_KEY)
+ enableCardDAV = not disabled
+ log("Addressbook service '%s' was previously %s" %
+ (CARDDAV_LAUNCHD_KEY, "disabled" if disabled else "enabled"))
+ except ServiceStateError, e:
+ log("Couldn't determine previous state of addressbook service '%s': %s" %
+ (CARDDAV_LAUNCHD_KEY, e))
+ return (enableCalDAV, enableCardDAV)
+
+
+def setRunState(options, enableCalDAV, enableCardDAV):
+ """
+ Modify the launchd settings in the new system.
+ """
+
+ # Lion has no separate addressbook service, so just worry about caldav:
+ if enableCalDAV or enableCardDAV:
+ setServiceStateDisabled(options.targetRoot, CALDAV_LAUNCHD_KEY, False)
+ else:
+ setServiceStateDisabled(options.targetRoot, CALDAV_LAUNCHD_KEY, True)
+
+
def triggerResourceMigration(newServerRootValue):
"""
Leave a file in the server root to act as a signal that the server
@@ -243,7 +274,7 @@
open(triggerPath, "w").close()
-def migrateConfiguration(options, newServerRootValue):
+def migrateConfiguration(options, newServerRootValue, enableCalDAV, enableCardDAV):
"""
Copy files/directories/symlinks from previous system's /etc/caldavd
and /etc/carddavd
@@ -323,6 +354,9 @@
newCalDAVDPlist["DocumentRoot"] = "Documents"
newCalDAVDPlist["DataRoot"] = "Data"
+ newCalDAVDPlist["EnableCalDAV"] = enableCalDAV
+ newCalDAVDPlist["EnableCardDAV"] = enableCardDAV
+
log("Writing %s" % (newCalDAVDPlistPath,))
writePlist(newCalDAVDPlist, newCalDAVDPlistPath)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20101208/1f60207b/attachment.html>
More information about the calendarserver-changes
mailing list