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

Last change on this file since 614 was 410, checked in by Herwig Bauernfeind, 15 years ago

GUI-Tools: Latest EVFSGUI changes

File size: 8.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 /* 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 /* upcase table files - several utilities need these */
127 if (\VRFileExists(samba.!bin'\lib\upcase.dat')) |,
128 (\VRFileExists(samba.!bin'\lib\lowcase.dat')) |,
129 (\VRFileExists(samba.!bin'\lib\valid.dat')) then call _ErrorDataFileNotFound 'upcase table files not present.'
130
131 /* Create these directories to make sure they do exist */
132 ok = SysMkDir(unixetc)
133 ok = SysMkDir(etc'\samba')
134 ok = SysMkDir(etc'\samba\lock')
135
136 /* Messages from Samba will go here */
137 samba.!error = SysTempFileName(TempDir'smb_err.???')
138 IF options.!debug == 1 THEN say ' samba.!error = "'samba.!error'"'
139 samba.!msg = SysTempFileName(TempDir'smb_msg.???')
140 IF options.!debug == 1 THEN say ' samba.!msg = "'samba.!msg'"'
141 /* Use of this file is deprecated */
142 ErrorFile = Tempdir'smbutil.error'
143
144 IF options.!debug == 1 then do
145 if ErrorState then say " One or more basic Samba Client setup errors detected!"
146 else say " No basic Samba Client setup errors detected!"
147 end
148 IF options.!debug == 1 THEN say time()' _CltInit() done, Errorstate = 'Errorstate
149return
150
151/*:VRX */
152_SambaFinish:
153 /* Do some basic housekeeping when leaving */
154 ok = SysFileTree(TempDir'smb_???.???', garbage., 'FO')
155 do I = 1 to garbage.0
156 ok = stream(garbage.I,'c','close')
157 ok = SysFileDelete(garbage.I)
158 end
159return
160
161/*:VRX */
162_ErrorBinaryNotFound:
163 /* Set error status variable and show a short message - incomplete! */
164 msg = arg(1)
165 say "ERROR: "msg
166 id = VRMessage( VRWindow(), msg, "Samba Client Installation", "E" )
167 ErrorState = (1|ErrorState)
168return
169
170/*:VRX */
171_ErrorDataFileNotFound:
172 /* Set error status variable and show a short message - incomplete! */
173 msg = arg(1)
174 say "ERROR: "msg
175 DataErrorState = (1|DataErrorState)
176return
177
178/*:VRX */
179_SambaExtendSearchPath:
180 IF options.!debug == 1 THEN say time()' _SambaExtendSearchPath() started'
181 /* Add binary and tools path to the PATH variable */
182 old_path = value('PATH',, 'OS2ENVIRONMENT')
183 if pos(translate(samba.!bin';'),translate(old_path)) = 0 then do
184 if samba.!bin = samba.!tools then new_path = samba.!bin';'
185 else new_path = samba.!bin';'samba.!tools';'
186 ok = value('PATH', new_path || old_path, 'OS2ENVIRONMENT')
187 drop new_path
188 end
189 drop old_path
190
191 /* Add binary and tools path to the BEGINLIBPATH variable */
192 old_beginlibpath = SysQueryExtLibPath("B")
193 if pos(translate(samba.!bin';'),translate(old_beginlibpath)) = 0 then do
194 if samba.!bin = samba.!tools then new_beginlibpath = samba.!bin';'old_beginlibpath
195 else new_beginlibpath = samba.!bin';'samba.!tools';'old_beginlibpath
196 ok = SysSetExtLibPath( new_beginlibpath, "B")
197 drop new_beginlibpath
198 end
199 drop old_beginlibpath
200
201 /* Set LIBPATHSTRICT (this is an option - disabled by default) */
202 /* ok = value('LIBPATHSTRICT','T', 'OS2ENVIRONMENT') */
203
204 IF options.!debug == 1 THEN say time()' _SambaExtendSearchPath() done'
205return
Note: See TracBrowser for help on using the repository browser.