Cài Driver Canon các dòng máy LBP trên Linux (hoạt động với CUPS).

0
43
(Last Updated On: Th1 21, 2024)

Tải về trên thư mục hiện hành:

https://vngeek.com/wp-content/uploads/2024/01/cndrvcups-common_3.21-1_amd64.deb
https://vngeek.com/wp-content/uploads/2024/01/cndrvcups-capt_2.71-1_amd64.deb
https://vngeek.com/wp-content/uploads/2024/01/canon_lbp_setup.sh

Trong đó có Driver của máy Canon và phần điều khiển cho CUPS.

Sau đó chạy lệnh sau để cấp quyền thực thi và tiến hành cài đặt:

chmod +x canon_lbp_setup.sh
./canon_lbp_setup.sh

Trên đây là cách nhanh nhất mà không tốn quá nhiều thời gian. Tuy nhiên có thể phát sinh lỗi thì các bạn có thể làm thủ công theo các bước tiếp theo ở dưới:

Trường hợp bạn muốn cài đặt 1 cách thủ công thì tải về 2 tập tin Driver common và capt về và chạy lệnh:

 dpkg -i cndrvcups-common_3.21-1_amd64.deb
 dpkg -i cndrvcups-capt_2.71-1_amd64.deb

Nếu xuất hiện lỗi như hình trên thì chúng ta có thể dùng lệnh sau để sửa chữa:

apt install libgtk2.0-0
apt --fix-broken install

Nếu cài trên Ubuntu Desktop, gặp lỗi:

Khi đó cần cài gói:

apt install libglade2-0

Làm theo các bước bạn sẽ thành công.

sudo apt update
sudo apt install cups
sudo systemctl start cups

sudo systemctl status cups
sudo systemctl enable cups
sudo cp /etc/cups/cupsd.conf /etc/cups/cupsd.conf.copy
sudo nano /etc/cups/cupsd.conf

Tiếp theo dưới đây là nội dung phần cấu hình có thể hoạt động được:

#
# Configuration file for the CUPS scheduler.  See "man cupsd.conf" for a
# complete description of this file.
#

# Log general information in error_log - change "warn" to "debug"
# for troubleshooting...
LogLevel warn
PageLogFormat

# Specifies the maximum size of the log files before they are rotated.  The value "0" disables log rotation.
MaxLogSize 0

# Default error policy for printers
ErrorPolicy retry-job

# Only listen for connections from the local machine.
Listen 631
Listen /run/cups/cups.sock

# Show shared printers on the local network.
Browsing On
BrowseLocalProtocols dnssd

# Default authentication type, when authentication is required...
DefaultAuthType Basic

# Web interface setting...
WebInterface Yes

# Timeout after cupsd exits if idle (applied only if cupsd runs on-demand - with -l)
IdleExitTimeout 60

# Restrict access to the server...
<Location />
  Order allow,deny
Allow @LOCAL
</Location>

# Restrict access to the admin pages...
<Location /admin>
  Order allow,deny
Allow @LOCAL
</Location>

# Restrict access to configuration files...
<Location /admin/conf>
  AuthType Default
  Require user @SYSTEM
  Order allow,deny
</Location>

# Restrict access to log files...
<Location /admin/log>
  AuthType Default
  Require user @SYSTEM
  Order allow,deny
</Location>

# Set the default printer/job policies...
<Policy default>
  # Job/subscription privacy...
  JobPrivateAccess default
  JobPrivateValues default
  SubscriptionPrivateAccess default
  SubscriptionPrivateValues default

  # Job-related operations must be done by the owner or an administrator...
  <Limit Create-Job Print-Job Print-URI Validate-Job>
    Order deny,allow
  </Limit>

  <Limit Send-Document Send-URI Hold-Job Release-Job Restart-Job Purge-Jobs Set-Job-Attributes Create-Job-Subscription Renew-Subscription Cancel-Subscription Get-Notifications Reprocess-Job Cancel-Current-Job Suspend-Current-Job Resume-Job Cancel-My-Jobs Close-Job CUPS-Move-Job CUPS-Get-Document>
    Require user @OWNER @SYSTEM
    Order deny,allow
  </Limit>

  # All administration operations require an administrator to authenticate...
  <Limit CUPS-Add-Modify-Printer CUPS-Delete-Printer CUPS-Add-Modify-Class CUPS-Delete-Class CUPS-Set-Default CUPS-Get-Devices>
    AuthType Default
    Require user @SYSTEM
    Order deny,allow
  </Limit>

  # All printer operations require a printer operator to authenticate...
  <Limit Pause-Printer Resume-Printer Enable-Printer Disable-Printer Pause-Printer-After-Current-Job Hold-New-Jobs Release-Held-New-Jobs Deactivate-Printer Activate-Printer Restart-Printer Shutdown-Printer Startup-Printer Promote-Job Schedule-Job-After Cancel-Jobs CUPS-Accept-Jobs CUPS-Reject-Jobs>
    AuthType Default
    Require user @SYSTEM
    Order deny,allow
  </Limit>

  # Only the owner or an administrator can cancel or authenticate a job...
  <Limit Cancel-Job CUPS-Authenticate-Job>
    Require user @OWNER @SYSTEM
    Order deny,allow
  </Limit>

  <Limit All>
    Order deny,allow
  </Limit>
