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