forked from portablejim/VeinMiner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·1917 lines (1601 loc) · 51.3 KB
/
install.sh
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
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
##############################################################################
##
## Canon Inkjet Printer Driver for Linux
## Copyright CANON INC. 2001-2013
## All Rights Reserved.
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; version 2 of the License.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
##
##############################################################################
C_version="4.00-1"
C_copyright_end="2013"
C_default_system="rpm"
L_INST_COM_01_01="Command executed = %s\n"
L_INST_COM_01_02="An error occurred. The package management system cannot be identified.\n"
L_INST_COM_01_03="An error occurred. A necessary package could not be found in the proper location.\n"
L_INST_COM_01_04="Installation has been completed.\n"
L_INST_COM_01_05="An error occurred. Your environment cannot be identified as 32-bit or 64-bit.\nTry to install again by using the following command.\n"
L_INST_COM_01_06="An error occurred. The specified environment differs from your environment.\nTry to install again by using the following command.\n"
L_INST_COM_02_01="Usage: %s\n"
L_INST_COM_02_02="Uninstallation has been completed.\n"
L_INST_COM_03_01="[Package]\n"
L_INST_PRN_00_01="Canon Inkjet Printer Driver"
L_INST_PRN_00_02="Version %s"
L_INST_PRN_00_03="Copyright CANON INC. %s-%s"
L_INST_PRN_00_04="All Rights Reserved."
L_INST_PRN_01_01="Register Printer\n"
L_INST_PRN_01_02="Next, register the printer to the computer.\n"
L_INST_PRN_01_03="Connect the printer, and then turn on the power.\nTo use the printer on the network, connect the printer to the network.\nWhen the printer is ready, press the Enter key.\n"
L_INST_PRN_01_04="Connection Method\n"
L_INST_PRN_01_05="USB\n"
L_INST_PRN_01_06="Network\n"
L_INST_PRN_01_07="Select the connection method.%s"
L_INST_PRN_01_08="Searching for printers...\n"
L_INST_PRN_01_09="Select Printer\n"
L_INST_PRN_01_10="Select the printer.\nIf the printer you want to use is not listed, select Update [0] to search again.\nTo cancel the process, enter [Q].\n"
L_INST_PRN_01_11="Update"
L_INST_PRN_01_12="Target printers detected (MAC address IP address)\n"
L_INST_PRN_01_13="Other printers detected (MAC address IP address)\n"
L_INST_PRN_01_14="Target printers detected\n"
L_INST_PRN_01_15="Other printers detected\n"
L_INST_PRN_01_16="Currently selected:%s %s\n"
L_INST_PRN_01_17="Enter the value."
L_INST_PRN_01_18="Could not detect the target printer.\n"
L_INST_PRN_01_19="Register Printer\n"
L_INST_PRN_01_20="Enter the printer name.%s"
L_INST_PRN_01_21="The printer name you entered already exists. Do you want to overwrite it?\nEnter [y] for Yes or [n] for No.%s"
L_INST_PRN_01_22="The printer name is invalid.\nYou can only use the following characters for the printer name:\n alphanumeric characters (a-z, A-Z, 0-9), \".\", \"-\", \"_\", \"+\", \"@\"\n"
L_INST_PRN_01_23="Set as Default Printer\n"
L_INST_PRN_01_24="Do you want to set this printer as the default printer?\nEnter [y] for Yes or [n] for No.%s"
L_INST_PRN_01_25="Printer Name : %s\n"
L_INST_PRN_01_26="Select this printer name for printing.\n"
L_INST_PRN_01_27="The printer registration has not been completed.\nRegister the printer manually by using the lpadmin command.\n"
L_INST_PRN_02_01="Uninstall Printer\n"
L_INST_PRN_02_02="All printer registration for this model will be deleted.\n"
L_INST_PRN_02_03="Do you want to continue?\nEnter [y] for Yes or [n] for No.%s"
L_INST_PRN_02_04="Failed to delete [%s].\nAfter the uninstall process is finished, delete this printer manually by using the lpadmin command.\n"
L_INST_PRN_02_05="Failed to delete printers.\nAfter the uninstall process is finished, delete these printers manually by using the lpadmin command.\n"
C_main_module="cnijfilter"
C_copyright_start="2001"
# internalversion : 3.20.01.005
#################################################################
#### C_function name define
#################################################################
C_function01="P_FUNC_MAIN_make_queue"
C_function02="P_FUNC_MAIN_delete_all_queue"
C_function03="P_FUNC_show_copyright"
#################################################################
#### path, filename, commandname, etc.
#################################################################
P_entry_list_path=""
P_entry_list_path_rpm="/usr/local/share/"
P_entry_list_path_deb="/usr/share/"
P_entry_list_dir="cnijfilter/"
P_entry_list_name="cnij_entry"
P_cupsd_command_1="/etc/init.d/cups"
P_cupsd_command_2="/etc/init.d/cupsys"
P_cupsd_command_current=""
P_lpadmin_command_full="/usr/sbin/lpadmin"
P_lpadmin_command_current=""
P_is_std_usb_backend=0
#################################################################
#### Show the copyright $1:version
#################################################################
P_FUNC_show_copyright()
{
# p_copyright1="Canon Inkjet Printer Driver Ver."$1" for Linux"
# p_copyright2="Copyright CANON INC. 2001-2011"
# p_copyright3="All Rights Reserved."
# echo $p_copyright1; echo $p_copyright2; echo $p_copyright3
printf "$L_INST_PRN_00_01\n"
printf "$L_INST_PRN_00_02\n" "$1"
printf "$L_INST_PRN_00_03\n" "$C_copyright_start" "$C_copyright_end"
printf "$L_INST_PRN_00_04\n"
}
#################################################################
#### Check if the model supports LAN or not.
#################################################################
p_FUNC_is_network_model()
{
local p_local_modelname_cif=""
local p_local_cif_output=""
local p_local_cif_command=""
local p_local_ret
#p_local_modelname_cif=`echo $P_printer_device | sed -e "s/series$//"`
p_local_modelname_cif=`expr $P_printer_device : '\(.\+\)series$'`
p_local_cif_command_tmp=cif$p_local_modelname_cif
p_local_cif_command=`whereis -b $p_local_cif_command_tmp | cut -d' ' -f2`
p_local_cif_output=`$p_local_cif_command --supportnetwork 2>&1`
if [ "$p_local_cif_output" = "1" ]; then
p_local_ret=1
elif [ "$p_local_cif_output" = "0" ]; then
p_local_ret=0
fi
return $p_local_ret
}
#################################################################
#### Add registered entry name to entry_list_file. $1:entry_list_file name $2:entry name to add
#################################################################
p_FUNC_write_entrydata_to_file()
{
local p_local_existentrys=""
p_local_existentrys=`cat $P_entry_list_fullname`
#to Upper case
p_local_name_to_write=`echo "$2" | tr a-z A-Z`
# set delimiter
IFS='
'
#-----------------------------
# Check entry list file (If same name exists, you should not to add entry name)
#-----------------------------
for line in ${p_local_existentrys}; do
if [ -n "$line" ]; then
#to Upper case
line=`echo "$line" | tr a-z A-Z`
if [ "$p_local_name_to_write" = "$line" ]; then
# same name exist in the entry_list_file -> restore delimiter and return.
IFS=$IFS_ORG
return 1
fi
fi
done
# restore delimiter.
IFS=$IFS_ORG
# add
local p_local_entry="'"$2"'"
${P_printer_sudo_command}sh -c "echo $p_local_entry >> $1"
return 0
}
#################################################################
#### Delete registered entry name from entry_list_file. $1:entry name to delete
#################################################################
p_FUNC_delete_entryname_from_file()
{
local p_local_list_of_files=""
local p_local_existentrys=""
local p_local_list_of_entries=""
local p_local_out_flg=0
p_local_list_of_files=`ls ${P_entry_list_path}/${P_entry_list_name}* 2> /dev/null`
if [ $? -ne 0 ]; then
return 1
fi
# set delimiter
IFS='
'
#to Upper case
p_local_target_name=`echo "$1" | tr a-z A-Z`
for file_name in $p_local_list_of_files; do
p_local_existentrys=`cat $file_name`
#-----------------------------
# Check entry list file (If same name exists, you should not to add entry name)
#-----------------------------
p_local_out_flg=0
p_local_list_of_entries=""
for line in ${p_local_existentrys}; do
if [ -n "$line" ]; then
#to Upper case
upper_val=`echo "$line" | tr a-z A-Z`
if [ "$p_local_target_name" = "$upper_val" ]; then
p_local_out_flg=1
continue
else
p_local_list_of_entries=${p_local_list_of_entries}${line}"\n"
fi
fi
done
# add
if [ $p_local_out_flg -eq 1 ]; then
IFS=$IFS_ORG
local p_local_out="'"$p_local_list_of_entries"'"
${P_printer_sudo_command}bash -c "echo -n -e $p_local_out > $file_name"
IFS='
'
fi
done
# restore delimiter.
IFS=$IFS_ORG
return 0
}
#################################################################
#### Exec command for printer $1:command to exec $2:1..show execution command
#################################################################
p_FUNC_show_and_exec_printer()
{
if [ $2 -eq 1 ]; then
printf "$L_INST_COM_01_01" "$1"
fi
$1 1> /dev/null #show error message only
return $?
}
#################################################################
#### Get "cups" command
#################################################################
p_FUNC_get_cupsd_command()
{
local p_local_service_command_tmp=""
local p_local_service_command=""
local p_local_systemctl_command_tmp=""
local p_local_systemctl_command=""
#-----------------------------
# Check "systemctl" command
#-----------------------------
p_local_systemctl_command_tmp=`whereis -b systemctl`
p_local_systemctl_command=`echo -n ${p_local_systemctl_command_tmp} | cut -s -d' ' -f2`
if [ -n "$p_local_systemctl_command" ]; then
${p_local_systemctl_command} status cups.service 1> /dev/null
if [ $? -eq 0 ]; then
P_cupsd_command_current=${P_printer_sudo_command}${p_local_systemctl_command}" restart cups.service"
return 0
fi
fi
#-----------------------------
# Check "service" command
#-----------------------------
p_local_service_command_tmp=`whereis -b service`
p_local_service_command=`echo -n ${p_local_service_command_tmp} | cut -s -d' ' -f2`
if [ -n "$p_local_service_command" ]; then
${p_local_service_command} cups status 1> /dev/null
if [ $? -eq 0 ]; then
P_cupsd_command_current=${P_printer_sudo_command}${p_local_service_command}" cups restart"
return 0
fi
fi
#-----------------------------
# Check "/etc/init.d/cups"
#-----------------------------
if [ -f "$P_cupsd_command_1" ]; then
P_cupsd_command_current=${P_printer_sudo_command}${P_cupsd_command_1}" restart"
return 0
fi
#-----------------------------
# Check "/etc/init.d/cupsys"
#-----------------------------
if [ -f "$P_cupsd_command_2" ]; then
P_cupsd_command_current=${P_printer_sudo_command}${P_cupsd_command_2}" restart"
return 0
fi
return 127 #error
}
#################################################################
#### Get "lpadmin" command
#################################################################
p_FUNC_get_lpadmin_command()
{
#-----------------------------
# Check "/usr/sbin/lpamin"
#-----------------------------
if [ -f "$P_lpadmin_command_full" ]; then
P_lpadmin_command_current=${P_printer_sudo_command}$P_lpadmin_command_full
return 0
fi
#-----------------------------
# Get fullpath by "whereis" and check it.
#-----------------------------
lpadmin_path_tmp=`whereis -b lpadmin`
lpadmin_path=`echo ${lpadmin_path_tmp} | cut -d' ' -f2`
if [ -z "$lpadmin_path" ]; then
lpadmin_path=`echo ${lpadmin_path_tmp} | cut -d\t -f2`
fi
if [ "$lpadmin_path" ]; then
if [ -f "$lpadmin_path" ]; then
P_lpadmin_command_current=${P_printer_sudo_command}$lpadmin_path
return 0
fi
fi
return 127 #error
}
#################################################################
#### Select "Yes" or "No". $1:message
#### (Loop until "yes" or "no" selected)
#################################################################
p_FUNC_check_yes_no()
{
local p_local_result=-1 # neither "Yes" nor "No"
while [ $p_local_result -eq -1 ]; do
printf "$1" "[y]"
read -r CMD
#Change to uppercase
CMD=`echo $CMD | tr a-z A-Z`
case $CMD in
"") p_local_result=1;;
"Y") p_local_result=1;;
"YES") p_local_result=1;;
"N") p_local_result=0;;
"NO") p_local_result=0;;
esac
done
return $p_local_result
}
#################################################################
#### Make entry name to suggest(default value) $1:base entry name (ex:"MP640")
#################################################################
p_FUNC_make_default_entryname()
{
local p_local_count=0
local p_local_entry_name=""
local p_local_result=""
p_local_entry_name=$1
while [ -z "${p_local_result}" ]; do
if [ $p_local_count -ge 1 ]; then
p_local_entry_name=$1"-"$p_local_count
fi
p_FUNC_check_entry_exist $p_local_entry_name
if [ $? -ne 0 ]; then
p_local_result=""
else
p_local_result=$p_local_entry_name
fi
#
p_local_count=`expr $p_local_count + 1`
done
# echo $p_local_result
P_DEF_ENTRYNAME=$p_local_result
# return 0
}
#################################################################
#### Check if the entry name exists or not. $1:entry name to check
#### 0:not exist 1:exist in cnij_entrys 2:exist in /etc/cups/ppd
#################################################################
p_FUNC_check_entry_exist()
{
#-----------------------------
# Check the return value of "cngpij --checkentryexist entryname" (new)
#-----------------------------
# local p_local_entry="'"$1"'"
cngpij --checkentryexist "$1" >& /dev/null
if [ $? -eq 0 ]; then #exist
return 1
fi
return 0 # Same name is not found
}
#################################################################
#### Check if the entry name is valid. $1:entry name to check
#### 0:invalid 1:valid
#################################################################
p_FUNC_is_valid_entry_name()
{
local p_local_tmpname=""
p_local_tmpname="$1"
case "$p_local_tmpname" in
*[^a-zA-Z0-9\.\+\-\_\@]*)
return 0;; #NG
*)
return 1;; #OK
esac
}
#################################################################
####
#################################################################
p_FUNC_execute_prepare_process()
{
local p_local_command=""
p_local_command=`whereis -b ldconfig | cut -d' ' -f2`
`${P_printer_sudo_command}${p_local_command}`;
}
#################################################################
#### Make printer list to show from backend output data. S1:USB or LAN string
#################################################################
p_FUNC_make_printer_list_from_backenddata()
{
# initialize
local p_local_current_model=""
local p_local_cn_uri=""
local p_local_srch_result=""
local p_local_fax_term=""
local p_local_dvice_uri=""
local p_local_ip_add=""
local p_local_current=""
local p_local_current_upper=""
local p_local_display_line=""
local p_local_is_std_usb_backend=0
P_target_model_list=""
P_other_model_list=""
P_target_model_num=0
P_other_model_num=0
P_is_std_usb_backend=0
# P_DEF_ENTRYNAME:all uppercase..
p_local_current_model=$P_DEF_ENTRYNAME
# show message...
printf "\n"
printf "$L_INST_PRN_01_08"
#-----------------------------
# Restart cupsd. (just before device detection)
#-----------------------------
# $P_cupsd_command_current restart 1> /dev/null #show error message only
$P_cupsd_command_current 1> /dev/null #show error message only
if [ $? -ne 0 ]; then
printf "$L_INST_PRN_01_27"
exit #quit immediately
fi
#-----------------------------
# Execute device search
#-----------------------------
if [ "$1" = "LAN" ]; then
p_local_srch_result=`${P_printer_sudo_command}cnijlgmon2 --installer_net`
else
p_local_srch_result=`${P_printer_sudo_command}cnijlgmon2 --installer_usb`
fi
#-----------------------------
# Make printer list array with detected printers
#-----------------------------
# set delimiter
IFS='
'
for line in ${p_local_srch_result}; do
#line=`echo -n ${line}`
#line=${line//\"/\\\"}
# Extract the 3rd field("Canon MX320 series") and set to value.
#value=`perl -e '"'$line'" =~ /\"(Canon.+?)\"/;print $1'`
value=`expr $line : '.*"\(Canon[^"]*series[^"]*\)"'`
# Skip FAX device
p_local_fax_term=""
if [ "$value" ]; then
p_local_fax_term=`expr $value : '.*\(FAX\).*$'`
fi
if [ "$p_local_fax_term" ]; then
continue
fi
# Extract the 2nd field(/00-1E-8F-0E-1D-44) and set to dvice_uri.
p_local_cn_uri=`echo ${line} | cut -d' ' -f2`
p_local_dvice_uri=`echo ${p_local_cn_uri} | cut -d':' -f2`
# If the I/F is LAN, delete "/" and add IPP address.
if [ "$1" = "LAN" ]; then
#p_local_dvice_uri=`echo ${p_local_dvice_uri} | cut -d'/' -f2`
p_local_dvice_uri=`expr ${p_local_dvice_uri} : '.*serial=\(.\+\)'`
#p_local_ip_add=`perl -e '"'$line'" =~ /\"(IP.+)\"/;print $1'`
p_local_ip_add=`expr $line : '.*"\(IP[^"]*\).*$'`
#p_local_ip_add=`echo $p_local_ip_add | sed -e "s/^IP://" ` #new
p_local_ip_add=`expr $p_local_ip_add : 'IP:\(.\+\)'`
p_local_dvice_uri=$p_local_dvice_uri" "$p_local_ip_add
fi
if [ "${value}" != "" ]; then
p_local_current=`echo ${value} | cut -d' ' -f2`
p_local_current_upper=`echo $p_local_current | tr a-z A-Z`
# fix backend
P_is_std_usb_backend=${p_local_is_std_usb_backend}
if [ "${p_local_current_upper}" = "${p_local_current_model}" ]; then # If target model..
P_target_model_num=`expr $P_target_model_num + 1` # arrya number starts with "1".
p_local_display_line="${P_target_model_num}) ${value} (${p_local_dvice_uri})"
P_target_model_list[P_target_model_num]=$p_local_display_line
else # If other model...
P_other_model_num=`expr ${P_other_model_num} + 1` # arrya number starts with "101".
p_local_display_line="`expr $P_other_model_num + 100`) ${value} (${p_local_dvice_uri})"
P_other_model_list[P_other_model_num]=$p_local_display_line
fi
fi
done
# restore delimiter
IFS=$IFS_ORG
# echo "P_target_model_num=$P_target_model_num"
# echo "P_other_model_num=$P_other_model_num"
}
#################################################################
#### Select device from printer lists menu. S1:backend name
#################################################################
p_FUNC_select_printer_from_list()
{
P_ans=''
local p_local_defaultnum
local p_local_target_list_title
local p_local_other_list_title
local p_local_current_num
local p_local_indata
local p_local_indata_for_array
#-----------------------------
# Set default selection.
#-----------------------------
if [ $P_target_model_num -eq 0 ]; then
p_local_defaultnum=0
else
p_local_defaultnum=1
fi
# Set list titles according to backend name.
if [ "$1" != "LAN" ]; then
p_local_target_list_title="$L_INST_PRN_01_14"
p_local_other_list_title="$L_INST_PRN_01_15"
else
p_local_target_list_title="$L_INST_PRN_01_12"
p_local_other_list_title="$L_INST_PRN_01_13"
fi
#-----------------------------
# Show printer list
#-----------------------------
printf "\n"
printf "\n"
printf "#=========================================================#\n"
printf "# $L_INST_PRN_01_09"
printf "#=========================================================#\n"
printf "$L_INST_PRN_01_10"
printf -- "-----------------------------------------------------------\n"
printf " 0) $L_INST_PRN_01_11\n"
printf -- "-----------------------------------------------------------\n"
if [ $P_target_model_num -gt 0 ]; then
printf "$p_local_target_list_title"
# for current in ${P_target_model_list[@]}; do
# echo $current
# done
for (( i=0; i<$P_target_model_num; i++ ))
{
p_local_current_num=`expr $i + 1`
echo ${P_target_model_list[p_local_current_num]}
}
else
printf "$L_INST_PRN_01_18"
fi
echo "-----------------------------------------------------------"
if [ $P_other_model_num -gt 0 ]; then
printf "$p_local_other_list_title"
# for current in ${P_other_model_list[@]}; do
# echo $current
# done
for (( i=0; i<$P_other_model_num; i++ ))
{
p_local_current_num=`expr $i + 1`
echo ${P_other_model_list[p_local_current_num]}
}
echo "-----------------------------------------------------------"
fi
#-----------------------------
# Show default choice
#-----------------------------
if [ $p_local_defaultnum -eq 0 ]; then
printf "$L_INST_PRN_01_16" "[0]" "$L_INST_PRN_01_11" > /dev/stderr
else
tmp_selected=${P_target_model_list[${p_local_defaultnum}]}
tmp_selected=`echo $tmp_selected | cut -d " " -f 2-`
printf "$L_INST_PRN_01_16" "[1]" "$tmp_selected" > /dev/stderr
fi
#-----------------------------
# Loop until valid selection is done...
#-----------------------------
# set delimiter
IFS='
'
while [ -z "${P_ans}" ]; do
# Please select...
printf "$L_INST_PRN_01_17 [${p_local_defaultnum}]" > /dev/stderr
IFS=$IFS_ORG
read -r p_local_indata
IFS='
'
# Enter(not select number) -> deault value selected
if [ "${p_local_indata}" = "" ] ; then
p_local_indata=${p_local_defaultnum}
fi
# Check the inputted data.
#to Upper case
p_local_indata=`echo $p_local_indata | tr a-z A-Z`
case "$p_local_indata" in
# "0"(re-search) -> return 0 immediately
"0")
# restore delimiter and return.
IFS=$IFS_ORG
return 1;;
# "Q"(quit) -> return 2 immediately
"Q")
# restore delimiter and return.
IFS=$IFS_ORG
return 2;;
*[^0-9]*)
# contain characters other than number(0-9).-> invaild -> back to input step.
P_ans='';;
*)
# valid -> go to next step.
# Verify inputted value
# Check if the choice is target model or not.
if [ "${p_local_indata}" -ge 1 -a "${p_local_indata}" -le 100 ] 2> /dev/null; then #1-100: target model
if [ "${p_local_indata}" -ge 1 -a "${p_local_indata}" -le "${P_target_model_num}" ] 2> /dev/null; then
P_ans=${P_target_model_list[${p_local_indata}]}
else
:
fi
else #101-: other model
p_local_indata_for_array=`expr $p_local_indata - 100`
if [ "${p_local_indata_for_array}" -ge 1 -a "${p_local_indata_for_array}" -le "${P_other_model_num}" ] 2> /dev/null; then
P_ans=${P_other_model_list[${p_local_indata_for_array}]}
else
:
fi
fi
esac
done
#echo "select num is ${P_ans}"
# restore delimiter and return.
IFS=$IFS_ORG
return 0
}
#################################################################
#### Make DeviceURI $1:USB or LAN string, $2:printer list line
#################################################################
p_FUNC_make_uri()
{
# set delimiter
IFS='
'
# echo "choice=$2"
local p_local_uri=""
# Extract "00-00-85-CE-9B-17 172.21.81.49"or"/dev/usb/lp0"
#p_local_uri=`perl -e '"'$2'" =~ /\((.+)\)/;print $1'`
p_local_uri=`expr $2 : '.*(\(.\+\)).*$'`
# If I/F is LAN: "00-00-85-CE-9B-17 172.21.81.49" -> "00-00-85-CE-9B-17" -> "/00-00-85-CE-9B-17"
if [ "$1" = "LAN" ]; then #LAN
p_local_uri=`echo $p_local_uri | cut -d' ' -f1`
p_local_uri="//Canon/?port=net&serial="$p_local_uri
fi
P_current_uri=$p_local_uri
# echo P_current_uri="$P_current_uri"
# restore delimiter
IFS=$IFS_ORG
}
#################################################################
#### Entry creation main $1:complete message $2:device("mp640series") $3:system("rpm")
#################################################################
P_FUNC_MAIN_make_queue()
{
IFS_ORG=$IFS
#echo ""
#echo "## Driver packages installed. ##"
P_printer_device=$2
# make P_printer_sudo_command
if [ "$3" = "rpm" ]; then
P_printer_sudo_command=""
P_entry_list_path=${P_entry_list_path_rpm}${P_entry_list_dir}
else
P_printer_sudo_command="sudo "
P_entry_list_path=${P_entry_list_path_deb}${P_entry_list_dir}
fi
####################################
### Make entry_list file (blank file).
####################################
if [ ! -d $P_entry_list_path ]; then
${P_printer_sudo_command}mkdir -p $P_entry_list_path 2> /dev/null
fi
P_entry_list_fullname=$P_entry_list_path${P_entry_list_name}_${P_printer_device}
${P_printer_sudo_command}touch $P_entry_list_fullname
####################################
### prepare command.
####################################
p_FUNC_get_cupsd_command
if [ $? -ne 0 ]; then
printf "$L_INST_PRN_01_27"
exit #quit immediately
fi
# echo "cups=$P_cupsd_command_current"
p_FUNC_get_lpadmin_command
if [ $? -ne 0 ]; then
printf "$L_INST_PRN_01_27"
exit #quit immediately
fi
# echo "lpadmin=$P_lpadmin_command_current"
p_FUNC_execute_prepare_process
####################################
### Registration start
####################################
printf "\n"
printf "#=========================================================#\n"
printf "# $L_INST_PRN_01_01"
printf "#=========================================================#\n"
printf "$L_INST_PRN_01_02"
printf "$L_INST_PRN_01_03"
echo -n "> "
read CMD
####################################
### Restart cupsd. -> moved to "p_FUNC_make_printer_list_from_backenddata" (just before device detection)
####################################
####################################
### Check if LAN I/F is supported.
####################################
local p_local_SUPPORT_LAN=0
p_FUNC_is_network_model
if [ $? -eq 1 ]; then
p_local_SUPPORT_LAN=1
fi
####################################
### Select I/F. (If LAN is not supported, skip this step.)
####################################
local p_local_BACKENDNAME=""
local p_local_I_F=""
if [ "${p_local_SUPPORT_LAN}" -eq 1 ]; then
printf "\n"
printf "#=========================================================#\n"
printf "# $L_INST_PRN_01_04"
printf "#=========================================================#\n"
printf " 1) $L_INST_PRN_01_05"
printf " 2) $L_INST_PRN_01_06"
while [ -z "$p_local_I_F" ]; do
printf "$L_INST_PRN_01_07" "[1]"
read -r CMD
case $CMD in
"") #USB
p_local_BACKENDNAME="cnijbe"
p_local_I_F="USB";;
"1") #USB
p_local_BACKENDNAME="cnijbe"
p_local_I_F="USB";;
"2") #Network
p_local_BACKENDNAME="cnijbe"
p_local_I_F="LAN";;
esac
done
else
#Skip I/F select step
p_local_BACKENDNAME="cnijbe"
p_local_I_F="USB_NOTSELECT"
fi
####################################
### Search printer devices and show list.
####################################
### P_DEF_ENTRYNAME..."MX860"
#Cut "series" from device
local p_local_SHOTMODELNAME=""
#p_local_SHOTMODELNAME=`echo $P_printer_device | sed -e "s/series$//"`
p_local_SHOTMODELNAME=`expr $P_printer_device : '\(.\+\)series$'`
#Change to uppercase
P_DEF_ENTRYNAME=`echo $p_local_SHOTMODELNAME | tr a-z A-Z`
retvalue=1
until [ $retvalue -eq 0 ]
do
#Search printers.
#ver400 p_FUNC_make_printer_list_from_backenddata $p_local_BACKENDNAME
p_FUNC_make_printer_list_from_backenddata $p_local_I_F
#Show printer list.
#ver400 p_FUNC_select_printer_from_list $p_local_BACKENDNAME
p_FUNC_select_printer_from_list $p_local_I_F
retvalue=$?
if [ $retvalue -eq 0 ]; then #some device selected -> re-search
:
elif [ $retvalue -eq 1 ]; then #"0" selected -> re-search
echo ""
printf "$L_INST_PRN_01_03"
echo -n "> "
read CMD #wait enter...
elif [ $retvalue -eq 2 ]; then #"Q" selected -> exit immediately
printf "$L_INST_PRN_01_27"
exit #quit immediately
fi
done
# echo "P_ans=$P_ans"
# make URI
P_current_uri=""
p_FUNC_make_uri "$p_local_I_F" "$P_ans"
####################################
### Input entry name
####################################
### Make default name
# P_DEF_ENTRYNAME + I/F
if [ "$p_local_I_F" = "USB_NOTSELECT" ]; then
P_DEF_ENTRYNAME=$P_DEF_ENTRYNAME
else
P_DEF_ENTRYNAME=$P_DEF_ENTRYNAME$p_local_I_F
fi
# Make default(pre-set) entry name.
p_FUNC_make_default_entryname $P_DEF_ENTRYNAME
local p_local_ENTRYNAME=""
local p_local_remake_flag=0
printf "\n"
printf "#=========================================================#\n"
printf "# $L_INST_PRN_01_19"
printf "#=========================================================#\n"
while [ -z "$p_local_ENTRYNAME" ]; do
p_local_ENTRYNAME=""
printf "$L_INST_PRN_01_20[$P_DEF_ENTRYNAME]"
read -r p_local_ENTRYNAME
case "$p_local_ENTRYNAME" in
"") # use default name
p_local_ENTRYNAME=$P_DEF_ENTRYNAME;;
esac
# Check if specified name is valid.
p_FUNC_is_valid_entry_name "$p_local_ENTRYNAME"
if [ $? -eq 0 ]; then # invalid printer name
printf "$L_INST_PRN_01_22"
p_local_ENTRYNAME=""
echo ""
continue
fi
# Check if the specified name is already exist.
p_FUNC_check_entry_exist $p_local_ENTRYNAME
if [ $? -ne 0 ]; then
#If the entry_name exists, ask if overwrite or not.
p_FUNC_check_yes_no "$L_INST_PRN_01_21"
if [ $? -eq 0 ]; then #No -> back to input step
p_local_ENTRYNAME=""
echo ""
else #Yes-> set "p_local_remake_flag" 1
p_local_remake_flag=1
fi
else
:
fi