</Policy>

# Set the authenticated printer/job policies...
<Policy authenticated>
  # Job/subscription privacy...
  JobPrivateAccess default
  JobPrivateValues default
  SubscriptionPrivateAccess default
  SubscriptionPrivateValues default

  # Job-related operations must be done by the owner or an administrator...
  <Limit Create-Job Print-Job Print-URI Validate-Job>
    AuthType Default
    Order deny,allow
  </Limit>

  <Limit Send-Document Send-URI Hold-Job Release-Job Restart-Job Purge-Jobs Set-Job-Attributes Create-Job-Subscription Renew-Subscription Cancel-Subscription Get-Notifications Reprocess-Job Cancel-Current-Job Suspend-Current-Job Resume-Job Cancel-My-Jobs Close-Job CUPS-Move-Job CUPS-Get-Document>
    AuthType Default
    Require user @OWNER @SYSTEM
    Order deny,allow
  </Limit>

  # All administration operations require an administrator to authenticate...
  <Limit CUPS-Add-Modify-Printer CUPS-Delete-Printer CUPS-Add-Modify-Class CUPS-Delete-Class CUPS-Set-Default>
    AuthType Default
    Require user @SYSTEM
    Order deny,allow
  </Limit>

  # All printer operations require a printer operator to authenticate...
  <Limit Pause-Printer Resume-Printer Enable-Printer Disable-Printer Pause-Printer-After-Current-Job Hold-New-Jobs Release-Held-New-Jobs Deactivate-Printer Activate-Printer Restart-Printer Shutdown-Printer Startup-Printer Promote-Job Schedule-Job-After Cancel-Jobs CUPS-Accept-Jobs CUPS-Reject-Jobs>
    AuthType Default
    Require user @SYSTEM
    Order deny,allow
  </Limit>

  # Only the owner or an administrator can cancel or authenticate a job...
  <Limit Cancel-Job CUPS-Authenticate-Job>
    AuthType Default
    Require user @OWNER @SYSTEM
    Order deny,allow
  </Limit>

  <Limit All>
    Order deny,allow
  </Limit>
</Policy>

# Set the kerberized printer/job policies...
<Policy kerberos>
  # Job/subscription privacy...
  JobPrivateAccess default
  JobPrivateValues default
  SubscriptionPrivateAccess default
  SubscriptionPrivateValues default

  # Job-related operations must be done by the owner or an administrator...
  <Limit Create-Job Print-Job Print-URI Validate-Job>
    AuthType Negotiate
    Order deny,allow
  </Limit>

  <Limit Send-Document Send-URI Hold-Job Release-Job Restart-Job Purge-Jobs Set-Job-Attributes Create-Job-Subscription Renew-Subscription Cancel-Subscription Get-Notifications Reprocess-Job Cancel-Current-Job Suspend-Current-Job Resume-Job Cancel-My-Jobs Close-Job CUPS-Move-Job CUPS-Get-Document>
    AuthType Negotiate
    Require user @OWNER @SYSTEM
    Order deny,allow
  </Limit>

  # All administration operations require an administrator to authenticate...
  <Limit CUPS-Add-Modify-Printer CUPS-Delete-Printer CUPS-Add-Modify-Class CUPS-Delete-Class CUPS-Set-Default>
    AuthType Default
    Require user @SYSTEM
    Order deny,allow
  </Limit>

  # All printer operations require a printer operator to authenticate...
  <Limit Pause-Printer Resume-Printer Enable-Printer Disable-Printer Pause-Printer-After-Current-Job Hold-New-Jobs Release-Held-New-Jobs Deactivate-Printer Activate-Printer Restart-Printer Shutdown-Printer Startup-Printer Promote-Job Schedule-Job-After Cancel-Jobs CUPS-Accept-Jobs CUPS-Reject-Jobs>
    AuthType Default
    Require user @SYSTEM
    Order deny,allow
  </Limit>

  # Only the owner or an administrator can cancel or authenticate a job...
  <Limit Cancel-Job CUPS-Authenticate-Job>
    AuthType Negotiate
    Require user @OWNER @SYSTEM
    Order deny,allow
  </Limit>

  <Limit All>
    Order deny,allow
  </Limit>
</Policy>

Sau đó thêm người dùng vào để cấu hình trên trang admin không gặp lỗi:

sudo usermod -aG lpadmin phatnlq

Đừng quên chạy lệnh dưới đây để máy in có thể hiện diện tự động mà không cần phải tìm trên các thiết bị như di động hay máy tính bảng:

apt install cups-ipp-utils
systemctl restart cups

