2020年12月22日火曜日

Emacs 27.1 で、google-translate を使うと ad-Advice-search-forward: Search failed: ",tkk:'" エラーになるときの対策

Emacs 27.1 に乗り換えたら、google-translate が使えなくなってしまった。
下記のエラーが出る。

ad-Advice-search-forward: Search failed: ",tkk:'"

google-translate-tk.el ファイルの google-translate--search-tkk() 関数を下記のように書き換えると良いらしい。
(参考) https://github.com/atykhonov/google-translate/issues/52

(defun google-translate--search-tkk () "Search TKK." (list 430675 2721866130))

● emacs, 27.1, google-translate, TKK, error, エラー, ad-Advice-search-forward, Search failed

2020年12月18日金曜日

Raspberry Pi でシリアル接続時の画面サイズを変更

Raspberry Pi (Ubuntu) に、シリアルでログインしているときに画面がたまに小さくなる。
Vi でファイルを編集した後とか。
resize コマンドを打てば、使用しているターミナルソフトの画面サイズまで拡大される。

$ resize                                                                                       
COLUMNS=116;
LINES=62;
export COLUMNS LINES;

● Raspberry Pi, Ubuntu, UART, シリアル, serial, console, サイズ, size, 画面, resize

2020年10月4日日曜日

Raspberry Pi 4 + DVB-T + Ubuntu 20.04 server で ADS-B 受信機を作成 ( Flightradar24、FlightAware、RadarBox )

そろそろ、Ubunu 20.04 server でもいけるようになったみたいです。
(これまで、何度か格闘しましたが、うまくいかずでした)

■ 環境

HardwareRaspberry Pi 4 Model B / 4 GB
OSUbuntu Server 20.04 64-bit
SDSanDisk Ultra micro SDHC 16GB Class10
DVB-TR820T2 & SDR+SMD X-tal 10PPM [DVB-T+FM+DAB/RTL-SDR][RTL2832U+R820T2][High quality USB-CN][広帯域受信用]Blue

1. Ubuntu Server 20.04.1 イメージを micro SD に書き込む

Ubuntu のサイト からイメージを取得。micro SD に書き込む。

$ sudo apt install gddrescue xz-utils
$ unxz ubuntu-20.04.1-preinstalled-server-arm64+raspi.img.xz
$ sudo ddrescue -D --force ubuntu-20.04.1-preinstalled-server-arm64+raspi.img /dev/mmcblk0

GNU ddrescue 1.23
Press Ctrl-C to interrupt
     ipos:    4539 MB, non-trimmed:        0 B,  current rate:  14417 kB/s
     opos:    4539 MB, non-scraped:        0 B,  average rate:  14834 kB/s
non-tried:  460714 kB,  bad-sector:        0 B,    error rate:       0 B/s
  rescued:    4539 MB,   bad areas:        0,        run time:      5m  6s
pct rescued:   90.78%, read errors:        0,  remaining time:         32s
                              time since last successful read:          0s
Copying non-tried blocks... Pass 1 (forwards)

2. Ubuntu Server 20.04 諸設定

デフォルトユーザのログインは、User: ubuntu, Password ubuntu で。
最初のログインは、起動してからちょっと待ったほうが良い。
パスワード変えるのと、adduser でユーザを作成。
SSHd は、最初から入ってました。
あとはお好みで。

$ sudo apt update
$ sudo apt upgrade

NTP をインストールする。
$ sudo systemctl stop systemd-timesyncd.service
$ sudo systemctl disable systemd-timesyncd.service
$ sudo apt install ntp
$ sudo systemctl enable ntp
$ sudo systemctl start ntp

キーボードレイアウトを日本語キーボードに変更。
$ sudo dpkg-reconfigure keyboard-configuration
  ・Generic 105-key (Intl) PC を選択
  ・keyboard: Japanese を選択
  ・Keyboard Layout: Japanese を選択
  ・AltGr 設定: The default for the keyboard layout を選択
  ・Compose key: No compose key を選択

3. FlightAware

(参考)
https://ja.flightaware.com/adsb/piaware/install
https://discussions.flightaware.com/t/piaware-v-3-7-1-on-debian-10-0-buster-amd64-intel-pc/52414

■ Piaware

$ sudo apt install -y git devscripts build-essential debhelper tcl8.6-dev autoconf python3-dev python3-venv virtualenv \
dh-systemd zlib1g-dev tclx8.4 tcllib tcl-tls itcl3 net-tools libboost-system-dev libboost-program-options-dev \
libboost-regex-dev libboost-filesystem-dev 

$ git clone https://github.com/flightaware/piaware_builder.git
$ cd  piaware_builder

Ubuntu 20.04 のコードネームは focal だけど、buster でいってみる。

$ ./sensible-build.sh buster

$ cd package-buster
$ sudo dpkg-buildpackage -b --no-sign

$ cd ../
$ sudo dpkg -i piaware_4.0_arm64.deb piaware-dbgsym_4.0_arm64.ddeb

$ sudo touch /etc/piaware.conf

既に feeder id がある場合は、下記を設定。

$ sudo piaware-config feeder-id xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx 

$ sudo piaware-config allow-auto-updates yes 
$ sudo piaware-config allow-manual-updates yes 

$ sudo systemctl restart piaware

自動起動を有効化

$ sudo systemctl enable piaware

■ dump1090-fa

$ sudo apt install -y git lighttpd build-essential debhelper dh-systemd \
libboost-system-dev libboost-program-options-dev libboost-regex-dev \
libboost-filesystem-dev libsoapysdr-dev soapysdr-module-rtlsdr \
debhelper dh-systemd librtlsdr-dev libusb-1.0-0-dev \
git pkg-config libncurses5-dev lighttpd libbladerf-dev \
libhackrf-dev liblimesuite-dev

$ git clone https://github.com/flightaware/dump1090.git dump1090-fa
$ cd dump1090-fa
$ sudo dpkg-buildpackage -b --no-sign

