checkAfsStatusForStartup method modification for search /afs volume for determinate if afs is on has been transfered into checkAfsStatus. checkAfsStatusForStartup method is used to check when afs start axitn system startup. Anyway these are only workaround we must use osx api or afs api to make this job.
Change-Id: If9be5a91418eccc0c58a69b566af140d619d3057
Reviewed-on: http://gerrit.openafs.org/1492
Reviewed-by: Claudio Bisegni <Claudio.Bisegni@lnf.infn.it>
Tested-by: Claudio Bisegni <Claudio.Bisegni@lnf.infn.it>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>
// -------------------------------------------------------------------------------
-(void) setAfsStatus
{
+
BOOL afsIsUp = [afsProperty checkAfsStatus];
- BOOL afsEnabledAtStartup = [afsProperty checkAfsStatusForStartup];
+ BOOL afsEnabledAtStartup = NO;
+
+ NSMutableString *commandOutput = [NSMutableString stringWithCapacity:20];
+ NSString *rootHelperApp = [[self bundle] pathForResource:@"afshlp" ofType:@""];
+
+ // make the parameter to call the root helper app
+ const char *checkAFSDaemonParam[] = {"check_afs_daemon", 0L};
+ if([[AuthUtil shared] autorize] == noErr) {
+ //now disable the launchd configuration
+ [[AuthUtil shared] execUnixCommand:[rootHelperApp UTF8String]
+ args:checkAFSDaemonParam
+ output:commandOutput];
+ afsEnabledAtStartup = [commandOutput rangeOfString:@"afshlp:afs daemon registration result:1"].location!=NSNotFound;
+ }
+
+
+
[((NSButton *)startStopButton) setTitle: (afsIsUp?kAfsButtonShutdown:kAfsButtonStartup)];
#define AFS_DAEMON_STARTUPSCRIPT "/Library/OpenAFS/Tools/root.client/usr/vice/etc/afs.rc"
#define AFS_DAEMON_PATH "/Library/LaunchDaemons/org.openafs.filesystems.afs.plist"
-#define AFS_FS_MOUNT "AFS"
-#define AFS_DAEMON_LAUNCH_PATH "/private/var/db/openafs/etc/launchafs.sh"
+#define AFS_FS_MOUNT "AFS"
+#define AFS_LAUNCHCTL_GREP_STR "org.openafs.filesystems.afs"
/*!
@class AFSPropertyManager
@abstract AFS Manage Class
-(BOOL) checkAfsStatus
{
BOOL result = NO;
- NSString *fsResult = [TaskUtil executeTaskSearchingPath:@"fs" args:[NSArray arrayWithObjects:@"checkserver", nil]];
- result = (fsResult?([fsResult rangeOfString:@"All servers are running."].location != NSNotFound):NO);
+ NSString *dfResult = [TaskUtil executeTaskSearchingPath:@"/bin/df" args:[NSArray arrayWithObjects:nil]];
+ result = (dfResult?([dfResult rangeOfString:@AFS_FS_MOUNT].location != NSNotFound):NO);
return result;
}
// -------------------------------------------------------------------------------
-(BOOL) checkAfsStatusForStartup {
BOOL result = NO;
- NSString *dfResult = [TaskUtil executeTaskSearchingPath:@"/bin/df" args:[NSArray arrayWithObjects:nil]];
- result = (dfResult?([dfResult rangeOfString:@AFS_FS_MOUNT].location != NSNotFound):NO);
+ //NSString *fsResult = [TaskUtil executeTaskSearchingPath:@"launchctl" args:[NSArray arrayWithObjects: @"list", nil]];
+ //result = (fsResult?([fsResult rangeOfString:@AFS_LAUNCHCTL_GREP_STR].location != NSNotFound):NO);
return result;
}
[PListManager launchctlStringCommand:enable?@"load":@"unload"
option:[NSArray arrayWithObjects:@"-w", nil]
plistName:@AFS_DAEMON_PATH];
+ } else if(argc == 2 && [cmdString rangeOfString:@"check_afs_daemon"].location!=NSNotFound) {
+ NSString *fsResult = [TaskUtil executeTaskSearchingPath:@"launchctl" args:[NSArray arrayWithObjects: @"list", nil]];
+ BOOL checkAfsDaemon = (fsResult?([fsResult rangeOfString:@"org.openafs.filesystems.afs"].location != NSNotFound):NO);
+ printf("afshlp:afs daemon registration result:%d",checkAfsDaemon);
}
}