sudo を実行するときに、proxy の設定とかが引き継がれないことがある。
sudo 実行時に、環境変数を引き継ぐオプション -E を使用すれば良い。
$ sudo -E ...
● sudo, 環境変数, proxy
主に Linux (Ubuntu, Fedora) 関連の設定メモ&小技集です。たまに Windows 関連ネタも。
(プロンプトの $ は一般ユーザ権限、# は root 権限です。いちいち説明はせんよ。)
sudo を実行するときに、proxy の設定とかが引き継がれないことがある。
sudo 実行時に、環境変数を引き継ぐオプション -E を使用すれば良い。
$ sudo -E ...
● sudo, 環境変数, proxy
cp コマンドで、ディレクトリごと上書きコピーする。
既にある foo ディレクトリに bar ディレクトリを上書きコピーする場合。
$ cp -r bar -T foo
● cp, directory, overwrite, ディレクトリ, 上書き, コピー, オプション, option
複数ファイルをテキストファイルにリスト化しておいて、wget でダウンロードさせる方法のメモ。
urls.txt ファイルにダウンロードしたい URL のリストを記述
$ vi urls.txt (下記を記述) ftp://hogehoge.org/hogehoge1.tar.gz ftp://hogehoge.org/hogehoge2.tar.gz ftp://hogehoge.org/hogehoge3.tar.gz
xargs と wget でダウンロード。wget の -c オプションは、レジューム。途中、停止したときに再開できる。
$ xargs -P 20 -n 1 wget -c --user=hogehoge --password=hogehoge < urls.txt
● wget, xargs, urls.txt, 一括, 自動, ダウンロード, レジューム, download
SVN で、チェックアウトしたローカルのツリーをサーバと同じ状態にしたいことがある。
make でいうところの、distclean みたいなやつ。
そんな便利コマンドは無いので、bash の function に SVN-DISTCLEAN というコマンドを追加する。
function SVN-DISTCLEAN () {
svn status --no-ignore
svn status --no-ignore | cut -c 2- | xargs rm -rf
svn revert -R .
svn update
svn status --no-ignore
}
ツリーに移動して、SVN-DISTCLEAN を実行。
作業中のファイルがある場合は、悲しいことになってしまうので注意。
$ SVN-DISTCLEAN
● SVN-DISTCLEAN, svn, distclean
XML ファイルを整形するコマンド。
$ tidy -i -w 0 -xml -utf8 ./hogehoge.xml > hogehoge-out.xml
● tidy, xml, XML, 整形
Windows10 で、Caps Lock キーを Ctrl キーに割り当てる設定メモ。
レジストリを変更する方法で。
(レジストリを変更するので、自己責任でお願いします)
| レジストリキー | コンピューター -> HKEY_LOCAL_MACHINE -> SYSTEM -> CurrentControlSet -> Control -> Keyboard Layout |
| 種類 | バイナリ値 (REG_BINARY) |
| データ | 00 00 00 00 00 00 00 00 02 00 00 00 1d 00 3a 00 00 00 00 00 |
caps2ctrl.reg ファイルを作成して実行する。中身は下記。
実行後、再起動。
Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout] "Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,1d,00,3a,00,00,00,00,00
先頭から、4 バイトずつ
00,00,00,00 : ヘッダ (バージョン)
00,00,00,00 : フラグ
02,00,00,00 : エントリー数 (NULL 終端含む)
1d,00,3a,00 : キーコード変換 (003a を 001d に変換)
00,00,00,00 : NULL 終端
remove_caps2ctrl.reg ファイルを作成して実行する。中身は下記。
実行後、再起動。
Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout] "Scancode Map"=-
Windows キーも不要という人 (=自分) は、下記を使います。
Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout] "Scancode Map"=hex:00,00,00,00,00,00,00,00,04,00,00,00,1d,00,3a,00,00,00,5b,e0,00,00,5c,e0,00,00,00,00
00,00,00,00 : ヘッダ (バージョン)
00,00,00,00 : フラグ
04,00,00,00 : エントリー数 (NULL 終端含む)
1d,00,3a,00 : キーコード変換 (003a Caps Lock を 001d Ctrl に変換)
00,00,5b,e0 : キーコード無効 (e05b 左 Win を無効化)
00,00,5c,e0 : キーコード無効 (e05c 右 Win を無効化)
00,00,00,00 : NULL 終端
● windows, windows10, caps, caps lock, ctrl, control, キャプスロック, コントロール, キー, 変更, 入れ替え, 割り当て, regedit, レジストリ, registry, win キー, win key, windows キー, windows key, 無効, 無効化
fzf をインストールするときに、毎回迷うのでメモしておく。
今回は、Ver.0.25.1 の例。シェルは bash。
git でやっても良いが、下記から tar.gz をダウンロード。
https://github.com/junegunn/fzf/tags
$ tar zxvf fzf-0.25.1.tar.gz
$ cd fzf-0.25.1
$ ./install
Downloading bin/fzf ...
- Already exists
- Checking fzf executable ... 0.25.1
Do you want to enable fuzzy auto-completion? ([y]/n) n
Do you want to enable key bindings? ([y]/n) n
Generate /home/masao/.fzf.bash ... OK
Do you want to update your shell configuration files? ([y]/n) n
Update /home/ohmoto/.bashrc:
- [ -f ~/.fzf.bash ] && source ~/.fzf.bash
~ Skipped
For more information, see: https://github.com/junegunn/fzf
$ sudo cp bin/fzf* /usr/local/bin
$ sudo cp man/man1/fzf* /usr/share/man/man1/
$ cp shell/completion.bash ~/.fzf_completion.bash
$ cp shell/key-bindings.bash ~/.fzf_key-bindings.bash
.bashrc に、下記を設定。設定はお好みで。
export HISTSIZE=100000
export HISTCONTROL=ignoreboth:erasedups # history を重複登録しないための設定
export PROMPT_COMMAND='history -a; history -c; history -r' # 複数のシェルで history を共有するための設定
shopt -u histappend # 同上
source ~/.fzf_completion.bash
source ~/.fzf_key-bindings.bash
export FZF_DEFAULT_OPTS='--height 40% --reverse --border'
export FZF_CTRL_R_OPTS="--preview-window up:3:wrap --preview 'echo {}'"
● fzf, history, 重複
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
Raspberry Pi (Ubuntu) に、シリアルでログインしているときに画面がたまに小さくなる。
Vi でファイルを編集した後とか。
resize コマンドを打てば、使用しているターミナルソフトの画面サイズまで拡大される。
$ resize COLUMNS=116; LINES=62; export COLUMNS LINES;
● Raspberry Pi, Ubuntu, UART, シリアル, serial, console, サイズ, size, 画面, resize
そろそろ、Ubunu 20.04 server でもいけるようになったみたいです。
(これまで、何度か格闘しましたが、うまくいかずでした)
| Hardware | Raspberry Pi 4 Model B / 4 GB |
| OS | Ubuntu Server 20.04 64-bit |
| SD | SanDisk Ultra micro SDHC 16GB Class10 |
| DVB-T | R820T2 & SDR+SMD X-tal 10PPM [DVB-T+FM+DAB/RTL-SDR][RTL2832U+R820T2][High quality USB-CN][広帯域受信用]Blue |
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)
デフォルトユーザのログインは、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 を選択
(参考)
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。
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
続いて 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]
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
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
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 円 お得です♪
| Service | Plan | $ / month | $ / year |
| Flightradar24 | Business | $ 49.99 | $ 499.99 |
| FlightAware | Enterprise | $ 89.95 | $ - |
| RadarBox | BUSINESS | $ 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