4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Raspberry Pi 4 で Radiko 録音サーバ(Docker未使用)

Last updated at Posted at 2020-11-10

はじめに

Raspberry Pi 4 の arm64v8 環境で Docker する道は険しかった…
過去に x86_64 用に作成した Dockerfile たちを arm64v8 化するのはやぶさかではなかったが
build ができない(かろうじて run はできる)んで心が折れた。みんなどうしてんの?
(参考:https://github.com/docker/distribution/issues/3008

一旦サービスを稼働させることを優先して、Docker 無しで環境構築した。

久々に systemd の Unit ファイルの作り方とか調べるの結構面倒だったので
ほぼ自分用メモとして残しておく。

追記)
2020/11/14 config.json の書き方が誤っていたので修正した
2020/11/14 crontab で1ヶ月前のものから自動削除する設定を追加した
2020/11/18 nginx の設定を足した

$ lsb_release -a
No LSB modules are available.
Distributor ID: Raspbian
Description:    Raspbian GNU/Linux 10 (buster)
Release:        10
Codename:       buster

radicast

$ sudo su -
# apt update
# apt install rtmpdump swftools libxml2-utils
# go get github.com/mtkhs/radicast
# mkdir -p /opt/service/radicast
# cd /opt/service/radicast
# vim config.json
# mkdir output
# vim /etc/systemd/system/radicast.service
# systemctl enable radicast
# systemctl start radicast
# crontab -e
config.json
{
  "BAYFM78": [],
  "FMJ": [],
  "FMT": [],
  "HOUSOU-DAIGAKU": [],
  "INT": [],
  "JOAB": [],
  "JOAK": [],
  "JOAK-FM": [],
  "JORF": [],
  "LFR": [
    "0 1 * * FRI",
    "0 1 * * SUN"
  ],
  "NACK5": [],
  "QRR": [],
  "RN1": [],
  "RN2": [],
  "TBS": [
    "30 21 * * MON",
    "0 0 * * WED",
    "0 1 * * WED",
    "0 0 * * FRI",
    "0 3 * * SUN",
    "30 3 * * SUN"
  ],
  "YFM": []
}
radicast.service
[Unit]
Description=Radicast service
After=networking.service
Requires=networking.service

[Service]
Type=simple
WorkingDirectory=/opt/service/radicast
ExecStart=/root/go/bin/radicast
ExecReload=/bin/kill -HUP $MAINPID
Restart=always

[Install]
WantedBy=multi-user.target
crontab
0 5 * * * find /opt/service/radicast/output/ -mtime +31 -delete

nginx

# apt install nginx
# cd /etc/nginx/
# rm sites-enabled/default
# vim sites-available/radicast
# ln -s sites-available/radicast sites-enabled/radicast

[yourhostname] には適当に取った DDNS 名とかホスト名を入れる。

radicast
server {
    listen 80;
    server_name [yourhostname];

    location / {
        rewrite ^/$ http://$server_name/rss redirect;
        proxy_pass                         http://127.0.0.1:3355;
        proxy_set_header X-Real-IP         $remote_addr;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Forwarded-For   $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Host  $http_host;
        proxy_set_header Host              $http_host;
        proxy_max_temp_file_size           0;
        proxy_buffers                      8 64k;
        proxy_buffer_size                  64k;
    }
}

おわりに

iPhoneのPodcastアプリで「番組をURLで追加…」で

http://[yourhostname]

が追加できたらOK

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?