$ cd ../
$ sudo dpkg -i dump1090-fa_4.0_arm64.deb dump1090-fa-dbgsym_4.0_arm64.ddeb

$ sudo systemctl restart dump1090-fa

しばらくしたら、下記リンクで Piaware と FlightAware のアカウントを関連付ける。
同じルータ配下の別 PC からブラウザでアクセスすれば OK。 https://flightaware.com/adsb/piaware/claim
更に、MY ADS-B のリンクから、アンテナ設置場所の緯度、経度、高度を設定すれば OK。

4. Flightradar24

tcl-tls のバージョンが古いので、インストールできないと言われた。パッケージの依存関係が壊れた?

$ sudo apt install libssl-dev tcl-dev chrpath

$ sudo dpkg --add-architecture armhf
$ sudo dpkg --print-foreign-architectures
armhf

$ sudo bash -c "$(wget -O - https://repo-feed.flightradar24.com/install_fr24_rpi.sh)"

______  _  _         _      _                    _              _____    ___
|  ___|| |(_)       | |    | |                  | |            / __  \  /   |
| |_   | | _   __ _ | |__  | |_  _ __  __ _   __| |  __ _  _ __`' / /' / /| |
|  _|  | || | / _` || '_ \ | __|| '__|/ _` | / _` | / _` || '__| / /  / /_| |
| |    | || || (_| || | | || |_ | |  | (_| || (_| || (_| || |  ./ /___\___  |
\_|    |_||_| \__, ||_| |_| \__||_|   \__,_| \__,_| \__,_||_|  \_____/    |_/
               __/ |
              |___/
[main][i]FR24 Feeder/Decoder
[main][i]Version: 1.0.26-5/generic
[main][i]Built on Sep 15 2020 08:05:17 (HEAD-3d4a88a.git/Linux/static_armel)
[main][i]Running on: ubuntu20.04
[main][i]Local IP(s): XXX.XXX.XXX.XXX
[main][i]Copyright 2012-2020 Flightradar24 AB
[main][i]https://www.flightradar24.com
[main][i]DNS mode: PING

Welcome to the FR24 Decoder/Feeder sign up wizard!

Before you continue please make sure that:

 1 - Your ADS-B receiver is connected to this computer or is accessible over network
 2 - You know your antenna's latitude/longitude up to 4 decimal points and the altitude in feet
 3 - You have a working email address that will be used to contact you
 4 - fr24feed service is stopped. If not, please run: sudo systemctl stop fr24feed

To terminate - press Ctrl+C at any point


Step 1.1 - Enter your email address (username@domain.tld)
$:●Flightradar24 に登録しているメールアドレスを入力

Step 1.2 - If you used to feed FR24 with ADS-B data before, enter your sharing key.
If you don't remember your sharing key, you can find it in your account on the website under "My data sharing".
https://www.flightradar24.com/account/data-sharing

Otherwise leave this field empty and continue.
$:●新規登録であれば、メールで送られてきた sharing key を入力。または既存のものを入力

Verifying sharing key...OK



Step 1.3 - Would you like to participate in MLAT calculations? (yes/no)$:yes

IMPORTANT: For MLAT calculations the antenna's location should be entered very precise!

Step 3.A - Enter antenna's latitude (DD.DDDD)
$:●設置場所の緯度を入力

Step 3.B - Enter antenna's longitude (DDD.DDDD)
$:●設置場所の経度を入力

Step 3.C - Enter antenna's altitude above the sea level (in feet)
$:●設置場所の高度を入力

Using latitude: XX.XXXX, longitude: XXX.XXXX, altitude: XXft above sea level

We have detected that you already have a dump1090 instance running. We can therefore automatically configure the FR24 feeder to use existing receiver configuration, or you can manually configure all the parameters.

Would you like to use autoconfig (*yes*/no)$:● yes を入力

Step 6A - Please select desired logfile mode:
 0 -  Disabled
 1 -  48 hour, 24h rotation
 2 -  72 hour, 24h rotation
Select logfile mode (0-2)$:● 2 を入力

Step 6B - Please enter desired logfile path (/var/log/fr24feed):
$:●何も入力せずに Enter

Submitting form data...OK

Congratulations! You are now registered and ready to share ADS-D data with Flightradar24.
+ Your radar id is T-RJFF33, please include it in all email communication with us.
+ Please make sure to start sharing data within one month from now as otherwise your ID/KEY will be deleted.

Thank you for supporting Flightradar24! We hope that you will enjoy our Premium services that will be available to you when you become an active feeder.

To start sending data now please execute:
sudo systemctl start fr24feed

Saving settings to /etc/fr24feed.ini...OK
Settings saved, please run "sudo systemctl restart fr24feed" to use new configuration.

fr24feed を再起動。

$ sudo systemctl restart fr24feed

5. RadarBox

続いて RadarBox。
RadarBox のアカウントに紐付ける方法は、忘れてしまいました。
通常は、下記を実行するだけなのですが、スクリプト内の lsb_release -c コマンドで、コードネームが bionic となってしまい、
スクリプトが停止してしまいます。
ちょっと修正して、buster と同じ流れにすれば OK。

$ sudo apt install apt install libc6-dev-armhf-cross
$ sudo bash -c "$(wget -O - http://apt.rb24.com/inst_rbfeeder.sh)"
Don't know how to install for a distribution named で止まってしまう、、、。

inst_rbfeeder.sh を取得して、スクリプトを修正、実行します。

$ wget http://apt.rb24.com/inst_rbfeeder.sh
$ vi inst_rbfeeder.sh
case 文の buster) となっている部分に focal を追記。
(変更前)
    buster)
(変更後)
    buster|focal)

$ sudo sh inst_rbfeeder.sh

mlat-client をソースからビルドしてインストール。
ビルドの前に python3.pm を作成しておきます (ビルドエラーになるため)。

$ sudo vi /usr/share/perl5/Debian/Debhelper/Sequence/python3.pm
(下記を記述)
#! /usr/bin/perl
# debhelper sequence file for dh_python3

use warnings;
use strict;
use Debian::Debhelper::Dh_Lib;

insert_before("dh_installinit", "dh_python3");

1

ここからビルド。

$ sudo apt install dh-python python2
$ wget https://github.com/mutability/mlat-client/archive/v0.2.11.tar.gz
$ tar zxvf v0.2.11.tar.gz
$ cd mlat-client-0.2.11/
$ sudo dpkg-buildpackage -b --no-sign
$ sudo dpkg -i ../mlat-client_0.2.11_arm64.deb
$ sudo ./setup.py install
$ sudo init 6

設定ファイルのメモを残しておきます。

$ cat /etc/rbfeeder.ini
[client]
network_mode=true
log_file=/var/log/rbfeeder.log

key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

sn=XXXXXXXXXXXX

[network]
mode=raw
external_port=30005
external_host=127.0.0.1

[mlat]

6. graphs1090

dump1090-fa の受信状況をグラフで表示。
http://192.168.x.x/graphs1090/ にアクセス。

$ sudo apt purge collectd collectd-core
$ wget http://ports.ubuntu.com/pool/universe/c/collectd/collectd_5.9.2.g-1ubuntu5_arm64.deb
$ wget http://ports.ubuntu.com/pool/universe/c/collectd/collectd-core_5.9.2.g-1ubuntu5_arm64.deb
$ sudo dpkg -i collectd_5.9.2.g-1ubuntu5_arm64.deb collectd-core_5.9.2.g-1ubuntu5_arm64.deb
$ sudo bash -c "$(wget -q -O - https://raw.githubusercontent.com/wiedehopf/graphs1090/master/install.sh)"

collectd が起動に失敗するので、/etc/default/collectd に下記を追記する。
libpython3.8.so が、そこにない場合は、/usr/lib 以下で検索してから記述する。

$ sudo vi /etc/default/collectd
(下記を追記)
LD_PRELOAD=/usr/lib/python3.8/config-3.8-x86_64-linux-gnu/libpython3.8.so

7. FR24 の MLAT が有効にならない対策

fr24feed の起動を遅らせると良いらしい。
参考: https://gato.intaa.net/archives/21762

$ sudo systemctl disable fr24feed

$ sudo vi /etc/systemd/system/fr24feed.service
(下記を変更)
#After=network-online.target
After=rc-local.service

(LimitCORE=infinity の次の行に下記を追加)
ExecStartPre=/bin/sleep 90

$ sudo systemctl enable fr24feed
$ sudo init 6

8. 2020/10/16 追記: logrotate を設定する

fr24feeder.log, rbfeeder.log, mlat-client.log については、logrotate の設定をしておく。

$ sudo vi /etc/logrotate.d/fr24feeder
(下記を記述)
/var/log/fr24feed/fr24feed.log {
  daily
  rotate 7
  copytruncate
}
$ sudo vi /etc/logrotate.d/rbfeeder
(下記を記述)
/var/log/rbfeeder.log {
  daily
  rotate 7
  copytruncate
}
$ sudo vi /etc/logrotate.d/mlat-client
(下記を記述)
/var/log/mlat-client.log {
  daily
  rotate 7
  copytruncate
}

■ 備考

ADS-B feeder を設置すると、下記プランが無料で利用可能になります。
年間、$ 1 = 108 円 換算で、$ 499.99 + ($ 89.95 × 12) + $399.50 = $ 1,978.89 = 213,720 円 お得です♪

ServicePlan$ / month$ / year
Flightradar24Business$ 49.99$ 499.99
FlightAwareEnterprise$ 89.95$ -
RadarBoxBUSINESS$ 39.95$ 399.50

dump1090 の受信状況は下記コマンドで確認できる。

$ nc 127.0.0.1 30003

● Raspberry Pi 4, raspi4, raspi, DVB-T, Ubuntu Server 20.04, ADS-B, Flightradar24, FlightAware RadarBox, dump1090-fa, ddrescue

2020年9月6日日曜日

LibreELEC (KODI) の日本語フォントを変更する

RasPi にインストールした LibreELEC の 日本語フォント = Arial ベース が読みにくいので、
VL P ゴシックに変更する方法。

■ VL ゴシックフォントをダウンロード

こちらからダウンロード。
https://ja.osdn.net/projects/vlgothic/downloads/62375/VLGothic-20141206.zip/

■ RasPi に転送、配置

RasPi に転送して、/storage/.kodi/media/Fonts/arial.ttf として配置します。
配置後、再起動。

# mkdir -p /storage/.kodi/media/Fonts
# scp VL-PGothic-Regular.ttf root@192.168.10.101:/storage/.kodi/media/Fonts/arial.ttf

● Raspberry Pi, LibreELEC, KODI, font, フォント, 日本語, Japanese, Arial ベース, ttf, VL PGothic, VL ゴシック

2020年9月5日土曜日

Raspberry Pi 4 で Netflix (LibreELEC) を再生

Raspberry Pi に LibreELEC を入れて、ちょいちょいっと設定して、Netflix 再生機にしたときの手順メモ。
今までは、古いノート PC を TV に繋いで、Firefox で見てたんですが、まあ使い勝手が悪かった。
これで、諸々のことが解決です。

0. 機材

機材は、Raspberry Pi 4 Model B (RAM 4GB) です。microSDHC カードは 32 GB のものを使いました。
ファンは、5V 給電の方に繋いで、高速回転させてやります。
長時間、動画再生するしね。

1. LibreELEC

下記サイトから、LibreELEC の最新版イメージをダウンロードして、microSD に書き込みます。
https://libreelec.tv/
2020/09/05 現在、Ver.9.2.5 です。
LibreELEC USB-SD Creator を使って書き込んでもよいし LibreELEC-RPi4.arm-9.2.5.img.gz をダウンロードして、ddrescue で書き込んでもよいです。
私は後者で。

$ sudo ddrescue -D --force LibreELEC-RPi4.arm-9.2.5.img /dev/mmcblk0

2. 初期設定

Language は English のままでいきます。
焦って、ここで Japanese にすると、文字化けして設定できなくなります。

続いて、ホスト名の設定。このままでも良いです。

ネットワークの設定。有線でも無線でも、お好きな方を。

有線の設定例はこちら。この例では Static IP を設定しています。

SSH を有効にする場合は、パスワードの設定は、お好みですが。変えておいたほうが良いです。

3. 日本語表示設定

ホームに戻って、歯車マークを選択。

Interface を選択。

Skin -> Fonts を選択。先にフォント設定を切り替えます。

Arial Based に変更。

そしていよいよ Regional -> Language を選択。

Japanese を選択。

4. タイムゾーンの設定

時刻が UTC になっているので、日本時間に変更します。 地域 -> タイムゾーン (国) を選択。

Japan を選択。

5. Netflix アドオンをインストール

Netflix を LibreELEC 上で再生するには、アドオンの zip ファイルを Raspberry Pi に転送してやる必要があります。
下記サイトから、repository.castagnait-1.0.1.zip をダウンロードします。
https://forum.kodi.tv/showthread.php?tid=329767

scp か Samba で、Raspberry Pi に転送。

$ scp repository.castagnait-1.0.1.zip root@192.168.10.101:~/

ホームに戻って、システム -> アドオン を選択。

zip ファイルからインストール を選択。

先に転送した zip ファイルを選択すると、"不明なソース" をインストールできるように設定を変更するメニューに飛ばされます。
素直に選択。

repository.castagnait-1.0.1.zip を選択。

一つ戻って、リポジトリからインストール -> CastagnaIT Repository for Kodi 18.x (LEIA) を選択。

ビデオアドオン を選択。

Netflix -> インストール。

ホームに戻って、アドオン -> Netflix を選択。
Netflix に登録しているメールアドレスとパスワード (暗証番号と出ますが、パスワードのことです) を入力してログイン。

再生しようとすると、追加のアドオンが必要と言われますが、言われるとおりにインストールしていきます。

Widevine CDM とは、暗号化メディア拡張機能(EME)のサポートを Vivaldi に提供する「コンテンツ復号化モジュール」(CDM) だそうです。

あとは、アドオンの検索メニューで、RTMP と検索して、RTMP Input アドオンを入れておくと良いらしいです。

その他、キーボードレイアウトの設定を Japanese にしておくと、USB キーボードを使うときに困らなくて良いでしょう。

6. GPU の RAM 割り当てを変更

Raspberry Pi 4 (RAM 4GB) を使っているので、GPU の RAM 割り当てサイズを増やしおきます。
/flash ディレクトリは ReadOnly でマウントされているので、Read/Write でリマウントしたあと、
config.txt ファイルを編集します。

(SSH でログイン後)
# mount -o remount,rw /flash
# vi /flash/config.txt
gpu_ram=512 に変更

7. おわりに

以上で、設定完了です。
LibreELEC は、TV の赤外線リモコンでメニュー操作が可能です。HDMI 経由で制御情報をやり取りしているらしい。
うちは 4K TV じゃないので、4K で見ることは無いのですが、config.mk を設定変更すると、
4K での出力も可能になるようです。
4K TV には、Netflix 最初から入ってるか (笑)。

● Raspberry Pi 4, RasPi, LibreELEC, Kodi, Netflix, ネットフリックス, HDMI

2020年5月16日土曜日

Linux で IPv4 アドレスを /proc で確認する方法

/proc/net/fib_trie で確認できる。

$ cat /proc/net/fib_trie
Main:
  +-- 0.0.0.0/0 3 0 5
     |-- 0.0.0.0
        /0 universe UNICAST
     +-- 127.0.0.0/8 2 0 2
        +-- 127.0.0.0/31 1 0 0
           |-- 127.0.0.0
              /32 link BROADCAST
              /8 host LOCAL
           |-- 127.0.0.1
              /32 host LOCAL
        |-- 127.255.255.255
           /32 link BROADCAST
     +-- 192.168.10.0/24 2 0 1
        |-- 192.168.10.0
           /32 link BROADCAST
           /24 link UNICAST
        |-- 192.168.10.100
           /32 host LOCAL
        |-- 192.168.10.255
           /32 link BROADCAST
Local:
  +-- 0.0.0.0/0 3 0 5
     |-- 0.0.0.0
        /0 universe UNICAST
     +-- 127.0.0.0/8 2 0 2
        +-- 127.0.0.0/31 1 0 0
           |-- 127.0.0.0
              /32 link BROADCAST
              /8 host LOCAL
           |-- 127.0.0.1
              /32 host LOCAL
        |-- 127.255.255.255
           /32 link BROADCAST
     +-- 192.168.10.0/24 2 0 1
        |-- 192.168.10.0
           /32 link BROADCAST
           /24 link UNICAST
        |-- 192.168.10.100
           /32 host LOCAL
        |-- 192.168.10.255
           /32 link BROADCAST

シェルのコマンドだけで抽出するならこうかな。
上からネットワーク、IP アドレス、ブロードキャストアドレス。

$ cat /proc/net/fib_trie  | grep \|-- | grep -v -e 0.0.0.0 -e 127.* | sort | uniq | cut -d"-" -f 3
 192.168.10.0
 192.168.10.100
 192.168.10.255

● proc, IPv4, check, 確認, IP address, IP アドレス

2020年5月10日日曜日

HDD (SSD) 上の Ubuntu 20.04 iso インストーラを grub2 で起動する

Ubuntu 20.04 LTS 日本語 Remix がリリースされたので、前にやってうまくいかなかった HDD (SSD) 上の iso イメージを
grub2 で起動してみる。に再チャレンジ。

以下、パーティションは、下記のようになっている PC での例です。

# sfdisk -l /dev/nvme0n1
Disk /dev/nvme0n1: 238.49 GiB, 256060514304 bytes, 500118192 sectors
Disk model: PM981 NVMe Samsung 256GB                
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 72AF23F1-3135-4466-B984-8C7183D69CCF

Device             Start       End   Sectors   Size Type
/dev/nvme0n1p1      2048    499711    497664   243M EFI System
/dev/nvme0n1p2    499712  50499583  49999872  23.9G Linux filesystem
/dev/nvme0n1p3  50499584 100499455  49999872  23.9G Linux filesystem
/dev/nvme0n1p4 100499456 108498943   7999488   3.8G Linux swap
/dev/nvme0n1p5 108498944 500117503 391618560 186.8G Linux filesystem     <-- ここが Home Directory

今、起動している Ubuntu 19.10 上で grub の設定ファイルを編集。
set isofile の部分は、適宜変更。
5 番目のパーティションに /home をマウントしているので、/home/USER の場合は /USER になる。

# vi /etc/grub.d/40_custom

(下記のように編集)
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.

menuentry "Ubuntu 20.04 ISO" {
    set isofile="/USER/Downloads/ubuntu-ja-20.04-desktop-amd64.iso"
    rmmod tpm
    loopback loop (hd0,gpt5)$isofile
    linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile noprompt noeject toram --
    initrd (loop)/casper/initrd
}

grub の設定を反映。

# update-grub

再起動して、Grub のメニューで "Ubuntu 20.04 ISO" を選択。

Ubuntu 20.04 ISO イメージ起動後、インストーラを起動する前に、/isodevice をアンマウントする必要があります。

$ sudo umount -l -r -f /isodevice

■ 参考
https://help.ubuntu.com/community/Grub2/ISOBoot

● grub2, grub, iso, HDD, SSD, 直接, 起動, boot, インストーラ, installer, install, hdd, ssd, Ubuntu

Ubuntu で ISO イメージファイルをマウントする

Ubuntu 20.04 インストーラを /mnt ディレクトリにマウントするときの例。

# mount -t iso9660 -o loop,ro ~/Downloads/ubuntu-ja-20.04-desktop-amd64.iso /mnt

● mount, iso, イメージ, iso image, マウント

2020年5月9日土曜日

マルチコネクションダウンロードコマンド aria2 (HTTP/HTTPS, FTP, SFTP)

大容量データのダウンロードを高速化できるコマンド aria2。
急ぎで大きいファイルをダウンロードしたいときに便利。
Ubuntu なら apt コマンドでサクッとインストール。

# apt install aria2

使い方。5 セッションでダウンロードする場合。

$ aria2c -x5 URL

イカしてる。

● マルチ, コネクション, multi, connection, HTTP, HTTPS, FTP, SFTP, aria2, 高速, 複数, 並列, curl, wget, 短縮

2020年5月8日金曜日

Raspberry Pi + Ubuntu server 環境で、起動時に ntpdate で時刻同期する

Raspberry Pi で NTPd を設定していても、起動後に時刻が同期するまでに時間がかかる。
一旦、ntpdate で同期するように設定。

ntpdate をインストール

# apt -y install ntpdate

自動起動するように設定。

# vi /etc/systemd/system/ntpdate.service
(下記のように記述)
[Unit]
Description=Set time with ntpdate
After=network.target

[Service]
# use -u to avoid conflict with ntpd
ExecStart=/usr/sbin/ntpdate -u ntp.nict.jp

# we may not have network yet, so retry until success
Restart=on-failure
RestartSec=60s

[Install]
WantedBy=multi-user.target

ntpdate.service を有効にする。 再起動して、時刻が同期されることを確認。

# systemctl enable ntpdate.service

● Raspberry Pi, Ubuntu, server, ntpdate, 時刻同期, ntp, 起動時

2020年4月29日水曜日

Ubuntu sever 20.04 で、固定 IPv4 アドレス設定

/etc/netplan/50-cloud-init.yaml を編集。

# vi /etc/netplan/50-cloud-init.yaml
(下記のように編集)
network:
    ethernets:
        eth0:
            dhcp4: no
            dhcp6: no
            addresses: [192.168.10.10/24]
            gateway4: 192.168.10.1
            nameservers:
                addresses: [192.168.10.1, 1.1.1.1, 8.8.8.8]
            optional: true
    version: 2

設定を反映。

# netplan apply

設定の確認。

# ip address
...
2: eth0:  mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
    inet 192.168.10.100/24 brd 192.168.10.255 scope global eth0
       valid_lft forever preferred_lft forever
...

● IPv4, IP アドレス, IP address, 固定, static

2020年4月22日水曜日

Ubuntu server で、ホスト名を変更する

Raspberry Pi 4 に Ubuntu server 18.04.4 をインストールしたので、ホスト名を raspi4 にする。

# hostnamectl set-hostname raspi4

確認

# hostnamectl
   Static hostname: raspi4
         Icon name: computer
        Machine ID: a760a1c3601a4049a70cf24254987172
           Boot ID: 523853d4411746268f1fd89d9867aa3a
  Operating System: Ubuntu 18.04.4 LTS
            Kernel: Linux 5.3.0-1022-raspi2
      Architecture: arm64

● ubuntu, server, hostname, ホスト名, 変更, hostnamectl

2020年4月19日日曜日

Raspberry Pi 4 + DVB-T + Ubuntu 18.04 server で ADS-B 受信機を作成 ( Flightradar24、FlightAware、RadarBox )

Raspberry Pi 4 で、ようやく ADS-B フィーダーを動かすことができました。
Ubuntu 19.10 server では、dump1090-fa が、なぜかすぐに落ちました。結局、解決できずしばらく放置してたのですが、
Raspberry Pi 4 用 Ubuntu Server 18.04.4 64-bit が出ていので試したところ、動くようになりました。

■ 環境

HardwareRaspberry Pi 4 Model B / 4 GB
OSUbuntu Server 18.04.4 64-bit
SDSanDisk Ultra micro SDHC 32GB Class10 A1
DVB-TR820T2 & SDR+SMD X-tal 10PPM [DVB-T+FM+DAB/RTL-SDR][RTL2832U+R820T2][High quality USB-CN][広帯域受信用]Blue

1. Ubuntu Server 18.04.4 イメージを micro SD に書き込む

Ubuntu のサイト からイメージを取得。micro SD に書き込む。

$ sudo apt install gddrescue xz-utils
$ unxz ubuntu-18.04.4-preinstalled-server-arm64+raspi3.img.xz
$ sudo ddrescue -D --force ubuntu-18.04.4-preinstalled-server-arm64+raspi3.img /dev/mmcblk0

GNU ddrescue 1.23
Press Ctrl-C to interrupt
     ipos:    4539 MB, non-trimmed:        0 B,  current rate:  14417 kB/s
     opos:    4539 MB, non-scraped:        0 B,  average rate:  14834 kB/s
non-tried:  460714 kB,  bad-sector:        0 B,    error rate:       0 B/s
  rescued:    4539 MB,   bad areas:        0,        run time:      5m  6s
pct rescued:   90.78%, read errors:        0,  remaining time:         32s
                              time since last successful read:          0s
Copying non-tried blocks... Pass 1 (forwards)

2. Ubuntu Server 18.04.4 諸設定

デフォルトユーザのログインは、User: ubuntu, Password ubuntu で。
パスワード変えるのと、adduser でユーザ作りました。
SSHd は、最初から入ってました。
あとはお好みで。

$ sudo apt update
$ sudo apt upgrade

NTP をインストールする。
$ sudo apt remove ntpdate
$ sudo systemctl stop systemd-timesyncd.service
$ sudo systemctl disable systemd-timesyncd.service
$ sudo apt install ntp
$ sudo systemctl enable ntp
$ sudo systemctl start ntp

3. FlightAware

(参考)
https://ja.flightaware.com/adsb/piaware/install
https://discussions.flightaware.com/t/piaware-v-3-7-1-on-debian-10-0-buster-amd64-intel-pc/52414

■ Piaware

$ sudo apt install -y git devscripts build-essential debhelper tcl8.6-dev autoconf python3-dev python3-venv virtualenv \
dh-systemd zlib1g-dev tclx8.4 tcllib tcl-tls itcl3 net-tools libboost-system-dev libboost-program-options-dev \
libboost-regex-dev libboost-filesystem-dev 

$ git clone https://github.com/flightaware/piaware_builder.git
$ cd  piaware_builder
$ ./sensible-build.sh buster

$ cd package-buster
$ sudo dpkg-buildpackage -b --no-sign

$ cd ../ 
$ sudo dpkg -i piaware_3.8.1_arm64.deb piaware-dbgsym_3.8.1_arm64.ddeb

piaware ユーザを手動で作成

$ sudo useradd --system piaware

$ sudo touch /etc/piaware.conf

既に feeder id がある場合は、下記を設定。

$ sudo piaware-config feeder-id xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx 

$ sudo piaware-config allow-auto-updates yes 
$ sudo piaware-config allow-manual-updates yes 

$ sudo systemctl restart piaware

自動起動を有効化

$ sudo systemctl enable piaware

■ dump1090-fa

$ sudo apt install -y git lighttpd build-essential debhelper dh-systemd \
libboost-system-dev libboost-program-options-dev libboost-regex-dev \
libboost-filesystem-dev libsoapysdr-dev soapysdr-module-rtlsdr \
debhelper dh-systemd librtlsdr-dev libusb-1.0-0-dev \
git pkg-config libncurses5-dev lighttpd libbladerf-dev

$ git clone https://github.com/flightaware/dump1090.git dump1090-fa 
$ cd dump1090-fa
$ sudo dpkg-buildpackage -b --no-sign

$ cd ../
$ sudo dpkg -i dump1090-fa_3.8.1_arm64.deb dump1090-fa-dbgsym_3.8.1_arm64.ddeb

$ sudo systemctl restart dump1090-fa

しばらくしたら、下記リンクで Piaware と FlightAware のアカウントを関連付ける。
同じルータ配下の別 PC からブラウザでアクセスすれば OK。 https://flightaware.com/adsb/piaware/claim
更に、MY ADS-B のリンクから、アンテナ設置場所の緯度、経度、高度を設定すれば OK。

4. Flightradar24

tcl-tls のバージョンが古いので、インストールできないと言われた。パッケージの依存関係が壊れた?

$ sudo apt --fix-broken install
$ sudo apt install libssl-dev tcl-dev chrpath

$ git clone http://github.com/flightaware/tcltls-rebuild.git
$ cd tcltls-rebuild  
$ ./prepare-build.sh buster  
$ cd package-buster  
$ sudo dpkg-buildpackage -b --no-sign
$ cd ../  
$ sudo dpkg -i tcl-tls_*.deb 
$ cd ..

$ sudo dpkg --add-architecture armhf
$ sudo dpkg --print-foreign-architectures
armhf

$ sudo bash -c "$(wget -O - https://repo-feed.flightradar24.com/install_fr24_rpi.sh)"

______  _  _         _      _                    _              _____    ___ 
|  ___|| |(_)       | |    | |                  | |            / __  \  /   |
| |_   | | _   __ _ | |__  | |_  _ __  __ _   __| |  __ _  _ __`' / /' / /| |
|  _|  | || | / _` || '_ \ | __|| '__|/ _` | / _` | / _` || '__| / /  / /_| |
| |    | || || (_| || | | || |_ | |  | (_| || (_| || (_| || |  ./ /___\___  |
\_|    |_||_| \__, ||_| |_| \__||_|   \__,_| \__,_| \__,_||_|  \_____/    |_/
               __/ |                                                         
              |___/                                                          
[main][i]FR24 Feeder/Decoder
[main][i]Version: 1.0.25-3/generic
[main][i]Built on Apr  8 2020 07:06:55 (HEAD-5e8ef0c.git/Linux/static_armel)
[main][i]Running on: ubuntu18.04
[main][i]Local IP(s): 192.168.10.10
[main][i]Copyright 2012-2020 Flightradar24 AB
[main][i]https://www.flightradar24.com
[main][i]DNS mode: PING

Welcome to the FR24 Decoder/Feeder sign up wizard!

Before you continue please make sure that:

 1 - Your ADS-B receiver is connected to this computer or is accessible over network
 2 - You know your antenna's latitude/longitude up to 4 decimal points and the altitude in feet
 3 - You have a working email address that will be used to contact you
 4 - fr24feed service is stopped. If not, please run: sudo systemctl stop fr24feed

To terminate - press Ctrl+C at any point


Step 1.1 - Enter your email address (username@domain.tld)
$:●Flightradar24 に登録しているメールアドレスを入力

Step 1.2 - If you used to feed FR24 with ADS-B data before enter your sharing key.
If you don't remember your sharing key, pelase use the retrival form:
https://feed.flightradar24.com/forgotten_key.php

Otherwise leave this field empty and continue.
$:●新規登録であれば、メールで送られてきた sharing key を入力。または既存のものを入力

Verifying sharing key...OK



Step 1.3 - Would you like to participate in MLAT calculations? (yes/no)$:yes

IMPORTANT: For MLAT calculations the antenna's location should be entered very precise!

Step 3.A - Enter antenna's latitude (DD.DDDD)
$:●設置場所の緯度を入力

Step 3.B - Enter antenna's longitude (DDD.DDDD)
$:●設置場所の経度を入力

Step 3.C - Enter antenna's altitude above the sea level (in feet)
$:●設置場所の高度を入力

Using latitude: XX.XXXX, longitude: XXX.XXXX, altitude: XXft above sea level

We have detected that you already have a dump1090 instance running. We can therefore automatically configure the FR24 feeder to use existing receiver configuration, or you can manually configure all the parameters.

Would you like to use autoconfig (*yes*/no)$:● yes を入力

Step 6A - Please select desired logfile mode:
 0 -  Disabled
 1 -  48 hour, 24h rotation
 2 -  72 hour, 24h rotation
Select logfile mode (0-2)$:● 2 を入力

Step 6B - Please enter desired logfile path (/var/log/fr24feed):
$:●何も入力せずに Enter

Submitting form data...OK

Congratulations! You are now registered and ready to share ADS-D data with Flightradar24.
+ Your radar id is T-RJFF33, please include it in all email communication with us.
+ Please make sure to start sharing data within one month from now as otherwise your ID/KEY will be deleted.

Thank you for supporting Flightradar24! We hope that you will enjoy our Premium services that will be available to you when you become an active feeder.

To start sending data now please execute:
sudo systemctl start fr24feed

Saving settings to /etc/fr24feed.ini...OK
Settings saved, please run "sudo systemctl restart fr24feed" to use new configuration.

fr24feed を再起動。

$ sudo systemctl restart fr24feed

5. RadarBox

続いて RadarBox。
RadarBox のアカウントに紐付ける方法は、忘れてしまいました。
通常は、下記を実行するだけなのですが、スクリプト内の lsb_release -c コマンドで、コードネームが bionic となってしまい、
スクリプトが停止してしまいます。
ちょっと修正して、buster と同じ流れにすれば OK。

$ sudo apt install libc6-dev-armhf-cross
$ sudo bash -c "$(wget -O - http://apt.rb24.com/inst_rbfeeder.sh)"
Don't know how to install for a distribution named で止まってしまう、、、。

inst_rbfeeder.sh を取得して、スクリプトを修正、実行します。

$ wget http://apt.rb24.com/inst_rbfeeder.sh
$ vi inst_rbfeeder.sh
case 文の buster) となっている部分に bionic を追記。
(変更前)
    buster)
(変更後)
    buster|bionic)

$ sudo sh inst_rbfeeder.sh

■2020/05/04 追記。
buster だと、パッケージの依存関係が解消できずに、rbfeeder をインストールできなくなりました。
stretch に変更するとインストールできました。かなり無理クリ。

$ wget http://apt.rb24.com/inst_rbfeeder.sh
$ vi inst_rbfeeder.sh
case 文の stretch) となっている部分に bionic を追記。
(変更前)
    stretch)
