1 | #!/bin/bash
|
---|
2 |
|
---|
3 | #####################################################################
|
---|
4 | ##
|
---|
5 | ## smb.conf parser class
|
---|
6 | ##
|
---|
7 | ## Copyright (C) Kurt Pfeifle <kpfeifle@danka.de>, 2004.
|
---|
8 | ##
|
---|
9 | ## This program is free software; you can redistribute it and/or modify
|
---|
10 | ## it under the terms of the GNU General Public License as published by
|
---|
11 | ## the Free Software Foundation; either version 2 of the License, or
|
---|
12 | ## (at your option) any later version.
|
---|
13 | ##
|
---|
14 | ## This program is distributed in the hope that it will be useful,
|
---|
15 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
16 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
17 | ## GNU General Public License for more details.
|
---|
18 | ##
|
---|
19 | ## You should have received a copy of the GNU General Public License
|
---|
20 | ## along with this program; if not, write to the Free Software
|
---|
21 | ## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
22 | ##
|
---|
23 | ######################################################################
|
---|
24 |
|
---|
25 | ######################################################################
|
---|
26 | ## Here an example calling sequence
|
---|
27 | ##!/bin/sh
|
---|
28 | ## set -x
|
---|
29 | ## source VampireDriversFunctions
|
---|
30 |
|
---|
31 | ##
|
---|
32 | ## Start local variables
|
---|
33 | ##
|
---|
34 | ## You must define these variable (possibly in a source script)
|
---|
35 |
|
---|
36 | ## nthost=192.168.17.1
|
---|
37 | ## printeradmin=Administrator
|
---|
38 | ## adminpasswd=not4you
|
---|
39 |
|
---|
40 | ## smbhost=knoppix
|
---|
41 | ## smbprinteradmin=knoppix
|
---|
42 | ## smbadminpasswd=knoppix
|
---|
43 | ##
|
---|
44 | ## End of local variables
|
---|
45 | ##
|
---|
46 |
|
---|
47 | ##
|
---|
48 | ## functions to call
|
---|
49 | ##
|
---|
50 |
|
---|
51 | ## fetchenumdrivers3listfromNThost # repeat, if no success at first
|
---|
52 | ## createdrivernamelist
|
---|
53 | ## createprinterlistwithUNCnames # repeat, if no success at first
|
---|
54 | ## createmapofprinterstodriver
|
---|
55 | ## splitenumdrivers3list
|
---|
56 | ## makesubdirsforWIN40driverlist
|
---|
57 | ## splitWIN40fileintoindividualdriverfiles
|
---|
58 | ## fetchtheWIN40driverfiles
|
---|
59 | ## uploadallWIN40drivers
|
---|
60 | ## makesubdirsforW32X86driverlist
|
---|
61 | ## splitW32X86fileintoindividualdriverfiles
|
---|
62 | ## fetchtheW32X86driverfiles
|
---|
63 | ## uploadallW32X86drivers
|
---|
64 |
|
---|
65 | ## End of example calling sequence
|
---|
66 | ######################################################################
|
---|
67 |
|
---|
68 |
|
---|
69 | # -----------------------------------------------------------------------------
|
---|
70 | # -----------------------------------------------------------------------------
|
---|
71 | function vampiredrivers_readme()
|
---|
72 | {
|
---|
73 | echo -e " \n\
|
---|
74 | ############################################################################
|
---|
75 | #
|
---|
76 | # About the \"Vampire Printer Drivers\" set of functions....
|
---|
77 | # --------------------------------------------------------
|
---|
78 | #
|
---|
79 | # (C) Kurt Pfeifle <kpfeifle@danka.de>, 2004
|
---|
80 | # License: GPL
|
---|
81 | #
|
---|
82 | # ------------------------------------------------------------
|
---|
83 | #
|
---|
84 | # Version: 0.8 (largely \"self-documented\" now, but not yet
|
---|
85 | # completely -- if it ever will be....)
|
---|
86 | #
|
---|
87 | # Thanks a lot to Fabian Franz for helping me with some important
|
---|
88 | # Bash-Scripting-Questions!
|
---|
89 | #
|
---|
90 | # This set of functions provides a framework to snatch all printer
|
---|
91 | # driver info and related files from a Windows NT print server.
|
---|
92 | # It then uploads and installs the drivers to a Samba server. (The
|
---|
93 | # Samba server needs to be prepared for this: a valid [print$]
|
---|
94 | # share, with write access set for a \"printer admin\".)
|
---|
95 | #
|
---|
96 | # The main commands used are \"smbclient\" and \"rpcclient\" combined
|
---|
97 | # with \"grep\", \"sed\" and \"awk\". Probably a Perl or Python script
|
---|
98 | # would be better suited to do this, mainly because we have to cope
|
---|
99 | # with printer and driver names which are containing spaces in
|
---|
100 | # them, so a lot of shell escaping is required to handle these.
|
---|
101 | # Also, I am not very savvy in scripting, so I invented some very
|
---|
102 | # obscure methods to work around my knowledge gaps. When I download
|
---|
103 | # the driver files from the Windows NT box, I put all related driver
|
---|
104 | # files into their own sub directory, using the same name as the
|
---|
105 | # driver. Also, driver versions \"0\", \"2\" and \"3\" are placed in
|
---|
106 | # further subdirectories.
|
---|
107 | #
|
---|
108 | #
|
---|
109 | # Known problems:
|
---|
110 | # ---------------
|
---|
111 | #
|
---|
112 | # 1) I found one printer driver containing a \"slash\" which is not
|
---|
113 | # handled by this script: \"HP Color LaserJet 5/5M PS\". (There
|
---|
114 | # are more of these in the wild, of course.) -- The reason: I
|
---|
115 | # didn't find a way to create a Unix directory containing a \"slash\".
|
---|
116 | # UPDATE: The script replaces the \"/\" with a \"_\" and also renames
|
---|
117 | # the drivername accordingly, when it is uploaded to the Samba
|
---|
118 | # [print$] share....
|
---|
119 | #
|
---|
120 | # 2) There is an unsolved problem in case a real file name deviates
|
---|
121 | # in its case sensitive spelling from how it is displayed by the
|
---|
122 | # \"rpcclient enumdrivers\" command. I encountered cases where
|
---|
123 | # rpcclient displayed \"PS5UI.DLL\" as a file name, but \"smbclient
|
---|
124 | # mget\" retrieved \"ps5ui.dll\" from the NT printserver, and the
|
---|
125 | # driverinstallation failed because \"smbclient mput\" tried to put
|
---|
126 | # \"PS5UI.DLL\" back onto the Samba server where UNIX only had
|
---|
127 | # \"ps5ui.dll\" available (which of course failed). -- UPDATE: this
|
---|
128 | # is now solved. All files are renamed now to the same
|
---|
129 | # case-sensitive spelling as \"rpcclient ... enumdrivers 3\"
|
---|
130 | # announces. This includes renaming into both, uppercase or
|
---|
131 | # lowercase, as the case might be....
|
---|
132 | #
|
---|
133 | # 3) This script is probably not portable at all and relies on lots
|
---|
134 | # of Bash-isms.
|
---|
135 | #
|
---|
136 | # 4) This script runs with rpcclient from Samba-3.0.2a (or later) only
|
---|
137 | # (because it uses the \"Version\" parameter for \"adddriver\").
|
---|
138 | #
|
---|
139 | # The following functions use a few external variables to log
|
---|
140 | # into the 2 hosts. We suggest that you create a file which
|
---|
141 | # contains the variables and that you source that file at the
|
---|
142 | # beginning of this script...
|
---|
143 | #
|
---|
144 | # #################################################################
|
---|
145 | #
|
---|
146 | # ntprinteradmin=Administrator # any account on the NT host
|
---|
147 | # # with \"printer admin\" privileges
|
---|
148 | # ntadminpasswd=not4you # the \"printer admin\" password on
|
---|
149 | # # the NT print server
|
---|
150 | # nthost=windowsntprintserverbox # the netbios name of the NT print
|
---|
151 | # # server
|
---|
152 | #
|
---|
153 | # smbprinteradmin=knoppix # an account on the Samba server
|
---|
154 | # # with \"printer admin\" privileges
|
---|
155 | # smbadminpasswd=2secret4you # the \"printer admin\" password on
|
---|
156 | # # the Samba server
|
---|
157 | # smbhost=knoppix # the netbios name of the Samba
|
---|
158 | # # print server
|
---|
159 | #
|
---|
160 | # #################################################################
|
---|
161 | #
|
---|
162 | #
|
---|
163 | # NOTE: these functions also work for 2 NT print servers: snatch all
|
---|
164 | # drivers from the first, and upload them to the second server (which
|
---|
165 | # takes the role of the \"Samba\" server). Of course they also work
|
---|
166 | # for 2 Samba servers: snatch all drivers from the first (which takes
|
---|
167 | # the role of the NT print server) and upload them to the second....
|
---|
168 | #
|
---|
169 | #
|
---|
170 | # ............PRESS \"q\" TO QUIT............" \
|
---|
171 | |less
|
---|
172 | }
|
---|
173 |
|
---|
174 |
|
---|
175 | #set -x
|
---|
176 |
|
---|
177 |
|
---|
178 | # -----------------------------------------------------------------------------
|
---|
179 | # ----------- print a little help... ------------------------------------------
|
---|
180 | # -----------------------------------------------------------------------------
|
---|
181 |
|
---|
182 | function helpwithvampiredrivers()
|
---|
183 | {
|
---|
184 | if stringinstring help $@ ; then
|
---|
185 | helpwithvampiredrivers ;
|
---|
186 | else
|
---|
187 | echo " ";
|
---|
188 | echo " 1. Run the functions of this script one by one.";
|
---|
189 | echo " ";
|
---|
190 | echo " 2. List all functions with the \"enumallfunctions\" call.";
|
---|
191 | echo " ";
|
---|
192 | echo " 3. After each functions' run, check if it completed successfully.";
|
---|
193 | echo " ";
|
---|
194 | echo " 4. For each function, you can ask for separate help by typing";
|
---|
195 | echo " \"<functionname> --help\"."
|
---|
196 | echo " ";
|
---|
197 | echo " 5. Often network conditions prevent the MS-RPC calls"
|
---|
198 | echo " implemented by Samba to succeed at the first attempt."
|
---|
199 | echo " You may have more joy if you try more than once or twice....";
|
---|
200 | echo " ";
|
---|
201 | echo " 6. I can not support end-users who have problems with this script."
|
---|
202 | echo " However, we are available for paid, professional consulting,"
|
---|
203 | echo " training and troubleshooting work.";
|
---|
204 | echo " ";
|
---|
205 | echo " ";
|
---|
206 | fi
|
---|
207 | }
|
---|
208 |
|
---|
209 | # -----------------------------------------------------------------------------
|
---|
210 | # ----------- enumerate all builtin functions... ------------------------------
|
---|
211 | # -----------------------------------------------------------------------------
|
---|
212 | function enumallfunctions()
|
---|
213 | {
|
---|
214 | if stringinstring help $@ ; then
|
---|
215 | helpwithvampiredrivers ;
|
---|
216 | else
|
---|
217 | echo " "
|
---|
218 | echo " "
|
---|
219 | echo "--> Running now function enumallfunctions()..."
|
---|
220 | echo "=============================================="
|
---|
221 | echo -e " \n\
|
---|
222 |
|
---|
223 | NOTE: run the listed functions in the same order as listed below.
|
---|
224 |
|
---|
225 | EXAMPLE: \"knoppix@ttyp6[knoppix]$ helpwithvampiredrivers\"
|
---|
226 |
|
---|
227 | HELP: the \"--help\" parameter prints usage hints regarding a function.
|
---|
228 |
|
---|
229 | EXAMPLE: \"knoppix@ttyp6[knoppix]$ fetchenumdrivers3listfromNThost --help\"
|
---|
230 |
|
---|
231 |
|
---|
232 | function vampiredrivers_readme()
|
---|
233 | function enumallfunctions()
|
---|
234 | function helpwithvampiredrivers()
|
---|
235 | function fetchenumdrivers3listfromNThost() # repeat, if no success at first
|
---|
236 | function createdrivernamelist()
|
---|
237 | function createprinterlistwithUNCnames() # repeat, if no success at first
|
---|
238 | function createmapofprinterstodrivers()
|
---|
239 | function splitenumdrivers3list()
|
---|
240 | function makesubdirsforW32X86driverlist()
|
---|
241 | function splitW32X86fileintoindividualdriverfiles()
|
---|
242 | function fetchallW32X86driverfiles()
|
---|
243 | function uploadallW32X86drivers()
|
---|
244 | function makesubdirsforWIN40driverlist()
|
---|
245 | function splitWIN40fileintoindividualdriverfiles()
|
---|
246 | function fetchallWIN40driverfiles()
|
---|
247 | function uploadallWIN40drivers()"
|
---|
248 | echo " "
|
---|
249 | fi
|
---|
250 | }
|
---|
251 |
|
---|
252 | # this is a helperfunction (Thanks to Fabian Franz!)
|
---|
253 | function stringinstring()
|
---|
254 | {
|
---|
255 | case "$2" in *$1*)
|
---|
256 | return 0
|
---|
257 | ;;
|
---|
258 | esac
|
---|
259 | return 1
|
---|
260 | }
|
---|
261 |
|
---|
262 | # -----------------------------------------------------------------------------
|
---|
263 | # ----------- Create an "enumprinters 3" list --------------------- -----------
|
---|
264 | # -----------------------------------------------------------------------------
|
---|
265 | #
|
---|
266 |
|
---|
267 | function helpwithfetchenumdrivers3listfromNThost()
|
---|
268 | {
|
---|
269 | echo -e " \n\
|
---|
270 | ################################################################################
|
---|
271 | #
|
---|
272 | # About fetchenumdrivers3listfromNThost()....
|
---|
273 | # -------------------------------------------
|
---|
274 | #
|
---|
275 | # PRECONDITIONS: 1) This function expects write access to the current directory.
|
---|
276 | # 2) This function expects to have the '\$nthosts',
|
---|
277 | # '\$ntprinteradmin' and '\$ntadminpasswd' variables set to
|
---|
278 | # according values.
|
---|
279 | #
|
---|
280 | # WHAT IT DOES: This function connects to the '\$nthost' (using the credentials
|
---|
281 | # '\$ntprinteradmin' with '\$ntadminpasswd', retrieves a list of
|
---|
282 | # drivers (with related file names) from that host, and saves the
|
---|
283 | # list under the name of '\${nthost}/enumdrivers3list.txt' (ie. it
|
---|
284 | # also creates the '\$nthost' subdirectory in the current one). It
|
---|
285 | # further prints some more info to stdout.
|
---|
286 | #
|
---|
287 | # IF IT DOESN'T WORK: It may happen that the function doesn't work at the first
|
---|
288 | # time (there may be a connection problem). Just repeat a
|
---|
289 | # few times. It may work then. You will recognize if it
|
---|
290 | # does.
|
---|
291 | #
|
---|
292 | # HINT: The current values: 'nthost'=\"$nthost\"
|
---|
293 | # 'ntprinteradmin'=\"$ntprinteradmin\"
|
---|
294 | # 'ntadminpasswd'=<not shown here, check yourself!>
|
---|
295 | #
|
---|
296 | ################################################################################"
|
---|
297 | echo " "
|
---|
298 | }
|
---|
299 |
|
---|
300 | # -----------------------------------------------------------------------------
|
---|
301 |
|
---|
302 | function fetchenumdrivers3listfromNThost()
|
---|
303 | {
|
---|
304 | if stringinstring help $@ ; then
|
---|
305 | helpwithfetchenumdrivers3listfromNThost;
|
---|
306 | else
|
---|
307 | echo " "
|
---|
308 | echo " "
|
---|
309 | echo "--> Running now function fetchenumdrivers3listfromNThost"
|
---|
310 | echo "========================================================"
|
---|
311 | [ -d ${nthost} ] || mkdir "${nthost}";
|
---|
312 | rpcclient -U${ntprinteradmin}%${ntadminpasswd} -c 'enumdrivers 3' ${nthost} \
|
---|
313 | | sed -e '/^.*Driver Name: \[.*\]/ y/\//_/' \
|
---|
314 | | tee \
|
---|
315 | ${nthost}/enumdrivers3list.txt;
|
---|
316 |
|
---|
317 | NUMBEROFDIFFERENTDRIVERNAMES=$( grep "Driver Name:" ${nthost}/enumdrivers3list.txt \
|
---|
318 | | sort -f \
|
---|
319 | | uniq \
|
---|
320 | | wc -l );
|
---|
321 |
|
---|
322 | echo " ";
|
---|
323 | echo "--> Finished in running function fetchenumdrivers3listfromNThost....";
|
---|
324 | echo "===================================================================="
|
---|
325 | echo "NUMBEROFDIFFERENTDRIVERNAMES retrieved from \"${nthost}\" is $NUMBEROFDIFFERENTDRIVERNAMES".;
|
---|
326 | echo " --> If you got \"0\" you may want to try again. <---";
|
---|
327 | echo "================================================================";
|
---|
328 | echo " ";
|
---|
329 | enumdrivers3list=`cat ${nthost}/enumdrivers3list.txt`;
|
---|
330 | fi
|
---|
331 | }
|
---|
332 |
|
---|
333 |
|
---|
334 | # -----------------------------------------------------------------------------
|
---|
335 | # ----------- Create a list of all available drivers installed ----------------
|
---|
336 | # ------------------------on the NT print server-------------------------------
|
---|
337 | # -----------------------------------------------------------------------------
|
---|
338 | #
|
---|
339 |
|
---|
340 | function helpwithcreatedrivernamelist()
|
---|
341 | {
|
---|
342 | echo -e " \n\
|
---|
343 | ################################################################################
|
---|
344 | #
|
---|
345 | # About createdrivernamelist()...
|
---|
346 | # -------------------------------
|
---|
347 | #
|
---|
348 | # PRECONDITIONS: 1) This function expects to find the subdirectory '\$nthost'
|
---|
349 | # and the file '\${nthost}/enumdrivers3list.txt' to exist.
|
---|
350 | # 2) This function expects to have the '\$nthosts' variable set
|
---|
351 | # to an according value.
|
---|
352 | #
|
---|
353 | # WHAT IT DOES: This function dissects the '\${nthost}/enumdrivers3list.txt'
|
---|
354 | # and creates other textfiles from its contents:
|
---|
355 | # - '\${nthost}/drvrlst.txt'
|
---|
356 | # - '\${nthost}/completedriverlist.txt'
|
---|
357 | # and further prints some more info to stdout.
|
---|
358 | #
|
---|
359 | # HINT: The current value: 'nthost'=\"$nthost\"
|
---|
360 | #
|
---|
361 | ################################################################################"
|
---|
362 | }
|
---|
363 |
|
---|
364 | # -----------------------------------------------------------------------------
|
---|
365 |
|
---|
366 | function createdrivernamelist()
|
---|
367 | {
|
---|
368 | if stringinstring help $@ ; then
|
---|
369 | helpwithcreatedrivernamelist;
|
---|
370 | else
|
---|
371 | echo " ";
|
---|
372 | echo " ";
|
---|
373 | echo "--> Running now function createdrivernamelist....";
|
---|
374 | echo "=================================================";
|
---|
375 | cat ${nthost}/enumdrivers3list.txt \
|
---|
376 | | grep "Driver Name:" \
|
---|
377 | | awk -F "[" '{ print $2 }' \
|
---|
378 | | awk -F "]" '{ print $1 }' \
|
---|
379 | | sort -f \
|
---|
380 | | uniq \
|
---|
381 | | tr / _ \
|
---|
382 | | sed -e 's/$/\"/' -e 's/^ */\"/' \
|
---|
383 | | tee \
|
---|
384 | ${nthost}/drvrlst.txt;
|
---|
385 | drvrlst=$(echo ${nthost}/drvrlst.txt);
|
---|
386 |
|
---|
387 | cat ${nthost}/enumdrivers3list.txt \
|
---|
388 | | grep "Driver Name:" \
|
---|
389 | | awk -F "[" '{ print $2 }' \
|
---|
390 | | awk -F "]" '{ print $1 }' \
|
---|
391 | | sort -f \
|
---|
392 | | uniq \
|
---|
393 | | sed -e 's/$/\"/' \
|
---|
394 | | cat -n \
|
---|
395 | | sed -e 's/^ */DRIVERNAME/' -e 's/\t/\="/' \
|
---|
396 | | tee \
|
---|
397 | ${nthost}/completedriverlist.txt;
|
---|
398 |
|
---|
399 | NUMBEROFDRIVERS=`cat ${nthost}/completedriverlist.txt| wc -l`;
|
---|
400 | echo " ";
|
---|
401 | echo "--> Finished in running function createdrivernamelist....";
|
---|
402 | echo "==============================================================================="
|
---|
403 | echo "NUMBEROFDRIVERS retrieve-able from \"${nthost}\" is $NUMBEROFDRIVERS".;
|
---|
404 | echo " --> If you got \"0\" you may want to run \"fetchenumdrivers3listfromNThost\""
|
---|
405 | echo " again. <---";
|
---|
406 | echo "===============================================================================";
|
---|
407 | echo " ";
|
---|
408 | driverlist=`cat ${nthost}/completedriverlist.txt`;
|
---|
409 |
|
---|
410 | # alternative method suggested by Fabian Franz:
|
---|
411 | # | awk 'BEGIN {n=1} { print "DRIVERNAME"n"=\""$0"\""; n=n+1 } '
|
---|
412 | fi
|
---|
413 | }
|
---|
414 |
|
---|
415 |
|
---|
416 |
|
---|
417 | # -----------------------------------------------------------------------------
|
---|
418 | # ----------- Create a list of all available printers -------------------------
|
---|
419 | # -----------------------------------------------------------------------------
|
---|
420 | #
|
---|
421 |
|
---|
422 | function helpwithcreateprinterlistwithUNCnames()
|
---|
423 | {
|
---|
424 | echo -e " \n\
|
---|
425 | ################################################################################
|
---|
426 | #
|
---|
427 | # About createprinterlistwithUNCnames()...
|
---|
428 | # ----------------------------------------
|
---|
429 | #
|
---|
430 | # PRECONDITIONS: 1) This function expects write access to the current directory.
|
---|
431 | # 2) This function expects to have the '\$nthost',
|
---|
432 | # '\$ntprinteradmin' and '\$ntadminpasswd' variables set to
|
---|
433 | # according values.
|
---|
434 | #
|
---|
435 | # WHAT IT DOES: This function connects to the '\$nthost' (using the credentials
|
---|
436 | # '\$ntprinteradmin' with '\$ntadminpasswd'), retrieves a list of
|
---|
437 | # printqueues (with associated driver names) from that host (with
|
---|
438 | # the help of the 'rpcclient ... enumprinters' utility, and saves
|
---|
439 | # it under name and path '\${nthost}/printerlistwithUNCnames.txt'
|
---|
440 | # (ie. it also creates the '\$nthost' subdirectory in the current
|
---|
441 | # one). It further prints some more info to stdout.
|
---|
442 | #
|
---|
443 | # IF IT DOESN'T WORK: It may happen that the function doesn't work at the first
|
---|
444 | # time (there may be a connection problem). Just repeat a
|
---|
445 | # few times. It may work then. You will recognize if it does.
|
---|
446 | #
|
---|
447 | # HINT: The current values: 'nthost'=\"$nthost\"
|
---|
448 | # 'ntprinteradmin'=\"$ntprinteradmin\"
|
---|
449 | # 'ntadminpasswd'=<not shown here, check yourself!>
|
---|
450 | #
|
---|
451 | ################################################################################"
|
---|
452 | }
|
---|
453 |
|
---|
454 | # -----------------------------------------------------------------------------
|
---|
455 |
|
---|
456 | function createprinterlistwithUNCnames()
|
---|
457 | {
|
---|
458 | if stringinstring help $@ ; then
|
---|
459 | helpwithcreateprinterlistwithUNCnames ;
|
---|
460 | else
|
---|
461 | [ -d ${nthost} ] || mkdir -p ${nthost};
|
---|
462 | echo " "
|
---|
463 | echo " "
|
---|
464 | echo " "
|
---|
465 | echo "--> Running now function createprinterlistwithUNCnames()...."
|
---|
466 | echo "============================================================"
|
---|
467 | rpcclient -U"${ntprinteradmin}%${ntadminpasswd}" -c 'enumprinters' ${nthost} \
|
---|
468 | | grep "description:" \
|
---|
469 | | awk -F "[" '{ print $2 }' \
|
---|
470 | | awk -F "]" '{ print $1 }' \
|
---|
471 | | sort -f \
|
---|
472 | | uniq \
|
---|
473 | | tee \
|
---|
474 | ${nthost}/printerlistwithUNCnames.txt;
|
---|
475 |
|
---|
476 | NUMBEROFPRINTERS=`cat ${nthost}/printerlistwithUNCnames.txt| wc -l`;
|
---|
477 | echo " ";
|
---|
478 | echo "--> Finished in running function createprinterlistwithUNCnames....";
|
---|
479 | echo "=========================================================================="
|
---|
480 | echo "NUMBEROFPRINTERS retrieved from \"${nthost}\" is $NUMBEROFPRINTERS".;
|
---|
481 | echo " --> If you got \"0\" you may want to try again. <---";
|
---|
482 | echo "==========================================================================";
|
---|
483 | echo " ";
|
---|
484 | printerlistwithUNCnames=`cat ${nthost}/printerlistwithUNCnames.txt`;
|
---|
485 | fi
|
---|
486 | }
|
---|
487 |
|
---|
488 |
|
---|
489 | # -----------------------------------------------------------------------------
|
---|
490 | # ----------- Create a list of all printers which have (no) drivers -----------
|
---|
491 | # -----------------------------------------------------------------------------
|
---|
492 | #
|
---|
493 |
|
---|
494 | function helpwithcreatemapofprinterstodrivers()
|
---|
495 | {
|
---|
496 | echo -e " \n\
|
---|
497 | ################################################################################
|
---|
498 | #
|
---|
499 | # About createmapofprinterdrivers()...
|
---|
500 | # ------------------------------------
|
---|
501 | #
|
---|
502 | # PRECONDITIONS: 1) This function expects to find a subdirectory '\$nthost' and
|
---|
503 | # the file '\${nthost}/printerlistwithUNCnames.txt' to exist.
|
---|
504 | # 2) This functions expects to have the '\$nthosts' variable set
|
---|
505 | # to an according value.
|
---|
506 | #
|
---|
507 | # WHAT IT DOES: This function dissects '\${nthost}/printerlistwithUNCnames.txt'
|
---|
508 | # and creates some other textfiles from its contents:
|
---|
509 | # - '\${nthost}/allprinternames.txt'
|
---|
510 | # - '\${nthost}/alldrivernames.txt'
|
---|
511 | # - '\${nthost}/allnonrawprinters.txt'
|
---|
512 | # - '\${nthost}/allrawprinters.txt'
|
---|
513 | # - '\${nthost}/printertodrivermap.txt'
|
---|
514 | # and further prints some more info to stdout.
|
---|
515 | #
|
---|
516 | # HINT: You currently have defined: 'nthost'=\"$nthost\", which resolves above
|
---|
517 | # mentioned paths to:
|
---|
518 | # - '${nthost}/allprinternames.txt'
|
---|
519 | # - '${nthost}/alldrivernames.txt'
|
---|
520 | # - '${nthost}/allnonrawprinters.txt'
|
---|
521 | # - '${nthost}/allrawprinters.txt'
|
---|
522 | # - '${nthost}/printertodrivermap.txt'
|
---|
523 | #
|
---|
524 | ################################################################################"
|
---|
525 | }
|
---|
526 |
|
---|
527 | # -----------------------------------------------------------------------------
|
---|
528 |
|
---|
529 | function createmapofprinterstodrivers()
|
---|
530 | {
|
---|
531 | if stringinstring help $@ ; then
|
---|
532 | helpwithcreatemapofprinterstodrivers ;
|
---|
533 | else
|
---|
534 | echo " "
|
---|
535 | echo " "
|
---|
536 | echo "--> Running now function createmapofprinterstodrivers()...."
|
---|
537 | echo "==========================================================="
|
---|
538 | echo " "
|
---|
539 | echo " "
|
---|
540 | echo "ALL PRINTERNAMES:"
|
---|
541 | echo "================="
|
---|
542 | echo " "
|
---|
543 | cat ${nthost}/printerlistwithUNCnames.txt \
|
---|
544 | | awk -F "\\" '{ print $4 }' \
|
---|
545 | | awk -F "," '{print $1}' \
|
---|
546 | | sort -f \
|
---|
547 | | uniq \
|
---|
548 | | tee \
|
---|
549 | ${nthost}/allprinternames.txt;
|
---|
550 |
|
---|
551 | echo " "
|
---|
552 | echo " "
|
---|
553 | echo "ALL non-RAW PRINTERS:"
|
---|
554 | echo "====================="
|
---|
555 | echo " "
|
---|
556 | cat ${nthost}/printerlistwithUNCnames.txt \
|
---|
557 | | grep -v ",," \
|
---|
558 | | awk -F "\\" '{ print $4 }' \
|
---|
559 | | awk -F "," '{print $1}' \
|
---|
560 | | sort -f \
|
---|
561 | | uniq \
|
---|
562 | | tee \
|
---|
563 | ${nthost}/allnonrawprinters.txt;
|
---|
564 |
|
---|
565 | echo " "
|
---|
566 | echo " "
|
---|
567 | echo "ALL RAW PRINTERS:"
|
---|
568 | echo "================"
|
---|
569 | echo " "
|
---|
570 | cat ${nthost}/printerlistwithUNCnames.txt \
|
---|
571 | | grep ",," \
|
---|
572 | | awk -F "\\" '{ print $4 }' \
|
---|
573 | | awk -F "," '{print $1}' \
|
---|
574 | | sort -f \
|
---|
575 | | uniq \
|
---|
576 | | tee \
|
---|
577 | ${nthost}/allrawprinters.txt;
|
---|
578 |
|
---|
579 | echo " "
|
---|
580 | echo " "
|
---|
581 | echo "THE DRIVERNAMES:"
|
---|
582 | echo "================"
|
---|
583 | cat ${nthost}/printerlistwithUNCnames.txt \
|
---|
584 | | awk -F "," '{print $2 }' \
|
---|
585 | | grep -v "^$" \
|
---|
586 | | tee \
|
---|
587 | ${nthost}/alldrivernames.txt;
|
---|
588 |
|
---|
589 | echo " "
|
---|
590 | echo " "
|
---|
591 | echo "THE PRINTER-TO-DRIVER-MAP-FOR-non-RAW-PRINTERS:"
|
---|
592 | echo "==============================================="
|
---|
593 | cat ${nthost}/printerlistwithUNCnames.txt \
|
---|
594 | | awk -F "\\" '{ print $4 }' \
|
---|
595 | | awk -F "," '{ print "\"" $1 "\":\"" $2 "\"" }' \
|
---|
596 | | grep -v ":\"\"$" \
|
---|
597 | | tee \
|
---|
598 | ${nthost}/printertodrivermap.txt
|
---|
599 | echo -e "##########################\n# printer:driver #" >> ${nthost}/printertodrivermap.txt
|
---|
600 | fi
|
---|
601 | }
|
---|
602 |
|
---|
603 |
|
---|
604 | # -----------------------------------------------------------------------------
|
---|
605 | # ----------- Create a list of all printers which have drivers ----------------
|
---|
606 | # -----------------------------------------------------------------------------
|
---|
607 | #
|
---|
608 |
|
---|
609 | function helpwithgetdrivernamelist()
|
---|
610 | {
|
---|
611 | echo -e " \n\
|
---|
612 | ################################################################################
|
---|
613 | #
|
---|
614 | # About getdrivernamelist()...
|
---|
615 | # ----------------------------
|
---|
616 | #
|
---|
617 | # PRECONDITIONS: 1) This function expects to find the subdirectory '\$nthost\'
|
---|
618 | # otherwise it creates it...
|
---|
619 | #
|
---|
620 | # WHAT IT DOES: This function creates the '\${nthost}/printernamelist.txt'
|
---|
621 | # and also prints it to <stdout>. To do so, it must contact the
|
---|
622 | # '\$nthost' via rpcclient (which in turn needs '\$ntprinteradmin'
|
---|
623 | # '\$ntadminpasswd' to log in....).
|
---|
624 | #
|
---|
625 | # HINT: The current values: 'nthost'=\"$nthost\"
|
---|
626 | # 'ntprinteradmin'=\"$ntprinteradmin\"
|
---|
627 | # 'ntadminpasswd'=<not shown here, check yourself!>
|
---|
628 | # which resolves above mentioned path to:
|
---|
629 | # - '${nthost}/printernamelist.txt'
|
---|
630 | #
|
---|
631 | ################################################################################"
|
---|
632 | }
|
---|
633 |
|
---|
634 | # -----------------------------------------------------------------------------
|
---|
635 |
|
---|
636 | function getdrivernamelist()
|
---|
637 | {
|
---|
638 | if stringinstring $@ ; then
|
---|
639 | helpwithgetdrivernamelist ;
|
---|
640 | else
|
---|
641 | [ -d ${nthost} ] || mkdir -p ${nthost};
|
---|
642 | echo " "
|
---|
643 | echo " "
|
---|
644 | echo "--> Running now function getdrivernamelist()...."
|
---|
645 | echo "================================================"
|
---|
646 | rpcclient -U${ntprinteradmin}%${ntadminpasswd} -c 'enumprinters' ${nthost} \
|
---|
647 | | grep "description:" \
|
---|
648 | | grep -v ",," \
|
---|
649 | | awk -F "," '{ print $2 }' \
|
---|
650 | | sort -f \
|
---|
651 | | uniq \
|
---|
652 | | tee \
|
---|
653 | ${nthost}/drivernamelist.txt
|
---|
654 | fi
|
---|
655 | }
|
---|
656 |
|
---|
657 |
|
---|
658 | # -----------------------------------------------------------------------------
|
---|
659 | # ----------- Split the driverfile listing between the architectures ----------
|
---|
660 | # -----------------------------------------------------------------------------
|
---|
661 | #
|
---|
662 |
|
---|
663 | function helpwithsplitenumdrivers3list()
|
---|
664 | {
|
---|
665 | echo -e " \n\
|
---|
666 | ################################################################################
|
---|
667 | #
|
---|
668 | # About splitenumdrivers3list()...
|
---|
669 | # --------------------------------
|
---|
670 | #
|
---|
671 | # PRECONDITIONS: 1) This function expects write access to the current directory
|
---|
672 | # and its subdirs '\$nthost/*'.
|
---|
673 | # 2) This function expects to have the '\$nthost' variable set to
|
---|
674 | # the according value.
|
---|
675 | #
|
---|
676 | # WHAT IT DOES: This function dissects the '\$nthost/enumdrivers3list.txt'
|
---|
677 | # (using "sed", "cat", "awk" and "grep"). It splits the list up
|
---|
678 | # into two different files representing a complete list of drivers
|
---|
679 | # and files for each of the 2 supported architectures. It creates
|
---|
680 | # '\${nthost}/W32X86/${nthost}-enumdrivers3list-NTx86.txt'
|
---|
681 | # and '\${nthost}/WIN40/${nthost}-enumdrivers3list-WIN40.txt'.
|
---|
682 | #
|
---|
683 | # IF IT DOESN'T WORK: The function "fetchenumdrivers3listfromNThost" may not
|
---|
684 | # have been run successfully. This is a precondition for
|
---|
685 | # the current function.
|
---|
686 | #
|
---|
687 | # HINT: You currently have defined: 'nthost'=\"$nthost\", which resolves above
|
---|
688 | # mentioned paths to:
|
---|
689 | # - '${nthost}/WIN40/${nthost}-enumdrivers3list-NTx86.txt'
|
---|
690 | # - '${nthost}/W32X86/${nthost}-enumdrivers3list-NTx86.txt'
|
---|
691 | #
|
---|
692 | ################################################################################"
|
---|
693 | }
|
---|
694 |
|
---|
695 | # -----------------------------------------------------------------------------
|
---|
696 |
|
---|
697 | function splitenumdrivers3list()
|
---|
698 | {
|
---|
699 | if stringinstring help $@ ; then
|
---|
700 | helpwithsplitenumdrivers3list ;
|
---|
701 | else
|
---|
702 | echo " "
|
---|
703 | echo " "
|
---|
704 | echo "--> Running now function splitenumdrivers3list()...."
|
---|
705 | echo "===================================================="
|
---|
706 |
|
---|
707 | [ -d ${nthost}/WIN40 ] || mkdir -p ${nthost}/WIN40;
|
---|
708 | [ -d ${nthost}/W32X86 ] || mkdir -p ${nthost}/W32X86;
|
---|
709 |
|
---|
710 | cat ${nthost}/enumdrivers3list.txt \
|
---|
711 | | sed -e '/^\[Windows NT x86\]/,$ d' \
|
---|
712 | | tee \
|
---|
713 | ${nthost}/WIN40/${nthost}-enumdrivers3list-WIN40.txt ;
|
---|
714 |
|
---|
715 | cat ${nthost}/WIN40/${nthost}-enumdrivers3list-WIN40.txt \
|
---|
716 | | grep Version \
|
---|
717 | | sort -f \
|
---|
718 | | uniq \
|
---|
719 | | awk -F "[" '{ print $2 }' \
|
---|
720 | | awk -F "]" '{ print $1 }' \
|
---|
721 | | tee ${nthost}/WIN40/availableversionsWIN40.txt ;
|
---|
722 |
|
---|
723 | # cd ${nthost}/WIN40/ ;
|
---|
724 | # mkdir $( cat availableversionsWIN40.txt ) 2> /dev/null ;
|
---|
725 | # cd - ;
|
---|
726 |
|
---|
727 | cat ${nthost}/enumdrivers3list.txt \
|
---|
728 | | sed -e '/^\[Windows NT x86\]/,$! d' \
|
---|
729 | | tee \
|
---|
730 | ${nthost}/W32X86/${nthost}-enumdrivers3list-NTx86.txt ;
|
---|
731 |
|
---|
732 | cat ${nthost}/W32X86/${nthost}-enumdrivers3list-NTx86.txt \
|
---|
733 | | grep Version \
|
---|
734 | | sort -f \
|
---|
735 | | uniq \
|
---|
736 | | awk -F "[" '{ print $2 }' \
|
---|
737 | | awk -F "]" '{ print $1 }' \
|
---|
738 | | tee ${nthost}/W32X86/availableversionsW32X86.txt ;
|
---|
739 |
|
---|
740 | # cd ${nthost}/W32X86/ ;
|
---|
741 | # mkdir $( cat availableversionsW32X86.txt ) 2> /dev/null ;
|
---|
742 | # cd - ;
|
---|
743 | fi
|
---|
744 | }
|
---|
745 |
|
---|
746 |
|
---|
747 | # -----------------------------------------------------------------------------
|
---|
748 | # ---------- Make subdirs in ./${sambahost}/WIN40/ for each driver.... -------
|
---|
749 | # -----------------------------------------------------------------------------
|
---|
750 | #
|
---|
751 |
|
---|
752 | function helpwithmakesubdirsforWIN40driverlist()
|
---|
753 | {
|
---|
754 | echo -e " \n\
|
---|
755 | ################################################################################
|
---|
756 | #
|
---|
757 | # About makesubdirsforWIN40driverlist() and makesubdirsforWIN40driverlist ()...
|
---|
758 | # -----------------------------------------------------------------------------
|
---|
759 | #
|
---|
760 | # PRECONDITIONS: 1) These functions expect write access to the current directory
|
---|
761 | # 2) These functions expect to have the '\$nthost' variable set
|
---|
762 | # to the according value.
|
---|
763 | # 3) These functions expect to find the two files
|
---|
764 | # '\${nthost}/WIN40/\${nthost}-enumdrivers3list-WIN40.txt' and
|
---|
765 | # '\${nthost}/W32X86/\${nthost}-enumdrivers3list-NTx86.txt' to
|
---|
766 | # work on.
|
---|
767 | #
|
---|
768 | # WHAT IT DOES: These functions dissect the '$nthost/enumdrivers3list.txt'
|
---|
769 | # (using "sed", "cat", "awk" and "grep"). They split the input
|
---|
770 | # files up into individual files representing driver(version)s and
|
---|
771 | # create appropriate subdirectories for each driver and version
|
---|
772 | # underneath './\$nthost/<architecture>'. They use the drivernames
|
---|
773 | # (including spaces) for the directory names. ("/" -- slashes --
|
---|
774 | # in drivernames are converted to underscores).
|
---|
775 | #
|
---|
776 | # IF IT DOESN'T WORK: The function "fetchenumdrivers3listfromNThost" and
|
---|
777 | # consecutive ones may not have been run successfully. This
|
---|
778 | # is a precondition for the current function.
|
---|
779 | #
|
---|
780 | # HINT: You currently have defined: 'nthost'=\"$nthost\", which resolves above
|
---|
781 | # mentioned paths to:
|
---|
782 | # - '\${nthost}/WIN40/\${nthost}-enumdrivers3list-NTx86.txt'
|
---|
783 | # - '\${nthost}/W32X86/\${nthost}-enumdrivers3list-NTx86.txt'
|
---|
784 | #
|
---|
785 | ################################################################################
|
---|
786 | # ............PRESS \"q\" TO QUIT............" \
|
---|
787 | |less
|
---|
788 | }
|
---|
789 |
|
---|
790 | # -----------------------------------------------------------------------------
|
---|
791 |
|
---|
792 | function makesubdirsforWIN40driverlist()
|
---|
793 | {
|
---|
794 | if stringinstring help $@ ; then
|
---|
795 | helpwithmakesubdirsforWIN40driverlist ;
|
---|
796 | else
|
---|
797 | cat ${nthost}/WIN40/${nthost}-enumdrivers3list-WIN40.txt \
|
---|
798 | | grep "Driver Name:" \
|
---|
799 | | awk -F "[" '{ print $2 }' \
|
---|
800 | | awk -F "]" '{ print $1 }' \
|
---|
801 | | sort -f \
|
---|
802 | | uniq \
|
---|
803 | | tr / _ \
|
---|
804 | | sed -e 's/$/\"/' \
|
---|
805 | | sed -e 's/^/mkdir -p '"\"${nthost}"'\/WIN40\//' \
|
---|
806 | | tee \
|
---|
807 | ${nthost}/makesubdirsforWIN40driverlist.txt;
|
---|
808 |
|
---|
809 | sh -x ${nthost}/makesubdirsforWIN40driverlist.txt;
|
---|
810 |
|
---|
811 | # rm ${nthost}/makesubdirsforWIN40driverlist.txt;
|
---|
812 | fi
|
---|
813 | }
|
---|
814 |
|
---|
815 |
|
---|
816 | # -----------------------------------------------------------------------------
|
---|
817 | # ---------- Make subdirs in ./${sambahost}/W32X86/ for each driver.... -------
|
---|
818 | # -----------------------------------------------------------------------------
|
---|
819 | #
|
---|
820 |
|
---|
821 | function makesubdirsforW32X86driverlist()
|
---|
822 | {
|
---|
823 | if stringinstring help $@ ; then
|
---|
824 | helpwithvampiredrivers ;
|
---|
825 | else
|
---|
826 | cat ${nthost}/W32X86/${nthost}-enumdrivers3list-NTx86.txt \
|
---|
827 | | grep "Driver Name:" \
|
---|
828 | | awk -F "[" '{ print $2 }' \
|
---|
829 | | awk -F "]" '{ print $1 }' \
|
---|
830 | | sort -f \
|
---|
831 | | uniq \
|
---|
832 | | tr / _ \
|
---|
833 | | sed -e 's/$/\"/' \
|
---|
834 | | sed -e 's/^ */mkdir '\""${nthost}"'\/W32X86\//' \
|
---|
835 | | tee \
|
---|
836 | ${nthost}/makesubdirsforW32X86driverlist.txt;
|
---|
837 |
|
---|
838 | sh -x ${nthost}/makesubdirsforW32X86driverlist.txt;
|
---|
839 |
|
---|
840 | # rm ${nthost}/makesubdirsforW32X86driverlist.txt;
|
---|
841 | fi
|
---|
842 | }
|
---|
843 |
|
---|
844 |
|
---|
845 |
|
---|
846 |
|
---|
847 | # -----------------------------------------------------------------------------
|
---|
848 | # ----------- Split the WIN40 driverfile listing of each architecture ---------
|
---|
849 | # ------------------------ into individual drivers ----------------------------
|
---|
850 | # -----------------------------------------------------------------------------
|
---|
851 | #
|
---|
852 |
|
---|
853 | function helpwithmakesubdirsforWIN40driverlist()
|
---|
854 | {
|
---|
855 | echo -e " \n\
|
---|
856 | ################################################################################
|
---|
857 | #
|
---|
858 | # About splitWIN40fileintoindividualdriverfiles() and
|
---|
859 | # splitW32X86fileintoindividualdriverfiles()...
|
---|
860 | # ---------------------------------------------------
|
---|
861 | #
|
---|
862 | # PRECONDITIONS: 1) These functions expect write access to the current directory
|
---|
863 | # and its subdirs '\$nthost/*/'.
|
---|
864 | # 2) These functions expect to have the '\$nthost' variable set
|
---|
865 | # to the according value.
|
---|
866 | # 3) These functions expect to find the two files
|
---|
867 | # '\${nthost}/WIN40/\${nthost}-enumdrivers3list-WIN40.txt' and
|
---|
868 | # '\${nthost}/W32X86/\${nthost}-enumdrivers3list-NTx86.txt' to
|
---|
869 | # work on.
|
---|
870 | #
|
---|
871 | # WHAT IT DOES: 1) These functions create a directory for each printer driver.
|
---|
872 | # The directory name is identical to the driver name.
|
---|
873 | # 2) For each supported driver version (\"0\", \"2\" and \"3\") it
|
---|
874 | # creates a subdirectory as required underneath
|
---|
875 | # './\$nthost/<architecture>'.
|
---|
876 | # 3) The directories use the drivernames (including spaces) for
|
---|
877 | # their names. ("/" - slashes - in drivernames are converted to
|
---|
878 | # underscores).
|
---|
879 | # 4) In each subdirectory they dissect the original
|
---|
880 | # '\$nthost/enumdrivers3list.txt' (using "sed", "cat", "awk"
|
---|
881 | # and "grep") and store that part describing the related driver
|
---|
882 | # (under the name \"driverfilesversion.txt\".
|
---|
883 | # 5) For each driver the files \"Drivername\", \"DriverPath\",
|
---|
884 | # \"Drivername\", \"Configfile\", \"Helpfile\", \"AllFiles\" and
|
---|
885 | # \"Dependentfilelist\" are stored in the according directory
|
---|
886 | # which hold contend that is used by other (downstream)
|
---|
887 | # functions.
|
---|
888 | # 6) It creates a file named \"AllFilesIAskFor\" which holds the
|
---|
889 | # case sensitive names of files it wanted to download. It also
|
---|
890 | # creates a file named \"AllFilesIGot\" which holds the case
|
---|
891 | # sensitive spelling of the downloaded files. (Due to
|
---|
892 | # Microsoft's ingenious file naming tradition, you may have
|
---|
893 | # asked for a \"PS5UI.DLL\" but gotten a \"ps5ui.dll\".
|
---|
894 | # 7) The 2 files from 6) will be later compared with the help of
|
---|
895 | # the \"sdiff\" utility to decide how to re-name the files so
|
---|
896 | # that the subsequent driver upload command's spelling
|
---|
897 | # convention is met.
|
---|
898 | #
|
---|
899 | # IF IT DOESN'T WORK: The function \"fetchenumdrivers3listfromNThost\" and
|
---|
900 | # consecutive ones may not have been run successfully. This
|
---|
901 | # is a precondition for the current function.
|
---|
902 | #
|
---|
903 | # HINT: You currently have defined: 'nthost'=\"$nthost\".
|
---|
904 | #
|
---|
905 | ################################################################################
|
---|
906 | # ............PRESS \"q\" TO QUIT............" \
|
---|
907 | |less
|
---|
908 | }
|
---|
909 |
|
---|
910 | # -----------------------------------------------------------------------------
|
---|
911 |
|
---|
912 | function splitWIN40fileintoindividualdriverfiles()
|
---|
913 | {
|
---|
914 | if stringinstring help $@ ; then
|
---|
915 | helpwithmakesubdirsforWIN40driverlist ;
|
---|
916 | else
|
---|
917 | echo " "
|
---|
918 | echo " "
|
---|
919 | echo "--> Running now function splitWIN40fileintoindividualdriverfiles()..."
|
---|
920 | echo "====================================================================="
|
---|
921 |
|
---|
922 | for i in ${nthost}/WIN40/*/; do
|
---|
923 | CWD1="$( pwd )" ;
|
---|
924 | cd "${i}" ;
|
---|
925 | echo " "
|
---|
926 | echo " "
|
---|
927 | echo " ###########################################################################################"
|
---|
928 | echo " "
|
---|
929 | echo " Next driver is \"$( basename "$( pwd)" )\""
|
---|
930 | echo " "
|
---|
931 | echo " ###########################################################################################"
|
---|
932 |
|
---|
933 | ##### echo "yes" | cp -f ../../../${nthost}/WIN40/${nthost}-enumdrivers3list-WIN40.txt . 2> /dev/null ;
|
---|
934 | ln -s -f ../${nthost}-enumdrivers3list-WIN40.txt ${nthost}-enumdrivers3list-WIN40.lnk ;
|
---|
935 |
|
---|
936 | tac ${nthost}-enumdrivers3list-WIN40.lnk \
|
---|
937 | | sed -e '/'"$(basename "$(echo "$PWD")")"'/,/Version/ p' -n \
|
---|
938 | | grep Version \
|
---|
939 | | uniq \
|
---|
940 | | awk -F "[" '{ print $2 }' \
|
---|
941 | | awk -F "]" '{ print "mkdir \"" $1 "\"" }' \
|
---|
942 | | tee mkversiondir.txt ;
|
---|
943 |
|
---|
944 | sh mkversiondir.txt 2> /dev/null ;
|
---|
945 |
|
---|
946 | cat ${nthost}-enumdrivers3list-WIN40.lnk \
|
---|
947 | | sed -e '/\['"$(basename "$(echo "$PWD")")"'\]/,/Monitor/ w alldriverfiles.txt' -n ;
|
---|
948 |
|
---|
949 | for i in */; do
|
---|
950 | CWD2="$( pwd )" ;
|
---|
951 | cd "${i}";
|
---|
952 | echo "yes" | cp ../alldriverfiles.txt . 2> /dev/null ;
|
---|
953 |
|
---|
954 | cat alldriverfiles.txt \
|
---|
955 | | egrep '(\\'"$(basename "$( pwd )")"'\\|Driver Name)' \
|
---|
956 | | tee driverfilesversion.txt ;
|
---|
957 |
|
---|
958 | Drivername=$( grep "Driver Name:" driverfilesversion.txt \
|
---|
959 | | awk -F "[" '{ print $2 }' \
|
---|
960 | | awk -F "]" '{ print $1 }' \
|
---|
961 | | sort -f \
|
---|
962 | | uniq \
|
---|
963 | | tee Drivername ) ;
|
---|
964 |
|
---|
965 | DriverPath=$( grep "Driver Path:" driverfilesversion.txt \
|
---|
966 | | awk -F "[" '{ print $2 }' \
|
---|
967 | | awk -F "]" '{ print $1 }' \
|
---|
968 | | awk -F "WIN40" '{ print $2 }' \
|
---|
969 | | awk -F "\\" '{ print $3 }' \
|
---|
970 | | sort -f \
|
---|
971 | | uniq ) ;
|
---|
972 | echo "${DriverPath}" \
|
---|
973 | | tee DriverPath ;
|
---|
974 |
|
---|
975 | Datafile=$( grep "Datafile:" driverfilesversion.txt \
|
---|
976 | | awk -F "[" '{ print $2 }' \
|
---|
977 | | awk -F "]" '{ print $1 }' \
|
---|
978 | | awk -F "WIN40" '{ print $2 }' \
|
---|
979 | | awk -F "\\" '{ print $3 }' \
|
---|
980 | | sort -f \
|
---|
981 | | uniq ) ;
|
---|
982 | echo "${Datafile}" \
|
---|
983 | | tee Datafile ;
|
---|
984 |
|
---|
985 | Configfile=$( grep "Configfile:" driverfilesversion.txt \
|
---|
986 | | awk -F "[" '{ print $2 }' \
|
---|
987 | | awk -F "]" '{ print $1 }' \
|
---|
988 | | awk -F "WIN40" '{ print $2 }' \
|
---|
989 | | awk -F "\\" '{ print $3 }' \
|
---|
990 | | sort -f \
|
---|
991 | | uniq ) ;
|
---|
992 | echo "${Configfile}" \
|
---|
993 | | tee Configfile ;
|
---|
994 |
|
---|
995 | Helpfile=$( grep "Helpfile:" driverfilesversion.txt \
|
---|
996 | | awk -F "[" '{ print $2 }' \
|
---|
997 | | awk -F "]" '{ print $1 }' \
|
---|
998 | | awk -F "WIN40" '{ print $2 }' \
|
---|
999 | | awk -F "\\" '{ print $3 }' \
|
---|
1000 | | sort -f \
|
---|
1001 | | uniq ) ;
|
---|
1002 | echo "${Helpfile}" \
|
---|
1003 | | tee Helpfile ;
|
---|
1004 |
|
---|
1005 | Dependentfilelist=$( grep "Dependentfiles:" driverfilesversion.txt \
|
---|
1006 | | awk -F "[" '{ print $2 }' \
|
---|
1007 | | awk -F "]" '{ print $1 }' \
|
---|
1008 | | awk -F "WIN40" '{ print $2 }' \
|
---|
1009 | | awk -F "\\" '{ print $3 }' \
|
---|
1010 | | sort -f \
|
---|
1011 | | uniq ) ;
|
---|
1012 |
|
---|
1013 | Dependentfiles=$( echo $Dependentfilelist \
|
---|
1014 | | sed -e 's/ /,/g ' ) ;
|
---|
1015 |
|
---|
1016 | echo "${Dependentfiles}" \
|
---|
1017 | | tee Dependentfiles
|
---|
1018 |
|
---|
1019 | AllFiles=$( echo ${Dependentfilelist}; echo ${Helpfile}; echo ${Configfile}; echo ${Datafile}; echo ${DriverPath} );
|
---|
1020 |
|
---|
1021 | echo "${AllFiles}" \
|
---|
1022 | | sort -f \
|
---|
1023 | | uniq \
|
---|
1024 | | tee AllFiles ;
|
---|
1025 |
|
---|
1026 | for i in $( cat AllFiles ); do echo ${i}; done \
|
---|
1027 | | sort -f \
|
---|
1028 | | uniq \
|
---|
1029 | | tee AllFilesIAskFor ;
|
---|
1030 |
|
---|
1031 | cd "${CWD2}" 1> /dev/null ;
|
---|
1032 | done
|
---|
1033 |
|
---|
1034 | # rpcclient -U"${smbprinteradmin}%${smbadminpasswd}" \
|
---|
1035 | # -c "adddriver \"${Architecture}\" \"${DriverName}:${DriverPath}:${Datafile}:${Configfile}:${Helpfile}:NULL:RAW:${Dependentfiles}\" ${Version}" \ ${smbhost}
|
---|
1036 |
|
---|
1037 | # rpcclient -U"${smbprinteradmin}%${smbadminpasswd}" \
|
---|
1038 | # -c "setdriver \"${printername}\" \"${DriverName}\"" \
|
---|
1039 | # ${smbhost}
|
---|
1040 | #
|
---|
1041 | # rpcclient -U"${smbprinteradmin}%${smbadminpasswd}" \
|
---|
1042 | # -c "setprinter \"${printername}\" \"Driver was installed and set via MS-RPC (utilized by Kurt Pfeifle\'s set of \"Vampire Printerdrivers\" scripts from Linux)\"" \
|
---|
1043 | # ${smbhost}
|
---|
1044 |
|
---|
1045 | cd "${CWD1}" 1> /dev/null ;
|
---|
1046 | done;
|
---|
1047 | fi
|
---|
1048 | }
|
---|
1049 |
|
---|
1050 |
|
---|
1051 |
|
---|
1052 |
|
---|
1053 | # -----------------------------------------------------------------------------
|
---|
1054 | # ---------- Split the W32X86 driverfile listing of each architecture ---------
|
---|
1055 | # ------------------------ into individual drivers ----------------------------
|
---|
1056 | # -----------------------------------------------------------------------------
|
---|
1057 | #
|
---|
1058 |
|
---|
1059 | function splitW32X86fileintoindividualdriverfiles()
|
---|
1060 | {
|
---|
1061 | if stringinstring help $@ ; then
|
---|
1062 | helpwithmakesubdirsforWIN40driverlist ;
|
---|
1063 | else
|
---|
1064 | echo " "
|
---|
1065 | echo " "
|
---|
1066 | echo "--> Running now function splitW32X86fileintoindividualdriverfiles()..."
|
---|
1067 | echo "======================================================================"
|
---|
1068 |
|
---|
1069 | for i in ${nthost}/W32X86/*/; do
|
---|
1070 | CWD1="$( pwd )" ;
|
---|
1071 | cd "${i}" ;
|
---|
1072 | echo " "
|
---|
1073 | echo " "
|
---|
1074 | echo " ###########################################################################################"
|
---|
1075 | echo " "
|
---|
1076 | echo " Next driver is \"$( basename "$( pwd)" )\""
|
---|
1077 | echo " "
|
---|
1078 | echo " ###########################################################################################"
|
---|
1079 |
|
---|
1080 | ###### echo "yes" | cp -f ../../../${nthost}/W32X86/${nthost}-enumdrivers3list-NTx86.txt . 2> /dev/null ;
|
---|
1081 | ln -s -f ../${nthost}-enumdrivers3list-NTx86.txt ${nthost}-enumdrivers3list-NTx86.lnk ;
|
---|
1082 |
|
---|
1083 | tac ${nthost}-enumdrivers3list-NTx86.lnk \
|
---|
1084 | | sed -e '/'"$(basename "$(echo "$PWD")")"'/,/Version/ p' -n \
|
---|
1085 | | grep Version \
|
---|
1086 | | uniq \
|
---|
1087 | | awk -F "[" '{ print $2 }' \
|
---|
1088 | | awk -F "]" '{ print "mkdir \"" $1 "\"" }' \
|
---|
1089 | | tee mkversiondir.txt ;
|
---|
1090 |
|
---|
1091 | sh mkversiondir.txt 2> /dev/null ;
|
---|
1092 |
|
---|
1093 | cat ${nthost}-enumdrivers3list-NTx86.lnk \
|
---|
1094 | | sed -e '/\['"$(basename "$(echo "$PWD")")"'\]/,/Monitor/ w alldriverfiles.txt' -n ;
|
---|
1095 |
|
---|
1096 | for i in */; do
|
---|
1097 | CWD2="$( pwd )" ;
|
---|
1098 | cd "${i}";
|
---|
1099 | echo "yes" | cp ../alldriverfiles.txt . 2> /dev/null ;
|
---|
1100 |
|
---|
1101 | cat alldriverfiles.txt \
|
---|
1102 | | egrep '(\\'"$(basename "$( pwd )")"'\\|Driver Name)' \
|
---|
1103 | | tee driverfilesversion.txt ;
|
---|
1104 |
|
---|
1105 | Drivername=$( grep "Driver Name:" driverfilesversion.txt \
|
---|
1106 | | awk -F "[" '{ print $2 }' \
|
---|
1107 | | awk -F "]" '{ print $1 }' \
|
---|
1108 | | sort -f \
|
---|
1109 | | uniq \
|
---|
1110 | | tee Drivername ) ;
|
---|
1111 | # echo "${Drivername}" \
|
---|
1112 | # | tee Drivername ;
|
---|
1113 |
|
---|
1114 |
|
---|
1115 | DriverPath=$( grep "Driver Path:" driverfilesversion.txt \
|
---|
1116 | | awk -F "[" '{ print $2 }' \
|
---|
1117 | | awk -F "]" '{ print $1 }' \
|
---|
1118 | | awk -F "W32X86" '{ print $2 }' \
|
---|
1119 | | awk -F "\\" '{ print $3 }' \
|
---|
1120 | | sort -f \
|
---|
1121 | | uniq ) ;
|
---|
1122 | echo "${DriverPath}" \
|
---|
1123 | | tee DriverPath ;
|
---|
1124 |
|
---|
1125 | Datafile=$( grep "Datafile:" driverfilesversion.txt \
|
---|
1126 | | awk -F "[" '{ print $2 }' \
|
---|
1127 | | awk -F "]" '{ print $1 }' \
|
---|
1128 | | awk -F "W32X86" '{ print $2 }' \
|
---|
1129 | | awk -F "\\" '{ print $3 }' \
|
---|
1130 | | sort -f \
|
---|
1131 | | uniq ) ;
|
---|
1132 | echo "${Datafile}" \
|
---|
1133 | | tee Datafile ;
|
---|
1134 |
|
---|
1135 | Configfile=$( grep "Configfile:" driverfilesversion.txt \
|
---|
1136 | | awk -F "[" '{ print $2 }' \
|
---|
1137 | | awk -F "]" '{ print $1 }' \
|
---|
1138 | | awk -F "W32X86" '{ print $2 }' \
|
---|
1139 | | awk -F "\\" '{ print $3 }' \
|
---|
1140 | | sort -f \
|
---|
1141 | | uniq ) ;
|
---|
1142 | echo "${Configfile}" \
|
---|
1143 | | tee Configfile ;
|
---|
1144 |
|
---|
1145 | Helpfile=$( grep "Helpfile:" driverfilesversion.txt \
|
---|
1146 | | awk -F "[" '{ print $2 }' \
|
---|
1147 | | awk -F "]" '{ print $1 }' \
|
---|
1148 | | awk -F "W32X86" '{ print $2 }' \
|
---|
1149 | | awk -F "\\" '{ print $3 }' \
|
---|
1150 | | sort -f \
|
---|
1151 | | uniq ) ;
|
---|
1152 | echo "${Helpfile}" \
|
---|
1153 | | tee Helpfile ;
|
---|
1154 |
|
---|
1155 | Dependentfilelist=$( grep "Dependentfiles:" driverfilesversion.txt \
|
---|
1156 | | awk -F "[" '{ print $2 }' \
|
---|
1157 | | awk -F "]" '{ print $1 }' \
|
---|
1158 | | awk -F "W32X86" '{ print $2 }' \
|
---|
1159 | | awk -F "\\" '{ print $3 }' \
|
---|
1160 | | sort -f \
|
---|
1161 | | uniq ) ;
|
---|
1162 |
|
---|
1163 | Dependentfiles=$( echo $Dependentfilelist \
|
---|
1164 | | sed -e 's/ /,/g ' ) ;
|
---|
1165 |
|
---|
1166 | echo "${Dependentfiles}" \
|
---|
1167 | | tee Dependentfiles
|
---|
1168 |
|
---|
1169 | AllFiles=$( echo ${Dependentfilelist}; echo ${Helpfile}; echo ${Configfile}; echo ${Datafile}; echo ${DriverPath} ) ;
|
---|
1170 |
|
---|
1171 | echo "${AllFiles}" \
|
---|
1172 | | sort -f \
|
---|
1173 | | uniq \
|
---|
1174 | | tee AllFiles ;
|
---|
1175 |
|
---|
1176 | for i in $( cat AllFiles ); do echo ${i}; done \
|
---|
1177 | | sort -f \
|
---|
1178 | | uniq \
|
---|
1179 | | tee AllFilesIAskFor ;
|
---|
1180 |
|
---|
1181 | cd "${CWD2}" 1> /dev/null ;
|
---|
1182 | done
|
---|
1183 |
|
---|
1184 | # rpcclient -U"${smbprinteradmin}%${smbadminpasswd}" \
|
---|
1185 | # -c "adddriver \"${Architecture}\" \"${DriverName}:${DriverPath}:${Datafile}:${Configfile}:${Helpfile}:NULL:RAW:${Dependentfiles}\" ${Version}" \ ${smbhost}
|
---|
1186 |
|
---|
1187 | # rpcclient -U"${smbprinteradmin}%${smbadminpasswd}" \
|
---|
1188 | # -c "setdriver \"${printername}\" \"${DriverName}\"" \
|
---|
1189 | # ${smbhost}
|
---|
1190 | #
|
---|
1191 | # rpcclient -U"${smbprinteradmin}%${smbadminpasswd}" \
|
---|
1192 | # -c "setprinter \"${printername}\" \"Driver was installed and set via MS-RPC (utilized by Kurt Pfeifle\'s set of \"Vampire Printerdrivers\" scripts from Linux)\"" \
|
---|
1193 | # ${smbhost}
|
---|
1194 |
|
---|
1195 | cd "${CWD1}" 1> /dev/null ;
|
---|
1196 | done;
|
---|
1197 | fi
|
---|
1198 | }
|
---|
1199 |
|
---|
1200 |
|
---|
1201 |
|
---|
1202 | # -----------------------------------------------------------------------------
|
---|
1203 | # ------------------ First download the driverfiles........... ----------------
|
---|
1204 | # -----------------------------------------------------------------------------
|
---|
1205 | #
|
---|
1206 |
|
---|
1207 | function helpwithfetchallW32X86driverfiles()
|
---|
1208 | {
|
---|
1209 | echo -e " \n\
|
---|
1210 | ################################################################################
|
---|
1211 | #
|
---|
1212 | # About fetchallW32X86driverfiles()...
|
---|
1213 | # ------------------------------------
|
---|
1214 | #
|
---|
1215 | # PRECONDITIONS: 1) This function expects to have the \'\$nthost\' variable set
|
---|
1216 | # to the according value.
|
---|
1217 | # 2) This function expects to find files \"AllFiles\",
|
---|
1218 | # \"AllFilesIAskFor\", and \"AllFilesIGot\" in the directories
|
---|
1219 | # \'\${nthost}/<architecture>/<drivername>/<version>/\'.
|
---|
1220 | #
|
---|
1221 | # WHAT IT DOES: These functions use \"smbclient\" to connect to the NT print
|
---|
1222 | # server \"\$nthost\" and download the printer driver files from
|
---|
1223 | # there. To achieve that in an orderly fashion, the previously
|
---|
1224 | # created subdirectories (named like the drivers to fetch) are
|
---|
1225 | # visited in turn and the related files are downloaded for each
|
---|
1226 | # driver/directory.
|
---|
1227 | #
|
---|
1228 | # IF IT DOESN'T WORK: The function \"fetchenumdrivers3listfromNThost\" and
|
---|
1229 | # consecutive ones may not have been run successfully. This
|
---|
1230 | # is a precondition for the current function.
|
---|
1231 | #
|
---|
1232 | # HINT: The current values: 'nthost'=\"$nthost\"
|
---|
1233 | # 'ntprinteradmin'=\"$ntprinteradmin\"
|
---|
1234 | # 'ntadminpasswd'=<not shown here, check yourself!>
|
---|
1235 | #
|
---|
1236 | ################################################################################"
|
---|
1237 | }
|
---|
1238 |
|
---|
1239 | # -----------------------------------------------------------------------------
|
---|
1240 |
|
---|
1241 | function fetchallW32X86driverfiles()
|
---|
1242 | {
|
---|
1243 | if stringinstring help $@ ; then
|
---|
1244 | helpwithfetchallW32X86driverfiles ;
|
---|
1245 | else
|
---|
1246 | echo " "
|
---|
1247 | echo " "
|
---|
1248 | echo "--> Running now function fetchallW32X86driverfiles()...."
|
---|
1249 | echo "========================================================"
|
---|
1250 |
|
---|
1251 | CURRENTWD=${PWD} ;
|
---|
1252 | for i in ${nthost}/W32X86/*/*/ ; do \
|
---|
1253 | cd "${i}";
|
---|
1254 |
|
---|
1255 | driverversion="$(basename "$(echo "$PWD")")" ;
|
---|
1256 | echo "$(basename "$(echo "$PWD")")" > driverversion ;
|
---|
1257 |
|
---|
1258 | AllFiles=$( cat AllFiles ) ;
|
---|
1259 |
|
---|
1260 | [ -d TheFiles ] || mkdir TheFiles;
|
---|
1261 |
|
---|
1262 | cd TheFiles;
|
---|
1263 |
|
---|
1264 | echo " "
|
---|
1265 | echo "===================================================="
|
---|
1266 | echo "Downloading files now to ${PWD}....";
|
---|
1267 | echo "===================================================="
|
---|
1268 | echo " "
|
---|
1269 |
|
---|
1270 | # Fetch the Driver files from the Windoze box (printserver)
|
---|
1271 | smbclient -U"${ntprinteradmin}%${ntadminpasswd}" -d 2 \
|
---|
1272 | //${nthost}/print\$ -c \
|
---|
1273 | "cd W32X86\\${driverversion};prompt;mget ${AllFiles}"
|
---|
1274 |
|
---|
1275 | ls -1 \
|
---|
1276 | | sort -f \
|
---|
1277 | | uniq \
|
---|
1278 | | tee ../AllFilesIGot ;
|
---|
1279 |
|
---|
1280 | cd ${CURRENTWD} ;
|
---|
1281 |
|
---|
1282 | done ;
|
---|
1283 | fi
|
---|
1284 | }
|
---|
1285 |
|
---|
1286 |
|
---|
1287 | # -----------------------------------------------------------------------------
|
---|
1288 | # -------------- Now upload the driverfiles and activate them! ----------------
|
---|
1289 | # Upload files into root "Architecture" directory of Samba'a [print$] share...
|
---|
1290 | # -----------------------------------------------------------------------------
|
---|
1291 | #
|
---|
1292 |
|
---|
1293 | function helpwithuploadallW32X86drivers()
|
---|
1294 | {
|
---|
1295 | echo -e " \n\
|
---|
1296 | ################################################################################
|
---|
1297 | #
|
---|
1298 | # About uploadallW32X86drivers()...
|
---|
1299 | # ---------------------------------
|
---|
1300 | #
|
---|
1301 | # PRECONDITIONS: 1) This function expects to have the '\$nthost',
|
---|
1302 | # '\$ntprinteradmin' and '\$ntadminpasswd' variables set to
|
---|
1303 | # according values.
|
---|
1304 | # 2) This function expects to find the files \"AllFiles\",
|
---|
1305 | # \"AllFilesIGot\" and \"AllFilesIAskFor\" in the
|
---|
1306 | # \"\${nthost}/W32X86<drivername>/<driverversion>/TheFiles\"
|
---|
1307 | # subdirectory.
|
---|
1308 | #
|
---|
1309 | # WHAT IT DOES: This function uses "smbclient" to connect to the new Samba print
|
---|
1310 | # server "\$nthost" and upload the printer driver files into the
|
---|
1311 | # \"[print\$]\" share there. To achieve that in orderly fashion,
|
---|
1312 | # the previously created subdirectories (named like the drivers
|
---|
1313 | # fetched previously from \$smbhost) are visited in turn and the
|
---|
1314 | # related files are uploaded for each driver/directory. For this
|
---|
1315 | # to really succeed, the files \"AllFilesIGot\" and \"AllFilesIAskFor\"
|
---|
1316 | # are compared with the help of the \"sdiff\" utility to decide
|
---|
1317 | # how to re-name the mis-matching filenams, so that the used
|
---|
1318 | # driver upload command's spelling convention is met....
|
---|
1319 | #
|
---|
1320 | # IF IT DOESN'T WORK: The function "fetchenumdrivers3listfromNThost" and
|
---|
1321 | # consecutive ones may not have been run successfully. This
|
---|
1322 | # is a precondition for the current function.
|
---|
1323 | #
|
---|
1324 | # HINT: The current values: 'nthost'=\"$nthost\"
|
---|
1325 | # 'ntprinteradmin'=\"$ntprinteradmin\"
|
---|
1326 | # 'ntadminpasswd'=<not shown here, check yourself!>
|
---|
1327 | #
|
---|
1328 | ################################################################################
|
---|
1329 | # ............PRESS \"q\" TO QUIT............" \
|
---|
1330 | |less
|
---|
1331 | }
|
---|
1332 |
|
---|
1333 | # -----------------------------------------------------------------------------
|
---|
1334 |
|
---|
1335 | function uploadallW32X86drivers()
|
---|
1336 | {
|
---|
1337 | if stringinstring help $@ ; then
|
---|
1338 | helpwithuploadallW32X86drivers ;
|
---|
1339 | else
|
---|
1340 | echo " "
|
---|
1341 | echo " "
|
---|
1342 | echo "--> Running now function uploadallW32X86drivers()...."
|
---|
1343 | echo "====================================================="
|
---|
1344 |
|
---|
1345 | for i in ${nthost}/W32X86/*/*/; do \
|
---|
1346 | CURRENTWD=${PWD} ;
|
---|
1347 | cd "${i}" ;
|
---|
1348 | # we are now in [..]/W32X86/[drvrname]/[2|3]/
|
---|
1349 |
|
---|
1350 | driverversion="$(basename "$(echo "$PWD")")" ;
|
---|
1351 |
|
---|
1352 | echo "$(basename "$(echo "$PWD")")" > driverversion ;
|
---|
1353 |
|
---|
1354 | cd TheFiles ;
|
---|
1355 | # we are now in [..]/W32X86/[drvrname]/[2|3]/TheFiles
|
---|
1356 | echo " "
|
---|
1357 | echo "===================================================="
|
---|
1358 | echo "Uploading driverfiles now from ${PWD}....";
|
---|
1359 | echo "===================================================="
|
---|
1360 | echo " "
|
---|
1361 | set -x ;
|
---|
1362 |
|
---|
1363 | smbclient -U"${smbprinteradmin}%${smbadminpasswd}" -d 2 \
|
---|
1364 | //${smbhost}/print\$ \
|
---|
1365 | -c "mkdir W32X86;cd W32X86;prompt;mput $( cat ../AllFilesIGot )";
|
---|
1366 |
|
---|
1367 | cd .. ;
|
---|
1368 | # we are now in [..]/W32X86/[drvrname]/[2|3]/
|
---|
1369 |
|
---|
1370 | # Now tell Samba that those files are *printerdriver* files....
|
---|
1371 | # The "adddriver" command will move them to the "0" subdir and create or
|
---|
1372 | # update the associated *.tdb files (faking the MS Windows Registry on Samba)
|
---|
1373 | Drivername="$( cat Drivername )"
|
---|
1374 |
|
---|
1375 | set -x ;
|
---|
1376 | [ x"$( cat Dependentfiles)" == x"" ] && echo NULL > Dependentfiles;
|
---|
1377 |
|
---|
1378 | sdiff -s AllFilesIGot AllFilesIAskFor \
|
---|
1379 | | tee sdiff-of-Requested-and-Received.txt ;
|
---|
1380 |
|
---|
1381 | [ -s sdiff-of-Requested-and-Received.txt ] \
|
---|
1382 | || rm -f sdiff-of-Requested-and-Received.txt \
|
---|
1383 | && cat sdiff-of-Requested-and-Received.txt > ../sdiff-of-Requested-and-Received.txt ;
|
---|
1384 |
|
---|
1385 | cat sdiff-of-Requested-and-Received.txt \
|
---|
1386 | | sed -e 's/^/mv /' \
|
---|
1387 | | sed -e 's/ *|/ /' \
|
---|
1388 | | tee rename-Received-to-Requested-case.txt ;
|
---|
1389 |
|
---|
1390 | sh -x rename-Received-to-Requested-case.txt ;
|
---|
1391 |
|
---|
1392 | mv rename-Received-to-Requested-case.txt rename-Received-to-Requested-case.done ;
|
---|
1393 |
|
---|
1394 | echo " ################ B E G I N DEBUGGING STATEMENT ############"
|
---|
1395 | echo "rpcclient -U\"${smbprinteradmin}%${smbadminpasswd}\" -d 2 \
|
---|
1396 | -c \'adddriver \"Windows NT x86\" \"$( cat Drivername ):$( cat DriverPath ):$( cat Datafile ):$( cat Configfile ):$( cat Helpfile ):NULL:RAW:$( cat Dependentfiles )\" $( cat driverversion )" \
|
---|
1397 | ${smbhost} \' ;
|
---|
1398 | echo " ################ E N D DEBUGGING STATEMENT ################"
|
---|
1399 |
|
---|
1400 | rpcclient -U"${smbprinteradmin}%${smbadminpasswd}" -d 2 \
|
---|
1401 | -c "adddriver \"Windows NT x86\" \"$( cat Drivername ):$( cat DriverPath ):$( cat Datafile ):$( cat Configfile ):$( cat Helpfile ):NULL:RAW:$( cat Dependentfiles )\" $( cat driverversion )" \
|
---|
1402 | ${smbhost} ;
|
---|
1403 |
|
---|
1404 | set +x ;
|
---|
1405 |
|
---|
1406 | cd ${CURRENTWD} ;
|
---|
1407 | # we are now back to where we started
|
---|
1408 | done;
|
---|
1409 | set +x ;
|
---|
1410 | fi
|
---|
1411 | }
|
---|
1412 |
|
---|
1413 | # Now tell Samba which printqueue this driver is associated with....
|
---|
1414 | # The "setdriver" command will do just that and create or
|
---|
1415 | # update the associated *.tdb files (faking the MS Windows Registry on Samba)
|
---|
1416 | # rpcclient -U"${smbprinteradmin}%${smbadminpasswd}" \
|
---|
1417 | # -c "setdriver \"${printername}\" \"${DriverName}\"" \
|
---|
1418 | # ${smbhost}
|
---|
1419 | # -- NOT YET IMPLEMENTED IN THIS SCRIPT ---
|
---|
1420 | #
|
---|
1421 |
|
---|
1422 | # Now set a nice printer comment and let the world know what we've done
|
---|
1423 | # (or not.... ;-)
|
---|
1424 | # rpcclient -U"${smbprinteradmin}%${smbadminpasswd}" \
|
---|
1425 | # -c "setprinter \"${printername}\" \"Driver was installed and set via MS-RPC (rpcclient commandline from Linux)\"" \
|
---|
1426 | # ${smbhost}
|
---|
1427 | # -- NOT YET IMPLEMENTED IN THIS SCRIPT ---
|
---|
1428 | #
|
---|
1429 |
|
---|
1430 |
|
---|
1431 | # -----------------------------------------------------------------------------
|
---|
1432 | # ------------------ First download the driverfiles........... ----------------
|
---|
1433 | # -----------------------------------------------------------------------------
|
---|
1434 | #
|
---|
1435 |
|
---|
1436 | function helpwithfetchallWIN40driverfiles()
|
---|
1437 | {
|
---|
1438 | echo -e " \n\
|
---|
1439 | ################################################################################
|
---|
1440 | #
|
---|
1441 | # About fetchallWIN40driverfiles()...
|
---|
1442 | # -----------------------------------
|
---|
1443 | #
|
---|
1444 | # PRECONDITIONS: 1) This function expects to have the \$nthost variable set to
|
---|
1445 | # the according value.
|
---|
1446 | # 2) This function expects to find the \"AllFiles\" file in
|
---|
1447 | # \"\${nthost}/WIN40<drivername>/<driverversion>/TheFiles\".
|
---|
1448 | #
|
---|
1449 | # WHAT IT DOES: These functions use "smbclient" to connect to the NT print server
|
---|
1450 | # "\$nthost" and download the printer driver files from there. To
|
---|
1451 | # achieve that in an orderly fashion, the previously created
|
---|
1452 | # subdirectories (named like the drivers to fetch) are visited in
|
---|
1453 | # turn and the related files are downloaded for each
|
---|
1454 | # driver/directory.
|
---|
1455 | #
|
---|
1456 | # IF IT DOESN'T WORK: The function "fetchenumdrivers3listfromNThost" and
|
---|
1457 | # consecutive ones may not have been run successfully. This
|
---|
1458 | # is a precondition for the current function.
|
---|
1459 | #
|
---|
1460 | # HINT: The current values: 'nthost'=\"$nthost\"
|
---|
1461 | # 'ntprinteradmin'=\"$ntprinteradmin\"
|
---|
1462 | # 'ntadminpasswd'=<not shown here, check yourself!>
|
---|
1463 | #
|
---|
1464 | ################################################################################
|
---|
1465 | # ............PRESS \"q\" TO QUIT............" \
|
---|
1466 | |less
|
---|
1467 | }
|
---|
1468 |
|
---|
1469 | # -----------------------------------------------------------------------------
|
---|
1470 |
|
---|
1471 | function fetchallWIN40driverfiles()
|
---|
1472 | {
|
---|
1473 | if stringinstring help $@ ; then
|
---|
1474 | helpwithfetchallWIN40driverfiles ;
|
---|
1475 | else
|
---|
1476 | echo " "
|
---|
1477 | echo " "
|
---|
1478 | echo "--> Running now function fetchallWIN40driverfiles()...."
|
---|
1479 | echo "======================================================="
|
---|
1480 |
|
---|
1481 | CURRENTWD=${PWD} ;
|
---|
1482 |
|
---|
1483 | for i in ${nthost}/WIN40/*/*/; do \
|
---|
1484 | cd "${i}";
|
---|
1485 |
|
---|
1486 | driverversion="$(basename "$(echo "$PWD")")" ;
|
---|
1487 | echo "$(basename "$(echo "$PWD")")" > driverversion ;
|
---|
1488 |
|
---|
1489 | AllFiles=$( cat AllFiles ) ;
|
---|
1490 |
|
---|
1491 | [ -d TheFiles ] || mkdir TheFiles;
|
---|
1492 |
|
---|
1493 | cd TheFiles;
|
---|
1494 |
|
---|
1495 | echo " "
|
---|
1496 | echo "===================================================="
|
---|
1497 | echo "Downloading files now to ${PWD}....";
|
---|
1498 | echo "===================================================="
|
---|
1499 | echo " "
|
---|
1500 |
|
---|
1501 | # Fetch the Driver files from the Windoze box (printserver)
|
---|
1502 | smbclient -U"${ntprinteradmin}%${ntadminpasswd}" -d 2 \
|
---|
1503 | //${nthost}/print\$ -c \
|
---|
1504 | "cd WIN40\\${driverversion};prompt;mget ${AllFiles}" ;
|
---|
1505 |
|
---|
1506 | ls -1 \
|
---|
1507 | | sort -f \
|
---|
1508 | | uniq \
|
---|
1509 | | tee ../AllFilesIGot ;
|
---|
1510 |
|
---|
1511 | cd ${CURRENTWD} ;
|
---|
1512 |
|
---|
1513 | done ;
|
---|
1514 | fi
|
---|
1515 | }
|
---|
1516 |
|
---|
1517 |
|
---|
1518 | # -----------------------------------------------------------------------------
|
---|
1519 | # -------------- Now upload the driverfiles and activate them! ----------------
|
---|
1520 | # Upload files into root "Architecture" directory of Samba'a [print$] share...
|
---|
1521 | # -----------------------------------------------------------------------------
|
---|
1522 | #
|
---|
1523 |
|
---|
1524 | function helpwithuploadallWIN40drivers()
|
---|
1525 | {
|
---|
1526 | echo -e " \n\
|
---|
1527 | ################################################################################
|
---|
1528 | #
|
---|
1529 | # About uploadallWIN40drivers()...
|
---|
1530 | # --------------------------------
|
---|
1531 | #
|
---|
1532 | # PRECONDITIONS: 1) This function expects to have '\$smbhost', '\$smbprinteradmin'
|
---|
1533 | # and '\$smbadminpasswd' variables set to according values.
|
---|
1534 | # 2) This function expects to find \"AllFiles\", \"AllFilesIGot\"
|
---|
1535 | # and \"AllFilesIAskFor\" in the subdirectory
|
---|
1536 | # \"\${nthost}/WINI40/<drivername>/<driverversion>/TheFiles\".
|
---|
1537 | #
|
---|
1538 | # WHAT IT DOES: These function uses \"smbclient\" to connect to the new Samba
|
---|
1539 | # print server "\$nthost" and upload the printer driver files into
|
---|
1540 | # the \"[print\$]\" share there.
|
---|
1541 | # To achieve that in an orderly fashion, the previously created
|
---|
1542 | # subdirectories (named like the drivers fetched previously from
|
---|
1543 | # \$smbhost) are visited in turn and the related files are
|
---|
1544 | # uploaded for each driver/directory.
|
---|
1545 | # For this to really succeed, \"AllFilesIGot\" and \"AllFilesIAskFor\"
|
---|
1546 | # are compared with the help of the \"sdiff\" utility to decide
|
---|
1547 | # how to re-name the mis-matching filenams, so that the used
|
---|
1548 | # driver upload command's spelling convention is met....
|
---|
1549 | #
|
---|
1550 | # IF IT DOESN'T WORK: The function \"fetchenumdrivers3listfromNThost\" and
|
---|
1551 | # consecutive ones may not have been run successfully. This
|
---|
1552 | # is a precondition for the current function.
|
---|
1553 | #
|
---|
1554 | # HINT: The current values: 'nthost'=\"$nthost\"
|
---|
1555 | # 'ntprinteradmin'=\"$ntprinteradmin\"
|
---|
1556 | # 'ntadminpasswd'=<not shown here, check yourself!>
|
---|
1557 | #
|
---|
1558 | ################################################################################
|
---|
1559 | # ............PRESS \"q\" TO QUIT............" \
|
---|
1560 | |less
|
---|
1561 | }
|
---|
1562 | function uploadallWIN40drivers()
|
---|
1563 | {
|
---|
1564 | if stringinstring help $@ ; then
|
---|
1565 | helpwithuploadallWIN40drivers ;
|
---|
1566 | else
|
---|
1567 | echo " "
|
---|
1568 | echo " "
|
---|
1569 | echo "--> Running now function uploadallWIN40drivers()...."
|
---|
1570 | echo "===================================================="
|
---|
1571 |
|
---|
1572 | for i in ${nthost}/WIN40/*/*/; do \
|
---|
1573 | CURRENTWD=${PWD} ;
|
---|
1574 | cd "${i}" ;
|
---|
1575 | # we are now in [..]/WIN40/[drvrname]/[0]/
|
---|
1576 |
|
---|
1577 | driverversion="$(basename "$(echo "$PWD")")" ;
|
---|
1578 |
|
---|
1579 | echo "$(basename "$(echo "$PWD")")" > driverversion ;
|
---|
1580 |
|
---|
1581 | cd TheFiles ;
|
---|
1582 | # we are now in [..]/WIN40/[drvrname]/[0]/TheFiles
|
---|
1583 | echo " "
|
---|
1584 | echo "===================================================="
|
---|
1585 | echo "Uploading driverfiles now from ${PWD}....";
|
---|
1586 | echo "===================================================="
|
---|
1587 | echo " "
|
---|
1588 | set -x ;
|
---|
1589 |
|
---|
1590 | smbclient -U"${smbprinteradmin}%${smbadminpasswd}" -d 2 \
|
---|
1591 | //${smbhost}/print\$ \
|
---|
1592 | -c "mkdir WIN40;cd WIN40;prompt;mput $( cat ../AllFilesIGot )";
|
---|
1593 |
|
---|
1594 | cd .. ;
|
---|
1595 | # we are now in [..]/WIN40/[drvrname]/[0]/
|
---|
1596 |
|
---|
1597 | # Now tell Samba that those files are *printerdriver* files....
|
---|
1598 | # The "adddriver" command will move them to the "0" subdir and create or
|
---|
1599 | # update the associated *.tdb files (faking the MS Windows Registry on Samba)
|
---|
1600 | Drivername="$( cat Drivername )"
|
---|
1601 |
|
---|
1602 | set -x ;
|
---|
1603 | [ x"$( cat Dependentfiles)" == x"" ] && echo NULL > Dependentfiles;
|
---|
1604 |
|
---|
1605 | sdiff -s AllFilesIGot AllFilesIAskFor \
|
---|
1606 | | tee sdiff-of-Requested-and-Received.txt ;
|
---|
1607 |
|
---|
1608 | [ -s sdiff-of-Requested-and-Received.txt ] \
|
---|
1609 | || rm -f sdiff-of-Requested-and-Received.txt \
|
---|
1610 | && cat sdiff-of-Requested-and-Received.txt > ../sdiff-of-Requested-and-Received.txt ;
|
---|
1611 |
|
---|
1612 | cat sdiff-of-Requested-and-Received.txt \
|
---|
1613 | | sed -e 's/^/mv /' \
|
---|
1614 | | sed -e 's/ *|/ /' \
|
---|
1615 | | tee rename-Received-to-Requested-case.txt ;
|
---|
1616 |
|
---|
1617 | sh -x rename-Received-to-Requested-case.txt ;
|
---|
1618 |
|
---|
1619 | mv rename-Received-to-Requested-case.txt rename-Received-to-Requested-case.done ;
|
---|
1620 |
|
---|
1621 | echo " ################ DEBUGGING STATEMENT "
|
---|
1622 | echo "rpcclient -U\"${smbprinteradmin}%${smbadminpasswd}\" -d 2 \
|
---|
1623 | -c \'adddriver \"Windows NT x86\" \"$( cat Drivername ):$( cat DriverPath ):$( cat Datafile ):$( cat Configfile ):$( cat Helpfile ):NULL:RAW:$( cat Dependentfiles )\" $( cat driverversion )" \
|
---|
1624 | ${smbhost}\' ;
|
---|
1625 | echo " ################ DEBUGGING STATEMENT "
|
---|
1626 |
|
---|
1627 | rpcclient -U"${smbprinteradmin}%${smbadminpasswd}" -d 2 \
|
---|
1628 | -c "adddriver \"Windows 4.0\" \"$( cat Drivername ):$( cat DriverPath ):$( cat Datafile ):$( cat Configfile ):$( cat Helpfile ):NULL:RAW:$( cat Dependentfiles )\" $( cat driverversion )" \
|
---|
1629 | ${smbhost} ;
|
---|
1630 |
|
---|
1631 | set +x ;
|
---|
1632 | cd ${CURRENTWD} ;
|
---|
1633 | # we are now back to where we started
|
---|
1634 | done;
|
---|
1635 | fi
|
---|
1636 | }
|
---|
1637 |
|
---|
1638 | # Now tell Samba which printqueue this driver is associated with....
|
---|
1639 | # The "setdriver" command will do just that and create or
|
---|
1640 | # update the associated *.tdb files (faking the MS Windows Registry on Samba)
|
---|
1641 | # rpcclient -U"${smbprinteradmin}%${smbadminpasswd}" \
|
---|
1642 | # -c "setdriver \"${printername}\" \"${DriverName}\"" \
|
---|
1643 | # ${smbhost}
|
---|
1644 | # -- NOT YET IMPLEMENTED IN THIS SCRIPT ---
|
---|
1645 | #
|
---|
1646 | # Now set a nice printer comment and let the world know what we've done
|
---|
1647 | # (or not.... ;-)
|
---|
1648 | # rpcclient -U"${smbprinteradmin}%${smbadminpasswd}" \
|
---|
1649 | # -c "setprinter \"${printername}\" \"Driver was installed and set via MS-RPC (rpcclient commandline from Linux)\"" \
|
---|
1650 | # ${smbhost}
|
---|
1651 | # -- NOT YET IMPLEMENTED IN THIS SCRIPT ---
|
---|
1652 | #
|
---|
1653 |
|
---|
1654 |
|
---|
1655 | #source ${0} ;
|
---|
1656 |
|
---|
1657 | enumallfunctions;
|
---|