File: getweb.in

package info (click to toggle)
foo2zjs 20171202dfsg0-2
  • links: PTS, VCS
  • area: main
  • in suites: buster, sid
  • size: 9,320 kB
  • sloc: ansic: 40,789; xml: 12,512; sh: 7,385; makefile: 1,705; objc: 573; tcl: 173; perl: 102; python: 8
file content (556 lines) | stat: -rwxr-xr-x 13,904 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
#!/bin/sh

set -e

#
# (c) Copyright Rick Richardson 2008
# This version has been modified by Debian

#
# PLEASE don't remove the copyright statements.  They should 
# be displayed to the human that is running this.
#

VERSION='$Id: getweb.in,v 1.114 2015/02/12 00:22:02 rick Exp $'

WGETOPTS="--passive-ftp -q"
ARM2HPDL="/usr/bin/arm2hpdl"

if [ $(id -ru) -ne 0 ]; then
    echo "You need to be root"
    exit 1
fi


usage() {
cat <<EOF

Usage:
    ./getweb something

    Convenience script to get extra somethings from the web,
    such as ICC color profiles, firmware, PPD files, etc.

    $ ./getweb 1025     # Get HP LaserJet Pro CP1025nw .ICM files
    $ ./getweb 1215	# Get HP Color LaserJet CP1215 .ICM files
    $ ./getweb 1500	# Get HP Color LaserJet 1500 .ICM files
    $ ./getweb 1600	# Get HP Color LaserJet 1600 .ICM files
    $ ./getweb 2600n	# Get HP Color LaserJet 2600n .ICM files

    $ ./getweb 1600w	# Get Konica Minolta 1600W .ICM files
    $ ./getweb 1680	# Get Konica Minolta 1680MF .ICM files
    $ ./getweb 1690	# Get Konica Minolta 1690MF .ICM files
    $ ./getweb 2480	# Get Konica Minolta 2480 MF .ICM files
    $ ./getweb 2490	# Get Konica Minolta 2490 MF .ICM files
    $ ./getweb 2530	# Get Konica Minolta 2530 DL .ICM files
    $ ./getweb 4690	# Get Konica Minolta 4690MF .ICM files
    $ ./getweb 6115	# Get Xerox Phaser 6115MFP .ICM files
    $ ./getweb 110	# Get Oki C110 .ICM files
    $ ./getweb 6121	# Get Xerox Phaser 6121MFP .ICM files

    $ ./getweb 2200	# Get Minolta 2200 DL .ICM files
    $ ./getweb 2300	# Get Minolta 2300 DL .ICM files
    $ ./getweb 2430	# Get Konica Minolta 2430 DL .ICM files
    $ ./getweb cpwl	# Get Minolta Color PageWorks/Pro L .ICM files

    $ ./getweb 300	# Get Samsung CLP-300 .ICM files
    $ ./getweb 310	# Get Samsung CLP-310 .ICM files
    $ ./getweb 315	# Get Samsung CLP-315 .ICM files
    $ ./getweb 325	# Get Samsung CLP-325 .ICM files
    $ ./getweb 360	# Get Samsung CLP-360 .ICM files
    $ ./getweb 365	# Get Samsung CLP-365 .ICM files
    $ ./getweb 600	# Get Samsung CLP-600 .ICM files
    $ ./getweb 610	# Get Samsung CLP-610 .ICM files
    $ ./getweb 2160	# Get Samsung CLX-2160 .ICM files
    $ ./getweb 3160	# Get Samsung CLX-3160 .ICM files
    $ ./getweb 3175	# Get Samsung CLX-3175 .ICM files
    $ ./getweb 3185	# Get Samsung CLX-3185 .ICM files
    $ ./getweb 6110	# Get Xerox Phaser 6110 and 6110MFP .ICM files

    $ ./getweb 500	# Get Lexmark C500 .ICM files

    $ ./getweb 301	# Get Oki C301dn .ICM files
    $ ./getweb c310	# Get Oki C310dn .ICM files
    $ ./getweb c511	# Get Oki C511dn .ICM files
    $ ./getweb c810	# Get Oki C810 .ICM files
    $ ./getweb 3100	# Get Oki C3100 .ICM files
    $ ./getweb 3200	# Get Oki C3200 .ICM files
    $ ./getweb 3300	# Get Oki C3300 .ICM files
    $ ./getweb 3400	# Get Oki C3400 .ICM files
    $ ./getweb 3530	# Get Oki C3530 MFP .ICM files
    $ ./getweb 5100	# Get Oki C5100 / C5150n .ICM files
    $ ./getweb 5200	# Get Oki C5200 .ICM files
    $ ./getweb 5500	# Get Oki C5500 .ICM files
    $ ./getweb 5600	# Get Oki C5600 .ICM files
    $ ./getweb 5800	# Get Oki C5800 .ICM files

    $ ./getweb 160	# Get Olivetti d-Color P160W .ICM files

    $ ./getweb 1000	# Get HP LJ 1000 firmware file
    $ ./getweb 1005	# Get HP LJ 1005 firmware file
    $ ./getweb 1018	# Get HP LJ 1018 firmware file
    $ ./getweb 1020	# Get HP LJ 1020 firmware file

    $ ./getweb p1005	# Get HP LJ P1005 firmware file
    $ ./getweb p1006	# Get HP LJ P1006 firmware file
    $ ./getweb p1007	# Get HP LJ P1007 firmware file
    $ ./getweb p1008	# Get HP LJ P1008 firmware file
    $ ./getweb p1505	# Get HP LJ P1505 firmware file

    $ ./getweb all	# Get everything above

    $ ./getweb 2300dl_fw # Get Minolta 2300DL v2.55 firmware (experts only)
EOF
    exit 1
}