(変更後)
    stretch|bionic)

$ sudo sh inst_rbfeeder.sh

mlat-client をソースからインストール。

$ sudo apt install python-minimal
$ wget https://github.com/mutability/mlat-client/archive/v0.2.11.tar.gz
$ tar zxvf v0.2.11.tar.gz
$ cd mlat-client-0.2.11/
$ sudo dpkg-buildpackage -b --no-sign
$ sudo dpkg -i ../mlat-client_0.2.11_arm64.deb
$ sudo ./setup.py install

(再起動)
$ sudo init 6

設定ファイルのメモを残しておきます。

$ cat /etc/rbfeeder.ini
[client]
network_mode=true
log_file=/var/log/rbfeeder.log

key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

sn=XXXXXXXXXXXX

[network]
mode=raw
external_port=30005
external_host=127.0.0.1

[mlat]

6. graphs1090

dump1090-fa の受信状況をグラフで表示。
http://192.168.x.x/graphs1090/ にアクセス。

$ sudo bash -c "$(wget -q -O - https://raw.githubusercontent.com/wiedehopf/graphs1090/master/install.sh)"

■ 2020/05/08 追記

FR24 の MLAT が有効にならない。
fr24feed の起動を遅らせると良いらしい。
参考: https://gato.intaa.net/archives/21762

