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

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

GUI-Tools: EVFSGUI 2.5.x: Support WINS, store credentials

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