LoginSignup
4
3

More than 1 year has passed since last update.

そうだ 録画サーバー 作ろう (CentOS8 + PX-W3PE4)

Last updated at Posted at 2020-05-05

録画サーバーを作ってGWも引きこもろう (GW連休もあと1日だけになっちゃったけど)

環境

  • CentOS 8
    (on ESXi 6.5.0U3 on HP Microserver G7 N54L)
  • PX-W3PE4
  • スマートカードリーダー (数百円で買える中国製)

セットアップ

OSのインストール

  • Minimumでインストール
  • SELinux は無効化済み
  • Chrony でNTPクライアント設定

ESXi の設定

  • 仮想マシン設定でUSBデバイス PX-W3PE4 と カードリーダー をアタッチ

  • [仮想マシン オプション]タブで [詳細] > [構成パラメータ] へ下記を追加
    (これをしないとカードリーダーが接続済みにならなかった。)

usb.generic.allowCCID = TRUE  

必要なパッケージのインストール

  • PowerToolsリポジトリを有効化
# vi /etc/yum.repos.d/CentOS-PowerTools.repo
  :
enabled=1
  :
  • EPELリポジトリをインストール
# dnf -y install epel-release
  • コンパイラなど必要なパッケージまとめてインストール
# dnf -y install wget git unzip bzip2 gcc gcc-c++ make autogen automake dkms kernel-devel kernel-headers patch perl-ExtUtils-MakeMaker libtool openssl-devel boost-devel cmake

カードリーダ系のツールインストール

  • カードリーダドライバのインストール
# dnf -y install ccid
  • pcsc-perlのインストール
# dnf -y install pcsc-lite-devel
# cd /usr/local/src/
# wget http://search.cpan.org/CPAN/authors/id/W/WH/WHOM/pcsc-perl-1.4.14.tar.bz2
# tar xvjf pcsc-perl-1.4.14.tar.bz2
# cd pcsc-perl-1.4.14
# perl Makefile.PL
# make
# make install
  • pcsc-toolsのインストール
# cd /usr/local/src/
# wget https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/pcsc-tools/1.5.5-1/pcsc-tools_1.5.5.orig.tar.bz2
# tar xvjf pcsc-tools_1.5.5.orig.tar.bz2
# cd pcsc-tools-1.5.5/
# ./configure
# make
# make install
  • スマートカードリーダーのデーモンの有効化
# systemctl enable pcscd
# systemctl start pcscd
  • 動作確認
# pcsc_scan
  :
        Japanese Chijou Digital B-CAS Card (pay TV)
  :
[Ctrl+c]

B25ライブラリインストール

# cd /usr/local/src/
# git clone https://github.com/stz2012/libarib25.git
# cd libarib25/
# cmake .
# make
# make install
# echo /usr/local/lib64 > /etc/ld.so.conf.d/usr-local-lib.conf
# ldconfig

W3PE4ドライバインストール

非公式ドライバを使います

  • ファームウェアのインストール
# cd /usr/local/src/
# git clone https://github.com/nns779/px4_drv
# cd px4_drv/fwtool
# make
# wget http://plex-net.co.jp/plex/pxw3u4/pxw3u4_BDA_ver1x64.zip -O pxw3u4_BDA_ver1x64.zip
# unzip pxw3u4_BDA_ver1x64.zip
# ./fwtool pxw3u4_BDA_ver1x64/PXW3U4.sys it930x-firmware.bin
# cp -p it930x-firmware.bin /lib/firmware/
  • ドライバのインストールをDKMSで行うためのスクリプト
# cd /usr/local/src/
# cd px4_drv/
# vi install.sh
install.sh
#!/bin/bash

. ./dkms.conf
cp -a `pwd` /usr/src/$PACKAGE_NAME-$PACKAGE_VERSION
dkms add -m $PACKAGE_NAME -v $PACKAGE_VERSION
dkms build -m $PACKAGE_NAME -v $PACKAGE_VERSION
dkms install -m $PACKAGE_NAME -v $PACKAGE_VERSION
# chmod +x install.sh
  • ついでにアンイストールスクリプト
# vi uninstall.sh
uninstall.sh
#!/bin/bash

. ./dkms.conf
dkms remove -m $PACKAGE_NAME -v $PACKAGE_VERSION --all
rm -vrf /usr/src/$PACKAGE_NAME-$PACKAGE_VERSION
# chmod +x uninstall.sh
  • ドライバのインストール
# ./install.sh
# modprobe px4_drv
  • デバイスの認識確認
# ll /dev/px4video*

録画コマンドインストール

# wget http://plex-net.co.jp/download/linux/Linux_Driver.zip
# unzip Linux_Driver.zip
# cd Linux_Driver/MyRecpt1/MyRecpt1/recpt1
# sed -i".org" 's/-DTV/video/g' pt1_dev.h
# ./configure --enable-b25
# make
# make install
  • 一般ユーザーでもカードリーダーを使えるようにPolicyKitを設定
# vi /usr/share/polkit-1/rules.d/org.debian.pcsc-lite.rules
org.debian.pcsc-lite.rules
polkit.addRule(function(action, subject) {
  if (
    action.id == "org.debian.pcsc-lite.access_pcsc"
  ) {
    return polkit.Result.YES;
  }
});

polkit.addRule(function(action, subject) {
  if (
    action.id == "org.debian.pcsc-lite.access_card"
  ) {
    return polkit.Result.YES;
  }
});
  • 動作確認
$ recpt1 --b25 --strip 27 10 test.ts

これで難しいハードウェア類の接続はできるようになった。

あとはMirakurunとかChinachuとか入れると便利らしいが、とりあえずここまで。

参考サイト

4
3
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
4
3