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

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

GUI-Tools: Added EVFSGUI 2.0.3

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