OSX Launchd Startup Manage with Preference Pane
[openafs.git] / src / platform / DARWIN / AFSPreference / AFSPropertyManager.h
1 //
2 //  AFSPropertyManager.h
3 //  AFSCommander
4 //
5 //  Created by Claudio Bisegni on 21/05/07.
6 //  Copyright 2007 INFN - National Institute of Nuclear Physics. All rights reserved.
7 //
8
9 #import <Cocoa/Cocoa.h>
10 #import "DBCellElement.h"
11 #import "FileUtil.h"
12
13
14 #define AFS_DAEMON_STARTUPSCRIPT        "/Library/OpenAFS/Tools/root.client/usr/vice/etc/afs.rc"
15 #define AFS_DAEMON_PATH                         "/Library/LaunchDaemons/org.openafs.filesystems.afs.plist"
16 #define AFS_DAEMON_LAUNCH_PATH          "/private/var/db/openafs/etc/launchafs.sh"
17 /*!
18     @class              AFSPropertyManager
19     @abstract   AFS Manage Class
20     @discussion This class manage the openafs param for celldbserv, cache param, group creation, get and release token
21 */
22
23 @interface AFSPropertyManager : NSObject {
24         NSString *installationPath;
25         NSString *cellName;
26         NSMutableArray *cellList;
27         NSArray *userDefaultCellArray;
28         NSString *afsRootMountPoint;
29         int statCacheEntry;
30         int dCacheDim;
31         int     cacheDimension;
32         int daemonNumber;
33         int nVolEntry;
34         bool dynRoot;
35         bool afsDB;
36         bool verbose;
37         
38         //-------------------
39         FileUtil *futil;
40         BOOL useAfsdConfVersion;
41 }
42
43 /*!
44     @method     
45     @abstract   (brief description)
46     @discussion (comprehensive description)
47 */
48 -(id) init;
49
50 /*!
51 @function       initWithAfsPath
52  @abstract   (description)
53  @discussion (description)
54  @param      path Path di installazione afs
55  @result     Istanza della classe di gestione delle propieta' afs
56  */
57 - (id)initWithAfsPath:(NSString*)path;
58
59 /*!
60     @method     
61     @abstract   (brief description)
62     @discussion (comprehensive description)
63 */
64 -(void) dealloc;
65 /*!
66  @method     
67  @abstract   (brief description)
68  @discussion (comprehensive description)
69  */
70 -(NSMutableArray*) getCellList;
71
72
73 /*!
74  @method     
75  @abstract   (brief description)
76  @discussion (comprehensive description)
77  */
78 -(NSArray*) getAllCellsName;
79 /*!
80  @method     
81  @abstract   (brief description)
82  @discussion (comprehensive description)
83  */
84 -(NSArray*) getUserDefaultForTokenCells;
85 /*!
86  @method     
87  @abstract   (brief description)
88  @discussion (comprehensive description)
89  */
90 -(NSArray*) getDefaultForTokenCellsName;
91 /*!
92  @method     
93  @abstract   (brief description)
94  @discussion (comprehensive description)
95  */
96 -(NSString*) getDefaultCellName;
97
98 /*!
99  @method     setDefaultCellByName
100  @abstract   set the cell named "name" to be se user default
101  @discussion first clean the last one selected as default and then  set the cell named "name" as default user cell
102  */
103 -(void) setDefaultCellByName:(NSString*)name;
104
105 /*!
106  @method     
107  @abstract   (brief description)
108  @discussion (comprehensive description)
109  */- (void) setCellName:(NSString*)cell;
110
111 /*!
112     @method     setPath
113     @abstract   Imposta Path
114     @discussion Imposta il path dove e' installato afs, in modo da leggere e scrivere le configurazioni
115 */
116 -(void) setPath:(NSString*)path;
117
118 /*!
119     @method     path
120     @abstract   Return the afs base
121     @discussion Return the Afs base installation path
122 */
123 -(NSString*) path;
124
125 /*!
126  @function       statCacheEntry
127  @abstract   get the afs number of state cache entry
128  @discussion 
129  @result     Number of stat cache entry
130  */
131 -(int) statCacheEntry;
132
133
134 /*!
135  @function       setStatCacheEntry
136  @abstract   Set the afs number of state cache entry
137  @discussion 
138  @result     Number of stat cache entry
139  */
140 -(void) setStatCacheEntry:(int)statEntry;
141
142 /*!
143 @function       dCacheDim
144 @abstract   return the dCacheDim param value for cache manager
145 @result     dCacheDim value
146 */
147 -(int) dCacheDim;
148
149 /*!
150  @function       setDCacheDim
151  @abstract   set the setDCacheDim value for cache manager param
152  @discussion <#(description)#>
153  @param      dcacheDim cache param value
154  */
155 -(void) setDCacheDim:(int)dcacheDim;
156
157 /*!
158  @function       cacheDimension
159  @abstract   return the max size of the cache 
160  @result     Cache  dimension
161  */
162 -(int) cacheDimension;
163
164 /*!
165  @function      setCacheDimension
166  @abstract   Set the max cache dimension
167  @discussion 
168  @param      cacheDim MAx Chace dimension
169  */
170 -(void) setCacheDimension:(int)cacheDim;
171
172 /*!
173  @function       daemonNumber
174  @abstract   Return the number of daemon for the cache manager
175  @result     Number of daemon
176  */
177 -(int) daemonNumber;
178
179 /*!
180  @function       setDaemonNumber
181  @abstract   Set the daemon numbero for the cache manager
182  @param      dNumber number of daemon
183  */
184 -(void) setDaemonNumber:(int)dNumber;
185
186 /*!
187  @function       afsRootMountPoint
188  @abstract   Return the path where afs root volume will be mounted
189  @result     AFS mount point
190  */
191 -(NSString*) afsRootMountPoint;
192
193 /*!
194  @function       setAfsRootMountPoint
195  @abstract   Set the AFS mount point
196  @param      mountPoint AFS mount point
197  */
198 -(void) setAfsRootMountPoint:(NSString*)mountPoint;
199
200 /*!
201  @function       nVolEntry
202  @abstract   Return the nVolEntry for cache manager
203  @result     value for nVolEntry cache parameter
204  */
205 -(int) nVolEntry;
206
207 /*!
208  @function       setNVolEntry
209  @abstract   Set the nVolEntry parameter for cache manager
210  @param      entry value for nVolEntry cache manager parameter
211  */
212 -(void) setNVolEntry:(int)entry;
213
214 /*!
215  @function       dynRoot
216  @abstract   Return the DynRoot parametr for cache manager
217  @result     dynRoot parameter value
218  */
219 -(bool) dynRoot;
220
221 /*!
222  @function       setDynRoot
223  @abstract   Set the DynRoot flag value for cache manager
224  @param      flag dynRoot state (enable/disable)
225  */
226 -(void) setDynRoot:(bool)flag;
227 /*!
228  @function       afsDB
229  @abstract   Get the afsdb flag value for cache manager
230  @result     Return the value of the flag
231  */
232 -(bool) afsDB;
233
234 /*!
235  @function       setAfsDB
236  @abstract   Set the flag value for afsdb cache manager
237  @param      flag AfsDB state (enable/disable)
238  */
239 -(void) setAfsDB:(bool)flag;
240 /*!
241  @function       verbose
242  */
243 -(bool) verbose;
244
245 /*!
246  @function       setVerbose
247  */
248 -(void) setVerbose:(bool)flag;
249 /*!
250  @function       readCacheInfo
251  @abstract   Read the cache info
252  @discussion The cache info is read from the file pointed by filePath param
253  @param      filePath file location for the CacheInfo
254  */
255 -(void) readCacheInfo:(NSString*)filePath;
256
257 /*!
258  @function       writeCacheInfo
259  @abstract   Write the cache info down the file
260  @param      filePath where to write the CacheInfo
261  @result     return the execution error
262  */
263 -(int) writeCacheInfo:(NSString*)filePath;
264
265 /*!
266  @function       readAfsdOption
267  @abstract   Read the afs option
268  @discussion Read the afs option checking firt the afs version so it can read the old afsd.option or afs.conf file. If any error accour an NSException wil be trown
269  @param      filePath file where the parameter are store for default afsd.option or afs.conf
270  */
271 -(void) readAfsdOption:(NSString*)filePath;
272
273 /*!
274  @function       readOldAfsdOption
275  @abstract   Read the afsd.option file
276  @discussion Read the old afsd.option style afsd option file. If any error accour an NSException wil be trown22
277  @param      filePath file path to afsd.option like file
278  @result     <#(description)#>
279  */
280 -(void) readOldAfsdOption:(NSString*)filePath;
281 /*!
282  @function       readAFSDParamLineContent
283  @abstract   Try to decode one line of afsd.option or afs.conf
284  @param      paramLine one line of file afsd.option(the only one that is present) os afs.conf
285  */
286 -(void) readAFSDParamLineContent:(NSString*)paramLine;
287 /*!
288  @function       readNewAfsdOption
289  @abstract   Read the new afs.conf file format
290  @discussion Scann every line f the afs.conf file ad for each one call the readAFSDParamLineContent with it's content
291  @param      filePath path of the new file with afs.conf file format
292  */
293 -(void) readNewAfsdOption:(NSString*)filePath;
294 /*!
295  @function       writeAfsdOption
296  @abstract   <#(description)#>
297  @discussion <#(description)#>
298  @param      <#(name) (description)#>
299  @result     <#(description)#>
300  */
301 -(int) writeAfsdOption:(NSString*)filePath;
302 /*!
303  @function       writeOldAfsdOption
304  @abstract   Write the cache manager parameter to file
305  @discussion First chech the version of afs installed then choice to save old o new file version(afsd.option or afs.conf)
306  @param      filePath file path for file to write into
307  @result     <#(description)#>
308  */
309 -(int) writeOldAfsdOption:(NSString*)filePath;
310 /*!
311  @function       writeNewAfsdOption
312  @abstract   Write the cache parameter to a file with the new format
313  @param      filePath file path where write into
314  */
315 -(int) writeNewAfsdOption:(NSString*)filePath;
316 /*!
317  @function       getAfsVersion
318  @abstract   Return the string representing the afs version
319  @result     The Enteir string returned from the call of fs -version
320  */
321 -(NSString*) getAfsVersion;
322 /*!
323  @function       getAfsMajorVersionVersion
324  @abstract   Return the major version of afs Major.x.x
325  @result     
326  */
327 -(int) getAfsMajorVersionVersion;
328 /*!
329  @function       getAfsMinorVersionVersion
330  @abstract   Return the major version of afs x.Minor.x
331  @result     
332  */
333 -(int) getAfsMinorVersionVersion;
334
335 /*!
336  @function       getAfsPatchVersionVersion
337  @abstract   Return the major version of afs x.x.Patch
338  @result     
339  */
340 -(int) getAfsPatchVersionVersion;
341
342 /*!
343  @method     clearConfiguration
344  @abstract   Clear all structure or array that contain value for afs client setting(cells cache param etch)
345  @discussion 
346          */
347 -(void) clearConfiguration;
348
349 /*!
350  @function       exceptionOnInvalidPath
351  @abstract   Check the validity of afs path
352  @discussion If the installationPath variable don't point to a valid path, will be fired an NSException
353  */
354 -(void) exceptionOnInvalidPath;
355
356 /*!
357     @method     loadConfiguration
358     @abstract   load the all afs configuration (ThisCell & CellServDB & cache parameter)
359 */
360 -(void) loadConfiguration;
361
362 /*!
363     @method     readCellInfo
364     @abstract   Read the Main Cell Name
365 */
366 -(void) readCellInfo:(NSString*) configFile;
367 /*!
368     @method     readCellDB
369     @abstract   Read the CellServDB File
370     @discussion Read the file of all cellservbd ad make the NSArray containing a DBCellElement for aech cell found
371 */
372 -(void) readCellDB:(NSString*) configFile;
373 /*!
374     @function   readTheseCell
375     @abstract   Read the "These Cell"
376     @discussion Read the "These Cell" file that contains all the cell from which the user want to get the token
377     @param      configFile TheseCell file path
378     @result     NSAray with the cells name
379 */
380 -(NSArray*) readTheseCell:(NSString*) configFile;
381 /*!
382     @method     shutdown
383     @abstract   Stop The AFS
384 */
385 -(void) shutdown;
386 -(void) startup;
387 -(void) scanIpForCell:(DBCellElement*) cellElement allIP:(NSString*)allIP;
388 -(void) backupConfigurationFiles;
389 -(void) backupFile:(NSString*)localAfsFilePath;
390 -(void) saveConfigurationFiles:(BOOL) makeBackup;
391 -(void) saveCacheConfigurationFiles:(BOOL) makeBackup;
392 -(void) installConfigurationFile:(NSString*)srcConfFile destPath:(NSString*) destPath;
393 -(NSArray*) getTokenList;
394 -(BOOL) checkAfsStatus;
395 -(BOOL) checkAfsStatusForStartup;
396 -(void) klog:(NSString*)uName uPwd:(NSString*)uPwd  cell:(NSString*)theCell;
397 -(void) aklog:(NSString*)theCell noKerberosCall:(BOOL)krb5CallEnable;
398 -(void) getTokens:(BOOL)klogAklogFlag usr:(NSString*)usr pwd:(NSString*)pwd;
399 -(void) unlog:(NSString*)cell;
400 -(NSString*) makeChaceParamString;
401 -(BOOL) useAfsdConfConfigFile;
402 @end