diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index cd60a12..0000000 --- a/.dockerignore +++ /dev/null @@ -1,5 +0,0 @@ -recorded -chinachu/conf/rules.json -chinachu/data/* -mirakurun/data/* - diff --git a/README.md b/README.md index b1f9fc2..3b359b6 100755 --- a/README.md +++ b/README.md @@ -1,130 +1,103 @@ # docker-mirakurun-chinachu -Mirakurun と Chinachu をDockerコンテナに閉じ込めました -## Constitution -### Mirakurun -- Alpine Linux 3.8(node:10-alpine) -- [Mirakurun](https://github.com/Chinachu/Mirakurun) - - branch: master +[Mirakurun](https://github.com/Chinachu/Mirakurun) + [Chinachu](https://github.com/Chinachu/Chinachu) の Docker コンテナ -### Chinachu -- Alpine Linux 3.8(node:10-alpine) -- [Chinachu](https://github.com/Chinachu/Chinachu) - - branch: gamma - -## 動作確認環境 -> OS ->>CentOS Linux release 7.2.1511 (Core) ->> Linux 3.10.0-327.22.2.el7.x86_64 -> ->>Fedora release 25 (Twenty Five) ->> Linux 4.9.4-201.fc25.x86_64 -> ->>Fedora release 27 (Twenty Seven) ->> Linux 4.18.12-100.fc27.x86_64 -> ->>Fedora release 30 (Thirty) ->> Linux 5.2.18-200.fc30.x86_64 - ->Docker ->>version 1.11.2, build b9f10c9 ->>version 17.03.0-ce, build 60ccb22 ->>version 1.13.1, build 9c9378f-unsupported ->>version 1.13.1, build 47e2230/1.13.1 - ->Tuner ->>ISDB-S, ISDB-T Tuner PT3 - ->Smart card reader ->>USB SmartCard Reader NTT Communications Corp. SCR3310-NTTCom - -## 利用方法 -- 最新のdocker & docker-compose がインストール済 -- SELinuxの無効化 -- ホストマシンにPT3 Driverがインストール済 -``` -$ ls -l /dev/pt*video* -crw-rw-rw- 1 root video 246, 0 Jun 26 16:07 /dev/pt3video0 -crw-rw-rw- 1 root video 246, 1 Jun 26 16:07 /dev/pt3video1 -crw-rw-rw- 1 root video 246, 2 Jun 26 16:07 /dev/pt3video2 -crw-rw-rw- 1 root video 246, 3 Jun 26 16:07 /dev/pt3video3 -``` -- B-CAS 用に利用するスマートカードリーダーはMirakurunコンテナ内で管理しますので -ホストマシン上のpcscdは停止してください +## 前提条件 + +- [Docker](https://docs.docker.com/engine/install/), [Docker Compose](https://docs.docker.com/compose/install/linux/#install-using-the-repository)の導入が必須 +- ホスト上の pcscd は停止する +- DVBドライバ非対応のチューナーはホストへのドライバのインストールが必須 ([例](https://github.com/tsukumijima/px4_drv)) + +## インストール手順 + +```sh +#取得 +git clone https://github.com/chinachu/docker-mirakurun-chinachu +cd docker-mirakurun-chinachu + +#各種設定 +nano ./compose.yaml + +#mirakurunをセットアップ +sudo docker compose run --rm -e SETUP=true mirakurun + +#DVBドライバ非対応チューナー向け +cp ./mirakurun/opt/bin/startup.sample ./mirakurun/opt/bin/startup +sudo nano ./mirakurun/opt/bin/startup +sudo chmod +x ./mirakurun/opt/bin/startup +sudo nano ./mirakurun/config/tuners.yml + +#チャンネル設定 +sudo nano ./mirakurun/config/channels.yml ``` -sudo systemctl stop pcscd.socket -sudo systemctl disable pcscd.socket + +## 起動 + +```sh +sudo docker compose up -d --remove-orphans ``` -- docker-composeを利用しておりますので、プロジェクトディレクトリ内で下記コマンドを実行してください -プロジェクトディレクトリ名はビルド時のレポジトリ名になりますので、適当に短いフォルダ名が推奨です +## 状態確認 -### 取得例 -```shell -git clone https://github.com/Chinachu/docker-mirakurun-chinachu.git tvs -cd tvs +```sh +sudo docker compose ps ``` -### 起動 -```shell -docker-compose up -d + +## ログ + +```sh +sudo docker compose logs -f [chinachu|mirakurun] ``` -### 停止 -```shell -docker-compose down + +## 停止 + +```sh +sudo docker compose down ``` -### デーモン化(systemd) -初期では「WorkingDirectory」が「/usr/local/projects/tvs/」となっています -設置した箇所に応じて、書き換えてください -```shell -vi mirakurun-user.service -vi chinachu-user.service +## 更新 + +```sh +sudo docker compose up -d --pull always --build --force-recreate --remove-orphans +sudo docker container prune -f +sudo docker image prune -f +sudo docker builder prune -f +sudo docker volume prune -f +sudo docker network prune -f ``` -ユーザ固有サービスとして動かすため、設定します -```shell -mkdir -p ~/.config/systemd/user/ -mv mirakurun-user.service ~/.config/systemd/user/ -mv chinachu-user.service ~/.config/systemd/user/ -## 永続化(次回OS起動時に自動で起動) -systemctl --user enable mirakurun-user.service -systemctl --user enable chinachu-user.service -sudo loginctl enable-linger `whoami` - -# 手動起動 -systemctl --user start mirakurun-user.service -systemctl --user start chinachu-user.service - -# 動作確認 -systemctl --user status mirakurun-user.service -systemctl --user status chinachu-user.service - -# 手動停止 -systemctl --user stop mirakurun-user.service -systemctl --user stop chinachu-user.service +## 初期化 +```sh +sudo docker compose down -v --rmi all --remove-orphans ``` ## 設定 -エリア、環境によって変更が必要なファイルは下記の通りとなります + ### Mirakurun -- ポート番号 : 40772 -- mirakurun/conf/tuners.yml -チューナー設定 -- mirakurun/conf/channels.yml -チャンネル設定 + +* ポート番号: 40772 ### Chinachu -- ポート番号 : 10772, 20772(local network only), 5353/udp(mDNS) -- chinachu/conf/config.json -チューナー設定 -チャンネル設定 - -### 録画ファイル保存先 -また録画ファイルはプロジェクトフォルダ内の./recordedに保存されます -> 保存先を別HDDにしたい場合は、docker-compose.ymlの ->> ./recorded:/usr/local/chinachu/recorded -> -> の./recordedを変更することで保存先を変更可能 + +* ポート番号: 20772 + +### 各種ファイル保存先 + +* 録画データ + + `./recorded/` + +* Mirakurun 設定ファイル + + `./mirakurun/config/` + +* Mirakurun OPT + + `./mirakurun/opt/` + +* Chinachu 設定ファイル + + `./chinachu/config/` ## License -This software is released under the MIT License, see LICENSE. +This software is released under the MIT License, see LICENSE. \ No newline at end of file diff --git a/chinachu-user.service b/chinachu-user.service deleted file mode 100644 index 4ccb4d9..0000000 --- a/chinachu-user.service +++ /dev/null @@ -1,15 +0,0 @@ -[Unit] -Description=Chinachu -Requires=mirakurun-user.service -After=mirakurun-user.service - -[Service] -Type=simple -RemainAfterExit=yes -Restart=on-failure -WorkingDirectory=/usr/local/projects/tvs -ExecStart=/usr/local/bin/docker-compose up -d chinachu -ExecStop=/usr/local/bin/docker-compose stop chinacnu - -[Install] -WantedBy=default.target diff --git a/chinachu/Dockerfile b/chinachu/Dockerfile index 2d121a0..9e694a9 100755 --- a/chinachu/Dockerfile +++ b/chinachu/Dockerfile @@ -1,67 +1,68 @@ -FROM node:10-alpine + # 使用するベースイメージを14-alpineに更新する。マルチステージビルドを利用して最終イメージをよりクリーンにする。 +FROM docker.io/library/node:14-alpine AS build + +RUN set -x && \ +\ + # パッケージを更新 + apk upgrade -U --no-cache && \ +\ + # ビルドに必要なパッケージを導入 + apk add -U --no-cache alpine-sdk python3 git bash && \ +\ + # Gitの設定を変更しChinachuをクローンできるようにする。 + git config --global http.version HTTP/1.1 && \ +\ + # Chinachuをサブモジュールごとクローン + git clone --recursive https://github.com/chinachu/chinachu /src && \ +\ + # 必要なディレクトリを作成 + mkdir /src/data/ /src/log/ /src/run/ /src/recorded/ /build/ && \ +\ + # ビルドに必要なファイルのみを移動する。 + mv /src/common /src/package*json /build/ && \ + cd /build/ && \ +\ + # Chinachuをビルド + npm install && \ + npm update && \ + npm audit fix + + # processes.jsonをDockerや実行ユーザnodeでも使用可能なものに置き換える。 +COPY ./processes.json /src/ + + +####最終イメージ + + # node:14-alpineは既にメンテナンスされていない為、最新のパッケージを使用できるようにalpine:latestを取得する。 +FROM docker.io/library/alpine:latest AS update_baseImage + + # ベースイメージ +FROM docker.io/library/node:14-alpine LABEL maintainer "h-mineta " -ENV DOCKER="YES" -ARG REPOSITORY="https://github.com/Chinachu/Chinachu.git" -ARG BRANCH="master" + # パッケージリポジトリの設定を更新 +COPY --from=update_baseImage /etc/apk/repositories /etc/apk/repositories + + # Chinachuのビルドとソースを、所有者をnodeとしてコピーする。 +COPY --chown=node:node --from=build /src/ /app/ +COPY --chown=node:node --from=build /build/ /app/ + + # ワーキングディレクトリを設定 +WORKDIR /app/ -ARG WORK_DIR="/usr/local/chinachu" + # ポートを開放 +EXPOSE 20772 -#node container default value -ARG USER_NAME="node" + # パッケージを更新 +RUN apk upgrade -U --no-cache && \ -RUN set -x \ - && apk upgrade --update \ - && apk add \ - bash \ - coreutils \ - curl \ - procps \ - ca-certificates \ - \ - && apk add --virtual .build-deps \ - git \ - make \ - gcc \ - g++ \ - autoconf \ - automake \ - wget \ - curl \ - sudo \ - tar \ - xz \ - libc-dev \ - musl-dev \ - eudev-dev \ - libevent-dev \ - perl-utils \ - \ - && mkdir -p ${WORK_DIR} \ - && git clone ${REPOSITORY} ${WORK_DIR} \ - && chown -R ${USER_NAME} ${WORK_DIR} \ - && cd ${WORK_DIR} \ - && git checkout ${BRANCH} \ - && echo 2 | sudo -u ${USER_NAME} ./chinachu installer \ - && echo 4 | sudo -u ${USER_NAME} ./chinachu installer \ - && echo 5 | sudo -u ${USER_NAME} ./chinachu installer \ - && sudo -u ${USER_NAME} ./chinachu service operator initscript | tee /tmp/chinachu-operator \ - && sudo -u ${USER_NAME} ./chinachu service wui initscript | tee /tmp/chinachu-wui \ - && sudo -u ${USER_NAME} mkdir log \ - \ - && chmod u+x /tmp/chinachu-operator /tmp/chinachu-wui \ - && mv /tmp/chinachu-operator /etc/init.d/ \ - && mv /tmp/chinachu-wui /etc/init.d/ \ - \ - # cleaning - && cd / \ - && npm cache verify \ - && apk del --purge .build-deps \ - && rm -rf /var/cache/apk/* + # 動作に必要なパッケージを導入 + apk add -U --no-cache curl ffmpeg bash coreutils procps-ng ca-certificates && \ + npm install pm2 -g -COPY services.sh /usr/local/bin -COPY config.sample.json ${WORK_DIR} + # コンテナ内の実行ユーザをnodeとする。 +USER node:node -WORKDIR ${WORK_DIR} -CMD ["/usr/local/bin/services.sh"] -EXPOSE 10772 20772 5353 + # コンテナをchinachuが起動する実行ファイルとする。 +ENTRYPOINT ["pm2-runtime"] +CMD ["./processes.json"] \ No newline at end of file diff --git a/chinachu/config.sample.json b/chinachu/config.sample.json deleted file mode 100755 index f1bc2a2..0000000 --- a/chinachu/config.sample.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "uid" : "node", - "recordedDir" : "/usr/local/chinachu/recorded/", - "temporaryDir": "/tmp/", - - "wuiUsers": [ - "akari:bakuhatsu" - ], - "wuiAllowCountries": ["JP"], - - "wuiPort" : 10772, - "wuiHost" : "::", - "wuiTlsKeyPath" : null, - "wuiTlsCertPath" : null, - "wuiOpenServer" : false, - "wuiOpenPort" : 20772, - "wuiXFF" : false, - "wuiPreviewer" : true, - "wuiStreamer" : true, - "wuiFiler" : true, - "wuiConfigurator" : true, - "wuiMdnsAdvertisement": true, - - "mirakurunPath": "http://container-mirakurun:40772/", - - "recordedFormat": "[][][].m2ts", - - "storageLowSpaceAction": "remove" -} diff --git a/chinachu/config/config.json b/chinachu/config/config.json new file mode 100644 index 0000000..320acac --- /dev/null +++ b/chinachu/config/config.json @@ -0,0 +1,49 @@ +{ + "uid": "node", + "gid": "video", + "mirakurunPath": "http://mirakurun:40772", + + "recordedDir" : "./recorded/", + + "vaapiEnabled": false, + "vaapiDevice": "/dev/dri/renderD128", + + "excludeServices": [ + 3273701416, + 3232728088, + 3273901183, + 3274201456, + 3239123992, + 3239123993, + 3273601408 + ], + + "serviceOrder": [ + 3273601024, + 3273601025, + 3273701032, + 3273701033, + 3273701034 + ], + + "wuiUsers": "null", + "wuiAllowCountries": ["JP"], + + "wuiPort": null, + "wuiHost": "0.0.0.0", + "wuiTlsKeyPath": null, + "wuiTlsCertPath": null, + "wuiTlsRequestCert": false, + "wuiTlsRejectUnauthorized": true, + "wuiTlsCaPath": null, + "wuiOpenServer": true, + "wuiOpenPort": 20772, + "wuiXFF": false, + "wuiMdnsAdvertisement": true, + + "recordedFormat": "[<date:yymmdd-HHMM>][<type><channel>][<channel-name>]<title>.m2ts", + "storageLowSpaceThresholdMB": 3000, + "storageLowSpaceAction": "remove", + "storageLowSpaceNotifyTo": null, + "storageLowSpaceCommand": "" + } \ No newline at end of file diff --git a/chinachu/config/config.sample.json b/chinachu/config/config.sample.json new file mode 100644 index 0000000..320acac --- /dev/null +++ b/chinachu/config/config.sample.json @@ -0,0 +1,49 @@ +{ + "uid": "node", + "gid": "video", + "mirakurunPath": "http://mirakurun:40772", + + "recordedDir" : "./recorded/", + + "vaapiEnabled": false, + "vaapiDevice": "/dev/dri/renderD128", + + "excludeServices": [ + 3273701416, + 3232728088, + 3273901183, + 3274201456, + 3239123992, + 3239123993, + 3273601408 + ], + + "serviceOrder": [ + 3273601024, + 3273601025, + 3273701032, + 3273701033, + 3273701034 + ], + + "wuiUsers": "null", + "wuiAllowCountries": ["JP"], + + "wuiPort": null, + "wuiHost": "0.0.0.0", + "wuiTlsKeyPath": null, + "wuiTlsCertPath": null, + "wuiTlsRequestCert": false, + "wuiTlsRejectUnauthorized": true, + "wuiTlsCaPath": null, + "wuiOpenServer": true, + "wuiOpenPort": 20772, + "wuiXFF": false, + "wuiMdnsAdvertisement": true, + + "recordedFormat": "[<date:yymmdd-HHMM>][<type><channel>][<channel-name>]<title>.m2ts", + "storageLowSpaceThresholdMB": 3000, + "storageLowSpaceAction": "remove", + "storageLowSpaceNotifyTo": null, + "storageLowSpaceCommand": "" + } \ No newline at end of file diff --git a/chinachu/conf/rules.json b/chinachu/config/rules.json old mode 100755 new mode 100644 similarity index 100% rename from chinachu/conf/rules.json rename to chinachu/config/rules.json diff --git a/chinachu/config/rules.sample.json b/chinachu/config/rules.sample.json new file mode 100644 index 0000000..0637a08 --- /dev/null +++ b/chinachu/config/rules.sample.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/chinachu/data/.gitignore b/chinachu/data/.gitignore deleted file mode 100644 index d6b7ef3..0000000 --- a/chinachu/data/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/chinachu/processes.json b/chinachu/processes.json new file mode 100644 index 0000000..dcf1581 --- /dev/null +++ b/chinachu/processes.json @@ -0,0 +1,34 @@ +{ + "apps": [ + { + "name": "chinachu-wui", + "script": "app-wui.js", + "error_file": "./log/chinachu-wui.stderr.log", + "out_file": "./log/chinachu-wui.stdout.log", + "merge_logs": true, + "pid_file": "./run/chinachu-wui.pid", + "exec_mode": "fork", + "autorestart": true, + "env": { + "NODE_ENV": "production", + "LOG_STDOUT": "./log/chinachu-wui.stdout.log", + "LOG_STDERR": "./log/chinachu-wui.stderr.log" + } + }, + { + "name": "chinachu-operator", + "script": "app-operator.js", + "error_file": "./log/chinachu-operator.stderr.log", + "out_file": "./log/chinachu-operator.stdout.log", + "merge_logs": true, + "pid_file": "./run/chinachu-operator.pid", + "exec_mode": "fork", + "autorestart": true, + "env": { + "NODE_ENV": "production", + "LOG_STDOUT": "./log/chinachu-operator.stdout.log", + "LOG_STDERR": "./log/chinachu-operator.stderr.log" + } + } + ] + } \ No newline at end of file diff --git a/chinachu/services.sh b/chinachu/services.sh deleted file mode 100755 index dbd7fb7..0000000 --- a/chinachu/services.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash -if [ ! -s config.json ]; then - cat config.sample.json > config.json -fi - -rm -f /var/run/chinachu-operator.pid > /dev/null 2>&1 -rm -f /var/run/chinachu-wui.pid > /dev/null 2>&1 - -countdown_max=300 -run_countdown=0 -while [ ${run_countdown} -le ${countdown_max} ] -do - http_status=`curl -s container-mirakurun:40772/api/status -o /dev/null -w '%{http_code}'` - if [ "${http_status}" = "200" ]; then - run_countdown=0 - echo "mirakurun is run complete!" - break - fi - run_countdown=`expr ${run_countdown} + 1` - echo "wait for mirakurun to run...(${run_countdown}sec)" - sleep 1 -done - -if [ ${run_countdown} -ge ${countdown_max} ]; then - echo "mirakurun is timeout" -fi - -/etc/init.d/chinachu-operator start -/etc/init.d/chinachu-wui start - -tail -f /dev/null diff --git a/compose-sample.yaml b/compose-sample.yaml new file mode 100644 index 0000000..a49e2a5 --- /dev/null +++ b/compose-sample.yaml @@ -0,0 +1,102 @@ +########## mirakurunの設定 ########## +x-mirakurun-tuners: &mirakurun-tuners + # mirakurunで使用するチューナーやカードリーダ等のデバイスを以下に列挙する。 + - "/dev/bus:/dev/bus" + - "/dev/dvb:/dev/dvb" + +x-mirakurun-ports: &mirakurun-ports + # mirakurunを公開するホスト側のポートを指定する。 + published: 40772 + + +########## chinachuの設定 ########## +x-chinachu-recorded: &chinachu-recorded + # chinachuの録画を保存するホスト側のディレクトリを指定する。 + source: ./recorded/ + +x-chinachu-ports: &chinachu-ports + # chinachuを公開するホスト側のポートを指定する。 + published: 20772 + + +########## 開発者向け ########## +services: + + mirakurun: + image: docker.io/chinachu/mirakurun:latest + container_name: mirakurun + ports: + - target: 40772 + <<: *mirakurun-ports + cap_add: + - SYS_ADMIN + - SYS_NICE + environment: + TZ: "Asia/Tokyo" + # LOG_LEVEL: "3" + # DEBUG: "true" + devices: *mirakurun-tuners + volumes: + - type: bind + source: ./mirakurun/opt/ + target: /opt/ + - type: bind + source: ./mirakurun/config/ + target: /app-config/ + - type: volume + source: mirakurun + target: /app-data/ + restart: always + logging: + driver: json-file + options: + max-file: "2" + max-size: "5m" + compress: "true" + healthcheck: + test: curl -fsSL http://localhost:40772/api/status || exit 1 + interval: 10s + timeout: 3s + + chinachu: + image: chinachu/chinachu:latest + build: + context: ./chinachu/ + container_name: chinachu + ports: + - target: 20772 + <<: *chinachu-ports + volumes: + - type: bind + source: /etc/localtime + target: /etc/localtime + read_only: true + - type: bind + source: ./chinachu/config/config.json + target: /app/config.json + - type: bind + source: ./chinachu/config/rules.json + target: /app/rules.json + - type: volume + source: chinachu + target: /app/data/ + - type: bind + <<: *chinachu-recorded + target: /app/recorded/ + depends_on: + mirakurun: + condition: service_healthy + restart: always + logging: + driver: "json-file" + options: + max-file: "2" + max-size: "5m" + compress: "true" + + +volumes: + mirakurun: + name: "mirakurun" + chinachu: + name: "chinachu" \ No newline at end of file diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 0000000..a49e2a5 --- /dev/null +++ b/compose.yaml @@ -0,0 +1,102 @@ +########## mirakurunの設定 ########## +x-mirakurun-tuners: &mirakurun-tuners + # mirakurunで使用するチューナーやカードリーダ等のデバイスを以下に列挙する。 + - "/dev/bus:/dev/bus" + - "/dev/dvb:/dev/dvb" + +x-mirakurun-ports: &mirakurun-ports + # mirakurunを公開するホスト側のポートを指定する。 + published: 40772 + + +########## chinachuの設定 ########## +x-chinachu-recorded: &chinachu-recorded + # chinachuの録画を保存するホスト側のディレクトリを指定する。 + source: ./recorded/ + +x-chinachu-ports: &chinachu-ports + # chinachuを公開するホスト側のポートを指定する。 + published: 20772 + + +########## 開発者向け ########## +services: + + mirakurun: + image: docker.io/chinachu/mirakurun:latest + container_name: mirakurun + ports: + - target: 40772 + <<: *mirakurun-ports + cap_add: + - SYS_ADMIN + - SYS_NICE + environment: + TZ: "Asia/Tokyo" + # LOG_LEVEL: "3" + # DEBUG: "true" + devices: *mirakurun-tuners + volumes: + - type: bind + source: ./mirakurun/opt/ + target: /opt/ + - type: bind + source: ./mirakurun/config/ + target: /app-config/ + - type: volume + source: mirakurun + target: /app-data/ + restart: always + logging: + driver: json-file + options: + max-file: "2" + max-size: "5m" + compress: "true" + healthcheck: + test: curl -fsSL http://localhost:40772/api/status || exit 1 + interval: 10s + timeout: 3s + + chinachu: + image: chinachu/chinachu:latest + build: + context: ./chinachu/ + container_name: chinachu + ports: + - target: 20772 + <<: *chinachu-ports + volumes: + - type: bind + source: /etc/localtime + target: /etc/localtime + read_only: true + - type: bind + source: ./chinachu/config/config.json + target: /app/config.json + - type: bind + source: ./chinachu/config/rules.json + target: /app/rules.json + - type: volume + source: chinachu + target: /app/data/ + - type: bind + <<: *chinachu-recorded + target: /app/recorded/ + depends_on: + mirakurun: + condition: service_healthy + restart: always + logging: + driver: "json-file" + options: + max-file: "2" + max-size: "5m" + compress: "true" + + +volumes: + mirakurun: + name: "mirakurun" + chinachu: + name: "chinachu" \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100755 index 6d75dfc..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,33 +0,0 @@ -version: '2' -services: - mirakurun: - build: - context: mirakurun - container_name: mirakurun - privileged: true - ports: - - "40772:40772" - volumes: - - /etc/localtime:/etc/localtime:ro - - ./mirakurun/conf:/usr/local/etc/mirakurun - - ./mirakurun/db:/usr/local/var/db/mirakurun - - chinachu: - build: - context: chinachu - args: - - REPOSITORY=https://github.com/Chinachu/Chinachu.git - - BRANCH=gamma - container_name: chinachu - ports: - - "10772:10772" - - "20772:20772" - - "5353:5353/udp" - volumes: - - /etc/localtime:/etc/localtime:ro - - ./chinachu/conf/config.json:/usr/local/chinachu/config.json - - ./chinachu/conf/rules.json:/usr/local/chinachu/rules.json - - ./chinachu/data:/usr/local/chinachu/data - - ./recorded:/usr/local/chinachu/recorded - links: - - mirakurun:container-mirakurun diff --git a/mirakurun-chinachu.service b/mirakurun-chinachu.service deleted file mode 100644 index 5f0c474..0000000 --- a/mirakurun-chinachu.service +++ /dev/null @@ -1,16 +0,0 @@ -[Unit] -Description=All in one Mirakurun & Chinachu -Requires=docker.service -After=docker.service network.target -Conflicts=shutdown.target reboot.target halt.target - -[Service] -Type=simple -RemainAfterExit=yes -Restart=on-failure -WorkingDirectory=/usr/local/projects/tvs/ -ExecStart=/usr/local/bin/docker-compose up -d -ExecStop=/usr/local/bin/docker-compose stop - -[Install] -WantedBy=multi-user.target diff --git a/mirakurun-user.service b/mirakurun-user.service deleted file mode 100644 index ad35180..0000000 --- a/mirakurun-user.service +++ /dev/null @@ -1,13 +0,0 @@ -[Unit] -Description=Mirakurun - -[Service] -Type=simple -RemainAfterExit=yes -Restart=on-failure -WorkingDirectory=/usr/local/projects/tvs -ExecStart=/usr/local/bin/docker-compose up -d mirakurun -ExecStop=/usr/local/bin/docker-compose stop mirakurun - -[Install] -WantedBy=default.target diff --git a/mirakurun/Dockerfile b/mirakurun/Dockerfile deleted file mode 100755 index e976939..0000000 --- a/mirakurun/Dockerfile +++ /dev/null @@ -1,82 +0,0 @@ -FROM node:10-alpine -LABEL maintainer "h-mineta <h-mineta@0nyx.net>" - -ENV DOCKER="YES" - -RUN set -x \ - && apk upgrade --update \ - && apk add \ - bash \ - coreutils \ - libusb \ - pcsc-lite \ - pcsc-lite-libs \ - curl \ - ca-certificates \ - util-linux \ - \ - && apk add --virtual .build-deps \ - git \ - make \ - gcc \ - g++ \ - gzip \ - autoconf \ - automake \ - libc-dev \ - musl-dev \ - eudev-dev \ - libevent-dev \ - pcsc-lite-dev \ - libusb-dev \ - libtool\ - flex\ - \ - && npm install pm2 -g \ - \ - && npm install arib-b25-stream-test -g --unsafe \ - \ - # mirakurun - && npm install mirakurun@latest -g --unsafe --production \ - \ - # recpt1 - && git clone https://github.com/stz2012/recpt1 /tmp/recpt1 \ - && cd /tmp/recpt1/recpt1 \ - && ./autogen.sh \ - && ./configure \ - && sed -i '/#include <sys\/msg.h>/d' recpt1core.h \ - && sed -i -E 's!(#include <sys/msg.h>)!#undef _GNU_SOURCE\n#undef _BSD_SOURCE\n\1!' recpt1.c \ - && sed -i -E 's!(#include <sys/msg.h>)!#undef _GNU_SOURCE\n#undef _BSD_SOURCE\n\1!' recpt1ctl.c \ - && sed -i -E 's!(#include <sys/msg.h>)!#undef _GNU_SOURCE\n#undef _BSD_SOURCE\n\1!' checksignal.c \ - && sed -i -E 's!(#include <ctype.h>)!\1\n#include <event.h>!' tssplitter_lite.c \ - && sed -i 's#-I../driver#-I../driver -I/usr/local/include#' Makefile \ - && make \ - && make install \ - \ - # ccid - && cd /tmp \ - && git clone --recursive https://salsa.debian.org/rousseau/CCID.git \ - && cd CCID \ - && ./bootstrap \ - && ./configure \ - && make \ - && make install \ - \ - # cleaning - && cd / \ - && npm cache verify \ - && apk del --purge .build-deps \ - #&& rm -rf /tmp/* \ - && rm -rf /tmp/recpt1 \ - && rm -rf /tmp/ccid-* \ - && rm -rf /var/cache/apk/* - - # forward request and error logs to docker log collector - #&& ln -sf /dev/stdout /usr/local/var/log/mirakurun.stdout-0.log \ - #&& ln -sf /dev/stderr /usr/local/var/log/mirakurun.stderr-0.log - -COPY services.sh /usr/local/bin - -WORKDIR /usr/local/lib/node_modules/mirakurun -CMD ["/usr/local/bin/services.sh"] -EXPOSE 40772 diff --git a/mirakurun/conf/channels.yml b/mirakurun/conf/channels.yml deleted file mode 100755 index c358a2f..0000000 --- a/mirakurun/conf/channels.yml +++ /dev/null @@ -1,313 +0,0 @@ -- name: THK - type: GR - channel: '21' - -- name: NHK E - type: GR - channel: '13' - -- name: NHK G - type: GR - channel: '20' - -- name: CTV - type: GR - channel: '19' - -- name: CBC - type: GR - channel: '18' - -- name: NBN - type: GR - channel: '22' - -- name: TVA - type: GR - channel: '23' - -- name: MTV - type: GR - channel: '27' - -- name: BS Asahi - type: BS - channel: 'BS1_0' - serviceId: 151 - isDisabled: false - -- name: BS-TBS - type: BS - channel: 'BS1_1' - serviceId: 161 - isDisabled: false - -- name: WOWOW Prime - type: BS - channel: 'BS3_0' - serviceId: 191 - isDisabled: false - -- name: BS Japan - type: BS - channel: 'BS3_1' - serviceId: 171 - isDisabled: false - -- name: WOWOW Live - type: BS - channel: 'BS5_0' - serviceId: 192 - isDisabled: false - -- name: WOWOW Chinema - type: BS - channel: 'BS5_1' - serviceId: 193 - isDisabled: false - -- name: Star channel 2,3 - type: BS - channel: 'BS7_0' - serviceId: 201 - isDisabled: false - -- name: Star channel 2,3 - type: BS - channel: 'BS7_0' - serviceId: 202 - isDisabled: false - -- name: Animax - type: BS - channel: 'BS7_1' - serviceId: 236 - isDisabled: false - -- name: Disney - type: BS - channel: 'BS7_2' - serviceId: 256 - isDisabled: false - -- name: BS11 - type: BS - channel: 'BS9_0' - serviceId: 211 - isDisabled: false - -- name: Star channel 1 - type: BS - channel: 'BS9_1' - serviceId: 200 - isDisabled: false - -- name: TwellV - type: BS - channel: 'BS9_2' - serviceId: 222 - isDisabled: false - -- name: FOX - type: BS - channel: 'BS11_0' - serviceId: 238 - isDisabled: false - -- name: BS Skyperfect - type: BS - channel: 'BS11_1' - serviceId: 241 - isDisabled: false - -- name: BS NIPPON - type: BS - channel: 'BS13_0' - serviceId: 141 - isDisabled: false - -- name: BS FUJI - type: BS - channel: 'BS13_1' - serviceId: 181 - isDisabled: false - -- name: NHKBS1 - type: BS - channel: 'BS15_0' - serviceId: 101 - isDisabled: false - -- name: NHKBS Premium - type: BS - channel: 'BS15_1' - serviceId: 103 - isDisabled: false - -- name: Green channel - type: BS - channel: 'BS19_0' - serviceId: 234 - isDisabled: false - -- name: J SPORTS 1 - type: BS - channel: 'BS19_1' - serviceId: 242 - isDisabled: false - -- name: J SPORTS 2 - type: BS - channel: 'BS19_2' - serviceId: 243 - isDisabled: false - -- name: IMAGICA - type: BS - channel: 'BS21_0' - serviceId: 252 - isDisabled: false - -- name: J SPORTS 3 - type: BS - channel: 'BS21_1' - serviceId: 244 - isDisabled: false - -- name: J SPORTS 4 - type: BS - channel: 'BS21_2' - serviceId: 245 - isDisabled: false - -- name: BS Fishing - type: BS - channel: 'BS23_0' - serviceId: 251 - isDisabled: false - -- name: BS Chinema ch - type: BS - channel: 'BS23_1' - serviceId: 255 - isDisabled: false - -- name: D-Life - type: BS - channel: 'BS23_2' - serviceId: 258 - isDisabled: false - -- name: ND6 - type: CS - channel: CS6 - serviceId: 294 - isDisabled: false - -- name: ND6 - type: CS - channel: CS6 - serviceId: 323 - isDisabled: false - -- name: ND6 - type: CS - channel: CS6 - serviceId: 329 - isDisabled: false - -- name: ND6 - type: CS - channel: CS6 - serviceId: 340 - isDisabled: false - -- name: ND6 - type: CS - channel: CS6 - serviceId: 341 - isDisabled: false - -- name: ND6 - type: CS - channel: CS6 - serviceId: 354 - isDisabled: false - -- name: ND6 - type: CS - channel: CS6 - serviceId: 294 - isDisabled: false - -- name: ND12 - type: CS - channel: CS12 - serviceId: 254 - isDisabled: false - -- name: ND12 - type: CS - channel: CS12 - serviceId: 325 - isDisabled: false - -- name: ND12 - type: CS - channel: CS12 - serviceId: 330 - isDisabled: false - -- name: ND16 - type: CS - channel: CS16 - serviceId: 290 - isDisabled: false - -- name: ND16 - type: CS - channel: CS16 - serviceId: 305 - isDisabled: false - -- name: ND16 - type: CS - channel: CS16 - serviceId: 311 - isDisabled: false - -- name: ND16 - type: CS - channel: CS16 - serviceId: 333 - isDisabled: false - -- name: ND16 - type: CS - channel: CS16 - serviceId: 343 - isDisabled: false - -- name: ND16 - type: CS - channel: CS16 - serviceId: 353 - isDisabled: false - -- name: ND20 - type: CS - channel: CS20 - serviceId: 307 - isDisabled: false - -- name: ND20 - type: CS - channel: CS20 - serviceId: 308 - isDisabled: false - -- name: ND20 - type: CS - channel: CS20 - serviceId: 309 - isDisabled: false diff --git a/mirakurun/conf/server.yml b/mirakurun/conf/server.yml deleted file mode 100755 index 5159f00..0000000 --- a/mirakurun/conf/server.yml +++ /dev/null @@ -1,6 +0,0 @@ -path: /var/run/mirakurun.sock - -port: 40772 -host: ~ - -logLevel: 2 diff --git a/mirakurun/conf/tuners.yml b/mirakurun/conf/tuners.yml deleted file mode 100755 index 97c29ba..0000000 --- a/mirakurun/conf/tuners.yml +++ /dev/null @@ -1,30 +0,0 @@ -- name: PT3-S0 - types: - - BS - - CS - command: recpt1 --device /dev/pt3video0 <channel> - - - decoder: arib-b25-stream-test - isDisabled: false - -- name: PT3-S1 - types: - - BS - - CS - command: recpt1 --device /dev/pt3video1 <channel> - - - decoder: arib-b25-stream-test - isDisabled: false - -- name: PT3-T0 - types: - - GR - command: recpt1 --device /dev/pt3video2 <channel> - - - decoder: arib-b25-stream-test - isDisabled: false - -- name: PT3-T1 - types: - - GR - command: recpt1 --device /dev/pt3video3 <channel> - - - decoder: arib-b25-stream-test - isDisabled: false - diff --git a/chinachu/conf/config.json b/mirakurun/config/.gitkeep old mode 100755 new mode 100644 similarity index 100% rename from chinachu/conf/config.json rename to mirakurun/config/.gitkeep diff --git a/mirakurun/db/.gitignore b/mirakurun/db/.gitignore deleted file mode 100644 index d6b7ef3..0000000 --- a/mirakurun/db/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/mirakurun/mirakurun_status.js b/mirakurun/mirakurun_status.js deleted file mode 100755 index 99078aa..0000000 --- a/mirakurun/mirakurun_status.js +++ /dev/null @@ -1,124 +0,0 @@ -#!/usr/bin/env node -/* - Copyright 2016 Yuki KAN - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ -/// <reference path="../../typings/index.d.ts" /> -"use strict"; - -const fs = require("fs"); -const path = require("path"); -const http = require("http"); -const execSync = require("child_process").execSync; -const munin = require("../node_modules/munin-plugin"); - -if (process.platform === "linux") { - execSync(`renice -n 19 -p ${ process.pid }`); - execSync(`ionice -c 3 -p ${ process.pid }`); -} - -{ - const opt = { - method: "GET", - host: "localhost", - port: 40772, - path: "/api/status", - userAgent: `Mirakurun/docker (munin-plugin) Node/${process.version} (${process.platform})` - }; - - const req = http.request(opt, res => { - - if (res.statusCode !== 200 || res.headers["content-type"] !== "application/json; charset=utf-8") { - console.error("Error: Invalid Response."); - process.exit(1); - } - - let body = ""; - - res.on("data", chunk => { - body += chunk; - }); - - res.once("end", () => { - finalize(JSON.parse(body)); - }); - }); - - req.end(); -} - -function finalize(status) { - - munin.create([ - () => { - const g = new munin.Graph('Mirakurun Memory Usage','Bytes','mirakurun'); - g.setScale(true); - g.args = { - "--base": "1024", - "-l": "0" - }; - g.add(new munin.Model.Default('rss').setDraw("AREA").setValue(status.process.memoryUsage.rss)); - g.add(new munin.Model.Default('heapTotal').setDraw("AREA").setValue(status.process.memoryUsage.heapTotal)); - g.add(new munin.Model.Default('heapUsed').setDraw("AREA").setValue(status.process.memoryUsage.heapUsed)); - return g; - }, - () => { - const g = new munin.Graph('Mirakurun Programs DB','Events','mirakurun'); - g.setScale(true); - g.add(new munin.Model.Default('stored events').setDraw("AREA").setValue(status.epg.storedEvents)); - return g; - }, - () => { - const g = new munin.Graph('Mirakurun Stream','Count','mirakurun'); - g.add(new munin.Model.Default("TunerDevice").setDraw("AREA").setValue(status.streamCount.tunerDevice)); - g.add(new munin.Model.Default("TSFilter").setDraw("STACK").setValue(status.streamCount.tsFilter)); - g.add(new munin.Model.Default("decoder").setDraw("STACK").setValue(status.streamCount.decoder)); - return g; - }, - () => { - const g = new munin.Graph('Mirakurun Error','Count','mirakurun'); - - const uncaughtException = new munin.Model.Default('uncaught exception') - uncaughtException.setDraw("AREA"); - uncaughtException.setType("DERIVE"); - uncaughtException.setMin("0"); - uncaughtException.setValue(status.errorCount.uncaughtException); - - const bufferOverflow = new munin.Model.Default('buffer overflow') - bufferOverflow.setDraw("STACK"); - bufferOverflow.setType("DERIVE"); - bufferOverflow.setMin("0"); - bufferOverflow.setValue(status.errorCount.bufferOverflow); - - const tunerDeviceRespawn = new munin.Model.Default('tuner device respawn') - tunerDeviceRespawn.setDraw("STACK"); - tunerDeviceRespawn.setType("DERIVE"); - tunerDeviceRespawn.setMin("0"); - tunerDeviceRespawn.setValue(status.errorCount.tunerDeviceRespawn); - - g.add(uncaughtException); - g.add(bufferOverflow); - g.add(tunerDeviceRespawn); - - return g; - }, - () => { - const g = new munin.Graph('Mirakurun Timer Accuracy','Microseconds','mirakurun'); - g.add(new munin.Model.Default('avg m1').setDraw("AREA").setValue(status.timerAccuracy.m1.avg)); - g.add(new munin.Model.Default('avg m5').setDraw("LINE1").setValue(status.timerAccuracy.m5.avg)); - g.add(new munin.Model.Default('avg m15').setDraw("LINE1").setValue(status.timerAccuracy.m15.avg)); - return g; - } - ].map(f => f())); -} diff --git a/mirakurun/opt/bin/startup.sample b/mirakurun/opt/bin/startup.sample new file mode 100644 index 0000000..55d4860 --- /dev/null +++ b/mirakurun/opt/bin/startup.sample @@ -0,0 +1,16 @@ +#!/bin/bash + +if !(type "recpt1" > /dev/null 2>&1); then + apt-get update + apt-get install -y --no-install-recommends git autoconf automake + + cd /tmp + git clone https://github.com/stz2012/recpt1.git + cd recpt1/recpt1 + ./autogen.sh + ./configure --prefix /opt + make + make install +fi + +recpt1 -v \ No newline at end of file diff --git a/mirakurun/services.sh b/mirakurun/services.sh deleted file mode 100755 index 49a2086..0000000 --- a/mirakurun/services.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash -if [ ! -s /usr/local/etc/mirakurun/channels.yml ]; then - cat /usr/local/share/mirakurun/channels.yml > /usr/local/etc/mirakurun/channels.yml -fi -if [ ! -s /usr/local/etc/mirakurun/tuners.yml ]; then - cat /usr/local/share/mirakurun/tuners.yml > /usr/local/etc/mirakurun/tuners.yml -fi -if [ ! -s /usr/local/etc/mirakurun/server.yml ]; then - cat /usr/local/share/mirakurun/server.yml > /usr/local/etc/mirakurun/server.yml -fi - -rm -f /run/pcscd/pcscd.comm >/dev/null 2>&1 - -pcscd -f --error & -npm start diff --git a/recorded/.gitignore b/recorded/.gitignore deleted file mode 100644 index d6b7ef3..0000000 --- a/recorded/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/recorded/.gitkeep b/recorded/.gitkeep new file mode 100644 index 0000000..e69de29