#
#       Report an error and exit
#
PROGNAME=$0
error() {
	echo "`basename $PROGNAME`: $1" >&2
	exit 1
}

SYSTEM=`uname -s`
WGET=`which wget`
if [ "$SYSTEM" = Darwin -a "$WGET" = "" ]
then
    WGETOPTS=
    wget() {
	shift
	curl -o $*
    }
fi

putfw() {
    inputname=$1
    outputname=$2
    $ARM2HPDL $inputname > /lib/firmware/hp/$outputname
    rm $inputname
}

puticm() {
    drivername=$1
    icmfolder=/usr/share/"$drivername"/icm/
    [ -d $icmfolder ] || mkdir -p $icmfolder
    mv *.icm $icmfolder
}

#
#	Download a .EXE file from the web, unzip it, and extract the
#	files we want
getexe() {
    url="$1"
    exefile="$2"
    shift; shift
    
    wget $WGETOPTS -O $exefile "$url/$exefile" ||
	error "Couldn't download $url/$exefile"
    unzip -oj $exefile "$@"
    rm $exefile
}

#
#	Download a .tar.gz file from the web, untar it, and extract the
#	files we want
gettgz() {
    url="$1"
    file="$2"
    what="$3"
    
    wget $WGETOPTS -O $file "$url/$file" ||
	error "Couldn't download $url/$file"
    gunzip <$file | tar xvf - $what
    rm $file
}

copyright() {
    echo
    echo "$1"
    echo
}

