source: trunk/guitools/shared/cltinit.vrs@ 675

Last change on this file since 675 was 675, checked in by Herwig Bauernfeind, 14 years ago

GUI-Tools: EVFSGUI 2.5.x: Several fixes and additions (including fix for Ticket #185)

File size: 9.7 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 tools "'directory(samba.!tools)'"'
41
42 /* smbclient.exe */
43 samba.!smbclientexe = ""
44 if samba.!smbclientexe = "" then do /* wellknown locations */
45 WellKnown = sysBootdrive()"\ecs\system\samba;"sysBootdrive()"\samba"
46 Programs = value("PROGRAMS",,'OS2ENVIRONMENT')
47 if Programs <> "" then WellKnown = Wellknown';'Programs'\samba'
48 Tools = value("TOOLS",,'OS2ENVIRONMENT')
49 if Programs <> "" then WellKnown = Wellknown';'Tools'\samba'
50 say Wellknown
51 call charout , " Are binaries in wellknown locations? "
52 ok = VRFindFile("smbclient.exe",WellKnown)
53 if ok <> "" then say "Yes."; else say "No."
54 if ok <> "" then samba.!smbclientexe = ok
55 drop Wellknown
56 end
57 if samba.!smbclientexe = "" then do /* in current directory? */
58 call charout , " Are binaries in current directory? "
59 ok = SysFileTree('.\smbclient.exe', exist.,'FO')
60 if exist.0 = 1 then say "Yes."; else say "No."
61 if exist.0 = 1 then samba.!smbclientexe = exist.1
62 end
63 if samba.!smbclientexe = "" then do /* RPM/YUM/FHS tree */
64 call charout , " Are binaries in RPM/YUM/FHS tree? "
65 ok = SysFileTree(UnixRoot'\usr\bin\smbclient.exe', exist.,'FO')
66 if exist.0 = 1 then say "Yes."; else say "No."
67 if exist.0 = 1 then samba.!smbclientexe = exist.1
68 end
69 if samba.!smbclientexe = "" then do /* in parent directory? */
70 call charout , " Are binaries in parent directory? "
71 ok = SysFileTree('..\smbclient.exe', exist.,'FO')
72 if exist.0 = 1 then say "Yes."; else say "No."
73 if exist.0 = 1 then samba.!smbclientexe = exist.1
74 end
75 if samba.!smbclientexe = "" then do /* in ..\BIN directory? */
76 call charout , " Are binaries in ..\BIN directory? "
77 ok = SysFileTree('..\bin\smbclient.exe', exist.,'FO')
78 if exist.0 = 1 then say "Yes."; else say "No."
79 if exist.0 = 1 then samba.!smbclientexe = exist.1
80 end
81 if samba.!smbclientexe = "" then do /* in SMB_EXE ? */
82 call charout , " Are binaries in SMB_EXE path? "
83 samba.!smbclientexe = SysSearchPath("SMB_EXE","smbclient.EXE")
84 if samba.!smbclientexe = "" then say "No."; else say "Yes."
85 end
86 if samba.!smbclientexe = "" then do /* in PATH ? */
87 call charout , " Are binaries in PATH? "
88 samba.!smbclientexe = SysSearchPath("PATH","smbclient.EXE")
89 if samba.!smbclientexe = "" then say "No."; else say "Yes."
90 end
91
92 if samba.!smbclientexe = "" then call _ErrorBinaryNotFound " could not find smbclient.exe!"
93
94 samba.!bin = VRParseFileName(samba.!smbclientexe,'DP')
95 IF options.!debug == 1 THEN say ' Samba binaries = "'samba.!bin'"'
96
97 /* net.exe */
98 samba.!netexe = samba.!bin'\net.exe'
99 if \VRFileExists(samba.!netexe) then call _ErrorBinaryNotFound " could not find net.exe!"
100 IF options.!debug == 1 THEN say ' net.exe = "'samba.!netexe'"'
101
102 /* testparm.exe */
103 samba.!testparmexe = samba.!bin'\testparm.exe'
104 if \VRFileExists(samba.!testparmexe) then call _ErrorBinaryNotFound " could not find testparm.exe!"
105 IF options.!debug == 1 THEN say ' testparm.exe = "'samba.!testparmexe'"'
106
107 /* smbtree.exe */
108 samba.!smbtreeexe = samba.!bin'\smbtree.exe'
109 if \VRFileExists(samba.!smbtreeexe) then call _ErrorBinaryNotFound " could not find smbtree.exe!"
110 IF options.!debug == 1 THEN say ' smbtree.exe = "'samba.!smbtreeexe'"'
111
112 /* nmblookup.exe */
113 samba.!nmblookupexe = samba.!bin'\nmblookup.exe'
114 if \VRFileExists(samba.!nmblookupexe) then call _ErrorBinaryNotFound " could not find nmblookup.exe!"
115 IF options.!debug == 1 THEN say ' nmblookup.exe = "'samba.!nmblookupexe'"'
116
117 /* smbspool.exe */
118 samba.!smbspoolexe = samba.!bin'\smbspool.exe'
119 if \VRFileExists(samba.!smbspoolexe) then call _ErrorBinaryNotFound " could not find smbspool.exe!"
120 IF options.!debug == 1 THEN say ' smbspool.exe = "'samba.!smbspoolexe'"'
121
122 /* rpcclient.exe */
123 samba.!rpcclientexe = samba.!bin'\rpcclient.exe'
124 if \VRFileExists(samba.!rpcclientexe) then call _ErrorBinaryNotFound " could not find rpcclient.exe!"
125 IF options.!debug == 1 THEN say ' rpcclient.exe = "'samba.!rpcclientexe'"'
126
127 /* smb.conf */
128 samba.!smbconf = ETC'\samba\smb.conf'
129 if \VRFileExists(samba.!smbconf) then call _ErrorDataFileNotFound samba.!smbconf' is not present.'
130 IF options.!debug == 1 THEN say ' Samba smb.conf = "'samba.!smbconf'"'
131
132 /* complete shadow copy of smb.conf in temporary directory - should always be created on the fly */
133 /* before reading from it */
134 samba.!shadowsmbconf = TempDir||'smb.conf'
135
136 /* lmhosts */
137 samba.!lmhosts = ETC'\samba\lmhosts'
138 if \VRFileExists(samba.!lmhosts) then call _ErrorDataFileNotFound samba.!lmhosts' is not present.'
139 IF options.!debug == 1 THEN say ' Samba lmhosts = "'samba.!lmhosts'"'
140
141 /* FIXME: Needs to be changed for Samba 3.3+ */
142 /* upcase table files - several utilities need these */
143 if (\VRFileExists(samba.!bin'\lib\upcase.dat')) |,
144 (\VRFileExists(samba.!bin'\lib\lowcase.dat')) |,
145 (\VRFileExists(samba.!bin'\lib\valid.dat')) then call _ErrorDataFileNotFound 'upcase table files not present.'
146
147 /* Create these directories to make sure they do exist */
148 ok = SysMkDir(unixetc)
149 ok = SysMkDir(etc'\samba')
150 ok = SysMkDir(etc'\samba\pid')
151 ok = SysMkDir(etc'\samba\lock')
152 /* This EA makes the testparm warning about browsing go away. */
153 /* Note: The EA is NOT marked critical as it should be, neverthelesse this fix works */
154 ok = SysPutEA(etc||'\samba\lock',"MODE", "FEFF0400ED410000"x)
155
156 /* Messages from Samba will go here */
157 samba.!error = SysTempFileName(TempDir'smb_err.???')
158 IF options.!debug == 1 THEN say ' samba.!error = "'samba.!error'"'
159 samba.!msg = SysTempFileName(TempDir'smb_msg.???')
160 IF options.!debug == 1 THEN say ' samba.!msg = "'samba.!msg'"'
161 /* Use of this file is deprecated */
162 ErrorFile = Tempdir'smbutil.error'
163
164 IF options.!debug == 1 then do
165 if ErrorState then say " One or more basic Samba Client setup errors detected!"
166 else say " No basic Samba Client setup errors detected!"
167 end
168 IF options.!debug == 1 THEN say time()' _CltInit() done, Errorstate = 'Errorstate
169return
170
171/*:VRX */
172_SambaFinish:
173 /* Do some basic housekeeping when leaving */
174 ok = SysFileTree(TempDir'smb_???.???', garbage., 'FO')
175 do I = 1 to garbage.0
176 ok = stream(garbage.I,'c','close')
177 ok = SysFileDelete(garbage.I)
178 end
179return
180
181/*:VRX */
182_ErrorBinaryNotFound:
183 /* Set error status variable and show a short message - incomplete! */
184 msg = arg(1)
185 say "ERROR: "msg
186 id = VRMessage( VRWindow(), msg, "Samba Client Installation", "E" )
187 ErrorState = (1|ErrorState)
188return
189
190/*:VRX */
191_ErrorDataFileNotFound:
192 /* Set error status variable and show a short message - incomplete! */
193 msg = arg(1)
194 say "ERROR: "msg
195 DataErrorState = (1|DataErrorState)
196return
197
198/*:VRX */
199_SambaExtendSearchPath:
200 IF options.!debug == 1 THEN say time()' _SambaExtendSearchPath() started'
201 /* Add binary and tools path to the PATH variable */
202 old_path = value('PATH',, 'OS2ENVIRONMENT')
203 if pos(translate(samba.!bin';'),translate(old_path)) = 0 then do
204 if samba.!bin = samba.!tools then new_path = samba.!bin';'
205 else new_path = samba.!bin';'samba.!tools';'
206 ok = value('PATH', new_path || old_path, 'OS2ENVIRONMENT')
207 drop new_path
208 end
209 drop old_path
210
211 /* Add binary and tools path to the BEGINLIBPATH variable */
212 old_beginlibpath = SysQueryExtLibPath("B")
213 if pos(translate(samba.!bin';'),translate(old_beginlibpath)) = 0 then do
214 if samba.!bin = samba.!tools then new_beginlibpath = samba.!bin';'old_beginlibpath
215 else new_beginlibpath = samba.!bin';'samba.!tools';'old_beginlibpath
216 ok = SysSetExtLibPath( new_beginlibpath, "B")
217 drop new_beginlibpath
218 end
219 drop old_beginlibpath
220
221 /* Set LIBPATHSTRICT (this is an option - disabled by default) */
222 /* ok = value('LIBPATHSTRICT','T', 'OS2ENVIRONMENT') */
223
224 IF options.!debug == 1 THEN say time()' _SambaExtendSearchPath() done'
225return
Note: See TracBrowser for help on using the repository browser.