[CalendarServer-changes] [14694] CalendarServer/trunk/calendarserver
source_changes at macosforge.org
source_changes at macosforge.org
Tue Apr 21 15:54:54 PDT 2015
Revision: 14694
http://trac.calendarserver.org//changeset/14694
Author: sagen at apple.com
Date: 2015-04-21 15:54:54 -0700 (Tue, 21 Apr 2015)
Log Message:
-----------
Server won't start if ServerRoot is on a phantom volume
Modified Paths:
--------------
CalendarServer/trunk/calendarserver/tap/util.py
CalendarServer/trunk/calendarserver/tools/diagnose.py
Modified: CalendarServer/trunk/calendarserver/tap/util.py
===================================================================
--- CalendarServer/trunk/calendarserver/tap/util.py 2015-04-21 17:03:42 UTC (rev 14693)
+++ CalendarServer/trunk/calendarserver/tap/util.py 2015-04-21 22:54:54 UTC (rev 14694)
@@ -32,6 +32,7 @@
from calendarserver.provision.root import RootResource
from calendarserver.push.applepush import APNSubscriptionResource
from calendarserver.push.notifier import NotifierFactory
+from calendarserver.tools import diagnose
from calendarserver.tools.util import checkDirectory
from calendarserver.webadmin.landing import WebAdminLandingResource
from calendarserver.webcal.resource import WebCalendarResource
@@ -1201,6 +1202,9 @@
success, reason = verifyConfig(config)
if success:
+ success, reason = verifyServerRoot(config)
+
+ if success:
success, reason = verifyTLSCertificate(config)
if success:
@@ -1240,7 +1244,21 @@
return False, "Neither CalDAV nor CardDAV are enabled"
+def verifyServerRoot(config):
+ """
+ Ensure server root is not on a phantom volume
+ """
+ result = diagnose.detectPhantomVolume(config.ServerRoot)
+ if result == diagnose.EXIT_CODE_SERVER_ROOT_MISSING:
+ return False, "ServerRoot is missing"
+
+ if result == diagnose.EXIT_CODE_PHANTOM_DATA_VOLUME:
+ return False, "ServerRoot is supposed to be on a non-boot-volume but it's not"
+
+ return True, "ServerRoot is ok"
+
+
def verifyTLSCertificate(config):
"""
If a TLS certificate is configured, make sure it exists, is non empty,
Modified: CalendarServer/trunk/calendarserver/tools/diagnose.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/diagnose.py 2015-04-21 17:03:42 UTC (rev 14693)
+++ CalendarServer/trunk/calendarserver/tools/diagnose.py 2015-04-21 22:54:54 UTC (rev 14694)
@@ -71,6 +71,7 @@
optargs, _ignore_args = getopt(
sys.argv[1:], "h", [
"help",
+ "phantom",
],
)
except GetoptError, e:
@@ -84,7 +85,11 @@
if opt in ("-h", "--help"):
usage()
+ elif opt == "--phantom":
+ result = detectPhantomVolume()
+ sys.exit(result)
+
osBuild = getOSBuild()
print("OS Build: {}".format(osBuild))
@@ -105,6 +110,14 @@
serverRoot = getServerRoot()
print("Prefs plist says ServerRoot directory is: {}".format(serverRoot.encode("utf-8")))
+ result = detectPhantomVolume(serverRoot)
+ if result == EXIT_CODE_OK:
+ print("ServerRoot volume ok")
+ elif result == EXIT_CODE_SERVER_ROOT_MISSING:
+ print("ServerRoot directory missing")
+ elif result == EXIT_CODE_PHANTOM_DATA_VOLUME:
+ print("Phantom ServerRoot volume detected")
+
systemPlist = os.path.join(serverRoot, "Config", "caldavd-system.plist")
try:
if checkPlist(systemPlist):
@@ -156,7 +169,32 @@
showWebApps()
+EXIT_CODE_OK = 0
+EXIT_CODE_SERVER_ROOT_MISSING = 1
+EXIT_CODE_PHANTOM_DATA_VOLUME = 2
+def detectPhantomVolume(serverRoot=None):
+ """
+ Check to see if serverRoot directory exists in a "phantom" volume, meaning
+ it's simply a directory under /Volumes residing on the boot volume, rather
+ that a real separate volume.
+ """
+
+ if not serverRoot:
+ serverRoot = getServerRoot()
+
+ if not os.path.exists(serverRoot):
+ return EXIT_CODE_SERVER_ROOT_MISSING
+
+ if serverRoot.startswith("/Volumes/"):
+ bootDevice = os.stat("/").st_dev
+ dataDevice = os.stat(serverRoot).st_dev
+ if bootDevice == dataDevice:
+ return EXIT_CODE_PHANTOM_DATA_VOLUME
+
+ return EXIT_CODE_OK
+
+
def showProcesses():
print()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20150421/bfa95dcc/attachment.html>
More information about the calendarserver-changes
mailing list