getone() {
    case "$1" in
    lj1000|1000)
	gettgz \
	    http://foo2zjs.rkkda.com/firmware sihp1000.tar.gz \
	    ""
	#echo "provided"
	#getexe \
	    #ftp://ftp.hp.com/pub/softlib/software1/lj1488/lj-1145-2 \
	    #lj1488en.exe \
	    #sihp1000.img
	copyright "(c) Copyright Hewlett-Packard 2001"
	putfw sihp1000.img sihp1000.dl
	;;
    lj1005|1005)
	gettgz \
	    http://foo2zjs.rkkda.com/firmware sihp1005.tar.gz \
	    ""
	#echo "provided"
	#getexe \
	    #ftp://ftp.hp.com/pub/softlib/software2/COL2222/lj-10067-2 \
	    #lj1005hostbased-en.exe \
	    #sihp1005.img
	copyright "(c) Copyright Hewlett-Packard 2002"
	gettgz \
	    http://foo2zjs.rkkda.com/firmware sihpP1005.tar.gz \
	    ""
	copyright "(c) Copyright Hewlett-Packard 2009"
	putfw sihp1005.img sihp1005.dl
	;;
    lj1018|1018)
	gettgz \
	    http://foo2zjs.rkkda.com/firmware sihp1018.tar.gz \
	    ""
	copyright "(c) Copyright Hewlett-Packard 2005"
	putfw sihp1018.img sihp1018.dl
	;;
    lj1020|1020)
	# http://ftp.hp.com/pub/softlib/software8/COL14041/lj-39322-2/hp_LJ_1020-1022_Full_Solution.exe
	gettgz \
	    http://foo2zjs.rkkda.com/firmware sihp1020.tar.gz \
	    ""
	copyright "(c) Copyright Hewlett-Packard 2005"
	putfw sihp1020.img sihp1020.dl
	;;
    [pP]100[57])
	gettgz \
	    http://foo2zjs.rkkda.com/firmware sihpP1005.tar.gz \
	    ""
	copyright "(c) Copyright Hewlett-Packard 2009"
	putfw sihpP1005.img sihpP1005.dl
	;;
    [pP]100[68])
	gettgz \
	    http://foo2zjs.rkkda.com/firmware sihpP1006.tar.gz \
	    ""
	copyright "(c) Copyright Hewlett-Packard 2009"
	putfw sihpP1006.img sihpP1006.dl
	;;
    [pP]1505)
	gettgz \
	    http://foo2zjs.rkkda.com/firmware sihpP1505.tar.gz \
	    ""
	copyright "(c) Copyright Hewlett-Packard 2009"
	putfw sihpP1505.img sihpP1505.dl
	;;
    2200dl|2200)
	if true; then
	    gettgz \
		http://foo2zjs.rkkda.com/icm dl2300.tar.gz \
		""
	else
	    getexe \
		http://printer.konicaminolta.net/drivers/win2000 m22dlicc.exe \
		"*.icm"
	fi
	copyright "(c) Copyright Minolta-QMS 1999"
	puticm foo2zjs
	;;
    2300dl|2300)
	if true; then
	    gettgz \
		http://foo2zjs.rkkda.com/icm dl2300.tar.gz \
		""
	else
	    getexe \
		http://printer.konicaminolta.net/drivers/other m23dlicc.exe \
		"*.icm"
	fi
	gettgz \
	    http://foo2zjs.rkkda.com/icm km2430.tar.gz \
	    ""
	copyright "(c) Copyright Minolta-QMS 2001"
	puticm foo2zjs
	;;
    2300dl_fw)
	# 2300DL firmware upgrade to v2.55
	BASE="http://crm01.minoltaeurope.com"
	BASE="$BASE/openmind/technic/swfw/mswprtdl.nsf/logdwl"
	FILE="MC2300DL_v255.zip"
	URL="$BASE?openagent&4CE486C20839C75AC1256D9E001EBD1F/\$File/$FILE"
	wget $WGETOPTS "$URL" || error "Couldn't download $URL"
	echo "*** Now use a windows box to unzip and install $FILE ***"
	;;
    cpwl|pageworks)
	if true; then
	    gettgz \
		http://foo2zjs.rkkda.com/icm dl2300.tar.gz \
		""
	else
	    getexe \
		ftp://ftp.minolta-qms.com/pub/crc/out_going/windows cpplxp.exe \
		"*.IC_"
	    for i in C*.IC_
	    do
		base=`basename $i .IC_`
		mv $base.IC_ $base.ic_
		./msexpand $base.ic_
		rm -f $base.ic_
	    done
	fi
	copyright "(c) Copyright Minolta-QMS 1998"
	puticm foo2zjs
	;;
    2430)
	gettgz \
	    http://foo2zjs.rkkda.com/icm km2430.tar.gz \
	    ""
	copyright "(c) Copyright Konica Minolta 2003"
	puticm foo2zjs
	;;
    2530|2490|6115|2480|1600w|1680|1690|4690|110|6121)
	gettgz \
	    http://foo2lava.rkkda.com/icm km2530.tar.gz \
	    ""
	copyright "(c) Copyright Konica Minolta 2005"
	copyright "(c) Copyright Rick Richardson 2007.  All Rights Reserved"
	gettgz \
	    http://foo2lava.rkkda.com/icm km-1600.tar.gz \
	    ""
	copyright "(c) Copyright Rick Richardson 2009.  All Rights Reserved"
	puticm foo2lava
	;;
    1500)
	gettgz \
	    http://foo2hp.rkkda.com/icm hpclj2500.tar.gz \
	    ""
	copyright "(c) Copyright Hewlett-Packard 2002"
	gettgz \
	    http://foo2hp.rkkda.com/icm hpclj2600n.tar.gz \
	    ""
	copyright "(c) Copyright Hewlett-Packard 2003"
	copyright "(c) Copyright Rick Richardson 2006.  All Rights Reserved"
	puticm foo2oak
	;;
    1025)
	gettgz \
	    http://foo2zjs.rkkda.com/icm hp-cp1025.tar.gz \
	    ""
	copyright "(c) Copyright Rick Richardson 2010.  All Rights Reserved"
	puticm foo2zjs
	;;
    1215|1600|2600*)
	gettgz \
	    http://foo2hp.rkkda.com/icm hpclj2600n.tar.gz \
	    ""
	gettgz \
	    http://foo2zjs.rkkda.com/icm km2430.tar.gz \
	    "km2430_2.icm"
	copyright "(c) Copyright Hewlett-Packard 2003"
	copyright "(c) Copyright Rick Richardson 2006.  All Rights Reserved"
	gettgz \
	    http://foo2hp.rkkda.com/icm hp1215.tar.gz \
	    ""
	copyright "(c) Copyright Rick Richardson 2008.  All Rights Reserved"
	puticm foo2hp
	;;
    300|310|315|325|360|365|2160|3160|3175|3185|6110)
	gettgz \
	    http://foo2qpdl.rkkda.com/icm samclp300.tar.gz \
	    ""
	copyright "(c) Copyright Rick Richardson 2007.  All Rights Reserved"
	gettgz \
	    http://foo2qpdl.rkkda.com/icm samclp315.tar.gz \
	    ""
	copyright "(c) Copyright Rick Richardson 2008.  All Rights Reserved"
	puticm foo2qpdl
	;;
    600|610)
	;;

    500)
	gettgz \
	    http://foo2slx.rkkda.com/icm lexc500.tar.gz \
	    ""
	copyright "(c) Copyright Lexmark 2006"
	puticm foo2slx
	;;

    oki)
	echo "Please wait, ~20MB is being downloaded from a slow site..."
	getexe \
	    http://www.okiprintingsolutions.at/binaryData/16516/ \
	    ICCProfiles.zip \
	    "*OK3200*ICM" "*OK5600*ICM" "*rom732*7.zip"
	unzip -oj *rom732*7.zip "*C3400*ICM"
	rm -f *rom732*7.zip
	for i in OK*ICM C3400*ICM; do
	    base=`basename $i .ICM`
	    mv "$base.ICM" "$base.icm"
	done
	copyright "(c) Copyright Okidata 2005, 2006"
	puticm foo2hiperc
	;;
    301)
	gettgz \
	    http://foo2hiperc.rkkda.com/icm okic301.tar.gz \
	    ""
	copyright "(c) Copyright Okidata 2012"
	puticm foo2hiperc
	;;
    c310)
	gettgz \
	    http://foo2hiperc.rkkda.com/icm okic310.tar.gz \
	    ""
	copyright "(c) Copyright Okidata 2010"
	puticm foo2hiperc
	;;
    c511)
	gettgz \
	    http://foo2hiperc.rkkda.com/icm okic511.tar.gz \
	    ""
	copyright "(c) Copyright Okidata 2012"
	puticm foo2hiperc
	;;
    c810)
	gettgz \
	    http://foo2hiperc.rkkda.com/icm okic810.tar.gz \
	    ""
	copyright "(c) Copyright Okidata 2012"
	puticm foo2hiperc
	;;
    3100|3200|5100|5150|5200|5250)
	gettgz \
	    http://foo2hiperc.rkkda.com/icm okic3200.tar.gz \
	    ""
	copyright "(c) Copyright Okidata 2005"
	puticm foo2hiperc
	;;
    3300|3400|3530)
	gettgz \
	    http://foo2hiperc.rkkda.com/icm okic3400.tar.gz \
	    ""
	copyright "(c) Copyright Okidata 2006"
	puticm foo2hiperc
	;;
    5500|5600|5800|160)
	gettgz \
	    http://foo2hiperc.rkkda.com/icm okic5600.tar.gz \
	    ""
	copyright "(c) Copyright Okidata 2006"
	puticm foo2hiperc
	;;

    xPPD)
	# Snarf PPD files from linuxprinting
	[ -d PPD ] || mkdir PPD
	for i in foomatic-db/printer/*.xml
	do
	    case "$i" in
	    */Gen*)	continue;;
	    esac
	    printer=`basename $i .xml`
	    echo $printer
	    case "$printer" in
	    *1500*|*oak*)	driver=foo2oak;;
	    *)			driver=foo2zjs;;
	    esac
	    URL="http://www.linuxprinting.org/ppd-o-matic.cgi"
	    URL="$URL?driver=$driver&printer=$printer"
	    URL="$URL&.submit=Generate+PPD+file"
	    URL="$URL&show=1&.cgifields=shortgui&.cgifields=show"
	    wget $WGETOPTS -O PPD/$printer.ppd "$URL" ||
		error "Couldn't dowload $URL"
	done
	;;
    ppd)
	# Generate PPD files using local tools
	[ -d PPD ] || mkdir PPD
	for i in foomatic-db/printer/*.xml
	do
	    printer=`basename $i .xml`
	    echo $printer
	    case "$printer" in
	    *M1005*|*M1120*)	driver=foo2xqx;;
	    *P1[05]0[56]*)	driver=foo2xqx;;
	    *P2014*)		driver=foo2xqx;;
	    *M1212*)		driver=foo2xqx;;
	    *1500*|*OAKT*)	driver=foo2oak;;
	    *1600*|*2600*)	driver=foo2hp;;
	    *1215*)		driver=foo2hp;;
	    *2530*|*24[89]0*)	driver=foo2lava;;
	    *6115*)		driver=foo2lava;;
	    *C110*)		driver=foo2lava;;
	    *C500*)		driver=foo2slx;;
	    *C3[234]00*)	driver=foo2hiperc;;
	    *C5[12568]00*)	driver=foo2hiperc;;
	    *CLP*|*CLX*|*6110*)	driver=foo2qpdl;;
	    *)			driver=foo2zjs;;
	    esac
	    ENGINE=../foomatic/foomatic-db-engine
	    PERL5LIB=$ENGINE/lib $ENGINE/foomatic-ppdfile \
		-d $driver -p $printer \
		> PPD/$printer.ppd
		# | sed -e 's/\(^\*NickName.*\)"/\1 (foo2zjs recommended)"/'
	done
	;;
    "")
	usage
	;;
    *)
	error "Don't know how to get extra stuff for printer $1"
	;;
    esac
}

if [ $# = 0 ]; then
    echo "$VERSION"
    usage
fi

OLDPWD=`pwd`
NEWPWD=`mktemp --tmpdir --directory foo2zjs.XXXXXX`
cd "$NEWPWD"

for i in $*
do
    case "$1" in
    all)
	getone 1000
	getone 1005
	getone 1018
	getone 1020

	getone p1005
	getone p1006
	getone p1505

	getone 2200
	getone 2300
	# getone 2430 already done
	# getone cpwl # file doesn't exist 1/28/08

	getone 1500
	getone 2600n
	# getone 1215 # already done
	getone 1025

	getone 2530

	getone 300
	# getone 6110 already done
	getone 600

	getone 500

	getone 301
	getone c310
	getone c511
	getone c810
	getone 3200
	getone 3400
	getone 5600
	;;
    *)	
	getone $i
	;;
    esac
done

cd "$OLDPWD"
rmdir "$NEWPWD"