LoginSignup
1
1

More than 3 years have passed since last update.

RaspberryPiをGoogleCloudPrint対応プリンタサーバにする(cups)

Posted at

これはなに

使っているプリンタの、Google Cloud Print 機能がいま一つ不安定。ときどき使えなくなる。
不都合なので、RaspberryPIをプリントサーバにし、Google Cloud Print に接続した。
安定して稼働するようになった。

参考

以下を参考にさせていただきました。ありがとうございます。
はじめての自宅サーバ構築 - Fedora/CentOS -
ともの技術メモ Google Cloud Print Connectorを設定

手順

cupsのインストール

cupsをインストールし、プリンタサーバにする。

sudo apt install cups

設定ファイル/etc/cups/cupsd.confの変更。変更箇所は5か所です。

sudo nano /etc/cups/cupsd.conf
1か所目
# Only listen for connections from the local machine.
# Listen localhost:631
# Port631 を追記。ポート631をlocalhost以外に開放
Port 631
Listen 631 
Listen /run/cups/cups.sock

2~5か所目
# 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
# 設定ファイルへのアクセスを開放
  Allow @Local

</Location>
# Restrict access to log files...
<Location /admin/log>
  AuthType Default
  Require user @SYSTEM
  Order allow,deny
# ログファイルへのアクセスを開放
  Allow @Local
</Location>

cupsを再起動する。

sudo systemctl restart cups.service

操作するユーザがlpadminグループに所属していなければ、追加します。

sudo usermod -aG lpadmin ユーザ名

webページ http://192.168.0.**:631 で管理ページを開き、ユーザ名でログインします。
GUI 管理画面で、プリンタを追加します。

google-cloud-print-connectorのインストール

aptコマンドでインストールします。

sudo apt install google-cloud-print-connector

gcpの初期化をします。

その後は、参考の
ともの技術メモ Google Cloud Print Connectorを設定
さんの手順と寸分変わりませんので、そちらをご参照ください。正確な最新情報をありがとうございます。

install_gcp_service.sh
#!/bin/bash

sudo useradd -M -s /usr/sbin/nologin cloud-print-connector
sudo mkdir /opt/cloud-print-connector
sudo ln -s /usr/bin/gcp-cups-connector /opt/cloud-print-connector/gcp-cups-connector
sudo cp gcp-cups-connector.config.json /opt/cloud-print-connector/.
sudo chown cloud-print-connector.cloud-print-connector /opt/cloud-print-connector/gcp-cups-connector.config.json 
ls -la /opt/cloud-print-connector/gcp-cups-connector.config.json
wget https://raw.githubusercontent.com/google/cloud-print-connector/master/systemd/cloud-print-connector.service
sleep 10
install -o root -m 0664 cloud-print-connector.service /etc/systemd/system
sudo systemctl enable cloud-print-connector.service
sudo systemctl start cloud-print-connector.service
sudo systemctl status cloud-print-connector.service
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1