$ sudo systemctl disable fr24feed

$ sudo vi /etc/sytemd/system/fr24feed.service
(下記を変更)
#After=network-online.target
After=rc-local.service

(LimitCORE=infinity の次の行に下記を追加)
ExecStartPre=/bin/sleep 90

$ sudo systemctl enable fr24feed
$ sudo init 6

■ 備考

ADS-B feeder を設置すると、下記プランが無料で利用可能になります。
年間、$ 1 = 108 円 換算で、$ 499.99 + ($ 89.95 × 12) + $399.50 = $ 1,978.89 = 213,720 円 お得です♪

ServicePlan$ / month$ / year
Flightradar24Business$ 49.99$ 499.99
FlightAwareEnterprise$ 89.95$ -
RadarBoxBUSINESS$ 39.95$ 399.50

dump1090 の受信状況は下記コマンドで確認できる。

$ nc 127.0.0.1 30002
$ nc 127.0.0.1 30003

● Raspberry Pi 3, raspi3, raspi, DVB-T, Ubuntu MATE 18.04, ADS-B, Flightradar24, FlightAware RadarBox, dump1090-fa

2020年1月12日日曜日

Raspberry Pi 4 + Ubuntu Server 19.10 で Wi-Fi の設定をする

Raspberry Pi 4 に Ubuntu Server 19.10 をインストールして Wi-Fi のセットアップ中。
/etc/network/interfaces で設定するんじゃないのね。