Cấu hình thêm:

lpadmin -p LBP3300 -m CNCUPSLBP3300CAPTK.ppd -v ccp://localhost:59687 -E
ccpdadmin -p LBP3300 -o net:192.168.1.24

/etc/init.d/ccpd start

Như dòng trên là mình sử dụng máy in mạng với địa chỉ IP 192.168.1.24. Cái này bạn cần cấu hình trên máy Windows nhé.

Trên Ubuntu Desktop chúng ta có thể thấy giờ đây xuất hiện máy in:

Chính xác hơn một chút:

/usr/sbin/lpadmin -p LBP3300 -P /usr/share/cups/model/CNCUPSLBP3300CAPTK.ppd -v ccp://localhost:59687 -E

/usr/sbin/ccpdadmin -p LBP3300 -o net:192.168.1.24

Đừng quên chạy lệnh:

/etc/init.d/ccpd start

Như thế là tương đối xong rồi đó.

Giờ có thể lên một máy tính khác, kết nối mạng nội bộ và bạn có thể in qua máy này mà không cần cài Driver. Trên iPhone, iPad sẽ tự hiện luôn. Android thì hơi chập chờn xí nhưng vẫn in ok luôn.

P/S:

Fix i386 (Trong trường hợp cài đặt Driver 64 bit nhưng cần thư viện 32 bit):

sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386

Nội dung cài đặt bạn cũng có thể tham khảo thêm:

## This gist contains step by step instructions of installing canon LBP3300 printer driver on ubuntu 18.04 machine
## After a couple of months painful trying, i finally got it successfully installed on my 18.04 ubuntu machine.

## Here is the requirement
# 1) For 64 bit linux version install necessary the libraries 
# 2) install the official CAPT drivers
# 3) register the printer with lpadmin 
# 4) register the printer with the ccpd daemon


### step-1
sudo apt-get install libglade2 libpopt0:i386 libxml2:i386 libjpeg62:i386 libstdc++6:i386
# for libglade2. manually download and install it form here https://packages.debian.org/wheezy/libglade2-0  
wget http://ftp.cn.debian.org/debian/pool/main/libg/libglade2/libglade2-0_2.6.4-1_amd64.deb
sudo dpkg -i libglade2-0_2.6.4-1_amd64.deb


### step-2
# download official CAPT driver
# for south asian region download it from here http://support-in.canon-asia.com/contents/ASIA/EN/0100459601.html
# first install the common module for CUPS driver 
sudo dpkg -i cndrvcups-common_3.21-1_amd64.deb
# then install Install the CAPT printer driver module.
sudo dpkg -i cndrvcups-capt_2.71-1_amd64.deb 
# for broken packages 
sudo apt install -f


### step-3
# restart cups
sudo /etc/init.d/cups restart
# now register the LBP3300 printer (PPD) with the print spooler.
# sudo /usr/sbin/lpadmin -p LBP3300 -m CNCUPSLBP3300CAPTK.ppd -v ccp://localhost:59687 –E
sudo /usr/sbin/lpadmin -p LBP3300 -P /usr/share/cups/model/CNCUPSLBP3300CAPTK.ppd -v ccp://localhost:59687 -E

### step-4
# register the printer in the ccpd daemon setup file for first printer (lp0)
sudo /usr/sbin/ccpdadmin -p LBP3300 -o /dev/usb/lp0
# finaly restart the ccpd daemon
sudo /etc/init.d/ccpd restart


# for successful installation check
# ask capt for a status report on the LBP3300
captstatusui -P LBP3300
# try to print a test page. and 
# if it print then  !!!! BOOM !!!! 

# start ccpd daemon by
sudo /etc/init.d/ccpd start

Hoặc sau khi cài CUPS, các bạn cài Driver Capt và Common tại đây cho các dòng máy in khác: https://github.com/hieplpvip/ubuntu_canon_printer

P/S: Tạo daemon khởi động cho ccpd:

Khởi động dịch vụ máy in Canon (ccpd) theo yêu cầu khi gắn máy in (bất kỳ máy in nào).

Điều kiện tiên quyết: cài đặt gói driver máy in Canon từ website của Canon theo hướng dẫn.

Đặt tệp ccpd2.service vào thư mục /etc/systemd/system và chạy lệnh systemctl daemon-reload && systemctl enable ccpd2 với quyền root.

Tệp này được gọi là cppd2.service vì systemd ánh xạ tập lệnh /etc/init.d/ccpd đi kèm với gói trình điều khiển máy in sang tên cppd. Bất kỳ tên nào khác ngoài cppd.service cũng được.

Nội dung tập tin ccpd2.service:

[Unit]
Description=Printer daemon for Canon printers
Requires=cups.service
After=cups.service

[Service]
ExecStart=/usr/sbin/ccpd
Type=forking

[Install]
# To run the daemon always when the system is up
#WantedBy=multi-user.target
# To run the daemon when a printer is attached
WantedBy=printer.target

Bình luận