source: branches/guitools-2.0/shared/cltinit.vrs@ 348

Last change on this file since 348 was 348, checked in by Herwig Bauernfeind, 16 years ago

GUI-Tools: EVFSGUI Version 2.0 beta6 level code

File size: 7.6 KB
Line 
1/* Perform basic Samba Client init stuff */
2
3/*:VRX */
4_CltInit:
5 IF options.!debug == 1 THEN say time()' _CltInit() started'
6 IF options.!debug == 1 THEN say ' Checking Samba Client setup...'
7
8 /* debuglevel when executing Samba binaries */
9 debuglevel = ' --debuglevel=0'
10
11 /* Error status and file variables */
12 ErrorState = 0 /* _ErrorBinaryNotFound() changes this variable */
13 DataErrorState = 0 /* _ErrorDataFileNotFound() changes this variable */
14
15 /* Evaluate environment */
16 ETC = value('ETC',,'OS2ENVIRONMENT')
17 IF options.!debug == 1 THEN say ' ETC = "'ETC'"'
18
19 UnixRoot = value("UNIXROOT",,'OS2ENVIRONMENT')
20 if UnixRoot = "" then do
21 UnixRoot = left(ETC,length(ETC)-4)
22 say ' WARNING! Setting missing UNIXROOT variable to "'UnixRoot'".'
23 ok = value("UNIXROOT",UnixRoot,'OS2ENVIRONMENT')
24 end
25
26 IF options.!debug == 1 THEN say ' UnixRoot = "'UnixRoot'"'
27
28 unixetc = UnixRoot'\etc'
29 IF options.!debug == 1 THEN say ' Unixetc = "'unixetc'"'
30
31 /* Find all executables */
32
33 /* Get the path to this file */
34 samba.!tools = VRParseFilename(VRGet("Application", "Program"),'DP')
35 if samba.!tools = '' then do
36 parse source . . script
37 samba.!tools = VRParseFilename(script,'DP')
38 end
39 IF options.!debug == 1 THEN say ' Samba tools = "'samba.!tools'"'
40 say ' Changing into "'directory(samba.!tools)'"'
41
42 /* smbclient.exe */
43 samba.!smbclientexe = ""
44 if samba.!smbclientexe = "" then do /* in current directory? */
45 call charout , " Are binaries in current directory? "
46 ok = SysFileTree('.\smbclient.exe', exist.,'FO')
47 say exist.0' (1 = Yes, 0 = No)'
48 if exist.0 = 1 then samba.!smbclientexe = exist.1
49 end
50 if samba.!smbclientexe = "" then do /* in parent directory? */
51 call charout , " Are binaries in parent directory? "
52 ok = SysFileTree('..\smbclient.exe', exist.,'FO')
53 say exist.0' (1 = Yes, 0 = No)'
54 if exist.0 = 1 then samba.!smbclientexe = exist.1
55 end
56 if samba.!smbclientexe = "" then do /* in ..\BIN directory? */
57 call charout , " Are binaries in ..\BIN directory? "
58 ok = SysFileTree('..\bin\smbclient.exe', exist.,'FO')
59 say exist.0' (1 = Yes, 0 = No)'
60 if exist.0 = 1 then samba.!smbclientexe = exist.1
61 end
62 if samba.!smbclientexe = "" then do /* in SMB_EXE ? */
63 call charout , " Are binaries in SMB_EXE path? "
64 samba.!smbclientexe = SysSearchPath("SMB_EXE","smbclient.EXE")
65 if samba.!smbclientexe = "" then say "No."; else say "Yes."
66 end
67 if samba.!smbclientexe = "" then do /* in PATH ? */
68 call charout , " Are binaries in PATH? "
69 samba.!smbclientexe = SysSearchPath("PATH","smbclient.EXE")
70 if samba.!smbclientexe = "" then say "No."; else say "Yes."
71 end
72
73 if samba.!smbclientexe = "" then call _ErrorBinaryNotFound " could not find smbclient.exe!"
74
75 samba.!bin = VRParseFileName(samba.!smbclientexe,'DP')
76 IF options.!debug == 1 THEN say ' Samba binaries = "'samba.!bin'"'
77
78 /* net.exe */
79 samba.!netexe = samba.!bin'\net.exe'
80 if \VRFileExists(samba.!netexe) then call _ErrorBinaryNotFound " could not find net.exe!"
81 IF options.!debug == 1 THEN say ' net.exe = "'samba.!netexe'"'
82
83 /* testparm.exe */
84 samba.!testparmexe = samba.!bin'\testparm.exe'
85 if \VRFileExists(samba.!testparmexe) then call _ErrorBinaryNotFound " could not find testparm.exe!"
86 IF options.!debug == 1 THEN say ' testparm.exe = "'samba.!testparmexe'"'
87
88 /* smbtree.exe */
89 samba.!smbtreeexe = samba.!bin'\smbtree.exe'
90 if \VRFileExists(samba.!smbtreeexe) then call _ErrorBinaryNotFound " could not find smbtree.exe!"
91 IF options.!debug == 1 THEN say ' smbtree.exe = "'samba.!smbtreeexe'"'
92
93 /* nmblookup.exe */
94 samba.!nmblookupexe = samba.!bin'\nmblookup.exe'
95 if \VRFileExists(samba.!nmblookupexe) then call _ErrorBinaryNotFound " could not find nmblookup.exe!"
96 IF options.!debug == 1 THEN say ' nmblookup.exe = "'samba.!nmblookupexe'"'
97
98 /* smbspool.exe */
99 samba.!smbspoolexe = samba.!bin'\smbspool.exe'
100 if \VRFileExists(samba.!smbspoolexe) then call _ErrorBinaryNotFound " could not find smbspool.exe!"
101 IF options.!debug == 1 THEN say ' smbspool.exe = "'samba.!smbspoolexe'"'
102
103 /* smb.conf */
104 samba.!smbconf = ETC'\samba\smb.conf'
105 if \VRFileExists(samba.!smbconf) then call _ErrorDataFileNotFound samba.!smbconf' is not present.'
106 IF options.!debug == 1 THEN say ' Samba smb.conf = "'samba.!smbconf'"'
107
108 /* upcase table files - several utilities need these */
109 if (\VRFileExists(samba.!bin'\lib\upcase.dat')) |,
110 (\VRFileExists(samba.!bin'\lib\lowcase.dat')) |,
111 (\VRFileExists(samba.!bin'\lib\valid.dat')) then call _ErrorDataFileNotFound 'upcase table files not present.'
112
113 /* Create these directories to make sure they do exist */
114 ok = SysMkDir(unixetc)
115 ok = SysMkDir(etc'\samba')
116 ok = SysMkDir(etc'\samba\lock')
117
118 /* Messages from Samba will go here */
119 samba.!error = SysTempFileName(TempDir'smb_err.???')
120 samba.!msg = SysTempFileName(TempDir'smb_msg.???')
121 /* Use of this file is deprecated */
122 ErrorFile = Tempdir'smbutil.error'
123
124 IF options.!debug == 1 then do
125 if ErrorState then say " One or more basic Samba Client setup errors detected!"
126 else say " No basic Samba Client setup errors detected!"
127 end
128 IF options.!debug == 1 THEN say time()' _CltInit() done, Errorstate = 'Errorstate
129return
130
131/*:VRX */
132_SambaFinish:
133 /* Do some basic housekeeping when leaving */
134 ok = SysFileTree(TempDir'smb_???.???', garbage., 'FO')
135 do I = 1 to garbage.0
136 ok = stream(garbage.I,'c','close')
137 ok = SysFileDelete(garbage.I)
138 end
139return
140
141/*:VRX */
142_ErrorBinaryNotFound:
143 /* Set error status variable and show a short message - incomplete! */
144 msg = arg(1)
145 say "ERROR: "msg
146 id = VRMessage( VRWindow(), msg, "Samba Client Installation", "E" )
147 ErrorState = (1|ErrorState)
148return
149
150/*:VRX */
151_ErrorDataFileNotFound:
152 /* Set error status variable and show a short message - incomplete! */
153 msg = arg(1)
154 say "ERROR: "msg
155 DataErrorState = (1|DataErrorState)
156return
157
158/*:VRX */
159_SambaExtendSearchPath:
160 IF options.!debug == 1 THEN say time()' _SambaExtendSearchPath() started'
161 /* Add binary and tools path to the PATH variable */
162 old_path = value('PATH',, 'OS2ENVIRONMENT')
163 if pos(translate(samba.!bin';'),translate(old_path)) = 0 then do
164 if samba.!bin = samba.!tools then new_path = samba.!bin';'
165 else new_path = samba.!bin';'samba.!tools';'
166 ok = value('PATH', new_path || old_path, 'OS2ENVIRONMENT')
167 drop new_path
168 end
169 drop old_path
170
171 /* Add binary and tools path to the BEGINLIBPATH variable */
172 old_beginlibpath = SysQueryExtLibPath("B")
173 if pos(translate(samba.!bin';'),translate(old_beginlibpath)) = 0 then do
174 if samba.!bin = samba.!tools then new_beginlibpath = samba.!bin';'old_beginlibpath
175 else new_beginlibpath = samba.!bin';'samba.!tools';'old_beginlibpath
176 ok = SysSetExtLibPath( new_beginlibpath, "B")
177 drop new_beginlibpath
178 end
179 drop old_beginlibpath
180
181 /* Set LIBPATHSTRICT (this is an option - disabled by default) */
182 /* ok = value('LIBPATHSTRICT','T', 'OS2ENVIRONMENT') */
183
184 IF options.!debug == 1 THEN say time()' _SambaExtendSearchPath() done'
185return
Note: See TracBrowser for help on using the repository browser.