netplan は、/etc/netplan/XX-***.yaml の XX が若い順に後勝ちで処理されるので、
/etc/netplan/98-wifi.yaml を作成。SSID と SSID-PASSWORD は適当に修正。

# vi /etc/netplan/98-wifi.yaml

network:
    wifis:
        wlan0:
            dhcp4: true
            optional: true
            access-points:
                SSID:
                    password: SSID-PASSWORD
    version: 2

設定を反映するのは netplan コマンドで。

# netplan apply

● raspberry pi 4, raspi4, ubuntu, server, 19.10, wi-fi, Wi-Fi, interfaces, netplan, wlan0, 無線 LAN

2020年1月8日水曜日

Samba over SSH (Windows10 Proxy 経由で Samba アクセス)

Proxy サーバ経由で SSH 接続して、Samba サーバにアクセスする手順のメモ。
確認環境: Samba サーバ = Ubuntu 16.04、クライアント = Windows10

まず、概要を説明すると、下記のようになる。
Windows でループバック I/F (10.255.255.1/24) を作成して、
10.255.255.1:445 -> 10.255.255.1:44445 に port proxy して、
Proxy サーバ経由で SSH 接続するときに、ポートフォワード設定をしておいて、
10.255.255.1:44445 -> XX.XX.XX.XX:445 にアクセス。

0. サーバ側設定

サーバ PC (Ubuntu 16.04) では、Samba, SSH サーバ が起動していることが前提 (構築手順等の説明省略)。
あと、proxy サーバ経由でその PC にアクセスできること。

1. ループバックアダプタ追加

まず、Windows PC にループバックアダプタを追加する。
デバイスマネージャを開いて、"操作" -> "レガシハードウェアの追加"。

ハードウェアの追加ウィザードの開始。

一覧から選択したハードウェアをインストールする。

ネットワークアダプター。

Microsoft KM-TEST Loopback Adapter。



わかりやすいように名前を "Loopback" に変えておく。

Loopback のプロパティを開き、Microsoft ネットワーク用ファイルとプリンター共有 のチェックを外す。

インターネット プロトコル バージョン 4 (TCP/IPv4) を開いて、固定 IP アドレスを設定。
IP アドレス = 10.255.255.1
サブネット マスク = 255.255.255.0

詳細設定 -> WINS、NetBIOS over TCP/IP を無効にする。

2. portproxy の設定

管理者権限で、コマンドプロンプトを起動する。
SMB ドライバ (サービス) がすでに起動している場合は、下記を実行する。
(自分の PC では必要なかった)

> sc config smb start= demand

portproxy の設定。

> netsh interface portproxy add v4tov4 listenaddress=10.255.255.1 listenport=445 connectaddress=10.255.255.1 connectport=44445

設定内容を確認。

> netsh interface portproxy show v4tov4

Address         Port        Address         Port
--------------- ----------  --------------- ----------
10.255.255.1    445         10.255.255.1    44445

3. タスクスケジューラに SMB ドライバ (サービス) を設定。

ログイン時に、下記が実行されるように設定する。
設定後、再起動する。

C:\Windows\System32\net.exe start smb




再起動後、設定が下記のようになっていれば OK。
ダメな場合は、タスクスケジューラを開いて、タスクの停止、実行を手動で行うと良いかも。
(場合によっては、社内 LAN 接続ツールの挙動がおかしくなる。その時は、一旦タスクを停止して、接続後、起動する)

> netstat -an | find ":445"

  TCP         0.0.0.0:445            0.0.0.0:0              LISTENING
  TCP         10.255.255.1:445       0.0.0.0:0              LISTENING
  TCP         [::]:445               [::]:0                 LISTENING

4. TeraTerm で、SSH 転送 (ポートフォワード設定) を行い、SSH ログインする。

今回は TeraTerm を使ってアクセスしたが、PuTTY でも同様のことができる。
まず、ポートフォワードの設定を行う。
to remote machine のところに、サーバ PC の IP アドレスを入力。

proxy サーバを設定。


SSH でログインする。
TeraTerm で、SSH のコネクションを張っている間、Samba のアクセスが可能となる。

5. エクスプローラで、Samba サーバにアクセス。

USER の部分は任意で入力。

\\10.255.255.1\USER

● Samba, SSH, proxy, windows10, port foward, smb, teraterm