スワップファイルを作ってお手軽にスワップを増やす

RAMを大量に必要とするプログラムがあって遅くてもいいから一時的にスワップを増やしてやり過ごすことがあります.また,RAMの少ないマシンでディスクの構成をいじるのが面倒なときにもスワップファイルが使えます.ということで今回RAMが2GBでそこそこあるけど偶に使い切ってしまう(主にchromium!)のでスワップファイルを用意してみました.

スワップファイルを作成します.今回は/var/tmp/swap.imgというファイルで2GB用意しました.

$ sudo install -o root -g root -m 0600 /dev/null /var/tmp/swap.img
$ sudo dd if=/dev/zero of=/var/tmp/swap.img bs=1M count=2048
$ sudo mkswap /var/tmp/swap.img

とりあえずスワップファイルをアドホックに有効にします.

$ sudo swapon /var/tmp/swap.img 

.スワップが増えています.

$ swapon -s
Filename                                Type            Size    Used    Priority
/dev/zram0                              partition       254688  80024   5
/dev/zram1                              partition       254688  80016   5
/dev/zram2                              partition       254688  79940   5
/dev/zram3                              partition       254688  79928   5
/var/tmp/swap.img                       file            2097148 0       -1

一時的に必要な場合はこれで良いのですが,恒久的に利用したい場合はこのままでは再起動後には有効になりません./etc/fstabに設定を書いて起動時に有効になるようにします.

$ sudo vi /etc/fstab
$ grep -i swap.img /etc/fstab 
/var/tmp/swap.img     none    swap    sw      0       0

一旦swapoffでスワップを無効にしてswapon -aでfatabの設定が有効か試します.swapon -afstabのスワップの設定を全て有効にします.

$ sudo swapoff /var/tmp/swap.img
$ sudo swapon -a
$ swapon -s
Filename                                Type            Size    Used    Priority
/dev/zram0                              partition       254688  80020   5
/dev/zram1                              partition       254688  80016   5
/dev/zram2                              partition       254688  79940   5
/dev/zram3                              partition       254688  79928   5
/var/tmp/swap.img                       file            2097148 0       -1

念のため再起動してスワップファイルが有効かも試せばOKです :)

スワップファイルの利用はお手軽ですが,スワップパーティーションに比べると性能は少し落ちるので可能ならスワップパーティーションを利用したほうが良いです.RAMが増設できるならそれが一番です.

環境

$ dpkg-query -W mount
mount   2.27.1-6ubuntu3.6
$ lsb_release -d
Description:    Ubuntu 16.04.4 LTS
$ uname -m
aarch64

MACアドレスをランダムに変更してくれるGNU MAC Changerを試してみる

簡単にMACアドレスをランダムに偽装できる GNU MAC Changer を試してみました.

導入

$ sudo apt install macchanger

導入時にネットワークインターフェイスが有効になるときにmacchangerを有効にするかどうかを聞いてきます.

 ┌────────────────────────┤ Configuring macchanger ├─────────────────────────┐
 │                                                                           │ 
 │ Please specify whether macchanger should be set up to run automatically   │ 
 │ every time a network device is brought up or down. This gives a new MAC   │ 
 │ address whenever you attach an ethernet cable or reenable wifi.           │ 
 │                                                                           │ 
 │ Change MAC automatically?                                                 │ 
 │                                                                           │ 
 │                    <Yes>                       <No>                       │ 
 │                                                                           │ 
 └───────────────────────────────────────────────────────────────────────────┘ 
                                                                               

20180529_21:05:46-14602

あとで変更したい場合は sudo dpkg-reconfigure macchanger で再度設定できます.

help

$ macchanger --help
GNU MAC Changer
Usage: macchanger [options] device

  -h,  --help                   Print this help
  -V,  --version                Print version and exit
  -s,  --show                   Print the MAC address and exit
  -e,  --ending                 Don't change the vendor bytes
  -a,  --another                Set random vendor MAC of the same kind
  -A                            Set random vendor MAC of any kind
  -p,  --permanent              Reset to original, permanent hardware MAC
  -r,  --random                 Set fully random MAC
  -l,  --list[=keyword]         Print known vendors
  -b,  --bia                    Pretend to be a burned-in-address
  -m,  --mac=XX:XX:XX:XX:XX:XX
       --mac XX:XX:XX:XX:XX:XX  Set the MAC XX:XX:XX:XX:XX:XX

Report bugs to https://github.com/alobbs/macchanger/issues

現在のMACアドレス確認

wls1のMACアドレスは00:22:fa:33:45:6aになっています.

$ ip link show wls1 
2: wls1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DORMANT group default qlen 1000
    link/ether 00:22:fa:33:45:6a brd ff:ff:ff:ff:ff:ff

ネットワークインターフェイスをダウン

upのままだとエラーとなります.([ERROR] Could not change MAC: interface up or insufficient permissions: Operation not permitted)

$ sudo ip link set dev wls1 down

MACアドレスをランダムに変更

$ sudo macchanger -r wls1
Current MAC:   de:ed:be:ef:01:23 (unknown)
Permanent MAC: 00:22:fa:33:45:6a (Intel Corporate)
New MAC:       7a:a9:98:47:10:1a (unknown)

macアドレスを元に戻す

$ sudo macchanger -p wls1
Current MAC:   78:a9:98:e1:2e:f8 (unknown)
Permanent MAC: 00:22:fa:33:45:6a (Intel Corporate)
New MAC:       00:22:fa:33:45:6a (Intel Corporate)

ベンダーIDは保持してランダムに変更

このオプションは使い勝手が良さそうですね.

$ sudo macchanger -e wls1
Current MAC:   00:22:fa:33:45:6a (Intel Corporate)
Permanent MAC: 00:22:fa:33:45:6a (Intel Corporate)
New MAC:       00:22:fa:db:b9:ed (Intel Corporate)

手動設定

これはip link set dev wls1 de:ed:be:ef:01:23ifconfig wls1 hw ether de:ed:be:ef:01:23と同じなのであまりmacchangerを使う意味ないですね.

$ sudo macchanger --mac=de:ed:be:ef:01:23 wls1
Current MAC:   00:22:fa:33:45:6a (Intel Corporate)
Permanent MAC: 00:22:fa:33:45:6a (Intel Corporate)
New MAC:       de:ed:be:ef:01:23 (unknown)

ネットワークインターフェイスをアップ

upして何時ものように利用します.

$ sudo ip link set dev wls1 up

自動起動時の動作

/etc/network/if-pre-up.d/macchanger, /etc/network/if-post-down.d/macchangerで設定しているようです.この中を見ると,以下のように-e optionで実行されるのでベンダーIDは維持した状態でランダムに設定されるようです.

/usr/bin/{package} -e IFACE >> $LOGFILE 2>&1

ログファイルは/var/log/macchanger.logに保存されます.

環境

$ neofetch 
       _,met$$$$$gg.          mk@x200 
    ,g$$$$$$$$$$$$$$$P.       ------- 
  ,g$$P"     """Y$$.".        OS: Debian GNU/Linux unstable (sid) x86_64 
 ,$$P'              `$$$.     Model: 74574PJ ThinkPad X200 
',$$P       ,ggs.     `$$b:   Kernel: 4.16.0-1-amd64 
`d$$'     ,$P"'   .    $$$    Uptime: 2 days, 13 hours, 17 minutes 
 $$P      d$'     ,    $$P    Packages: 5718 
 $$:      $$.   -    ,d$$'    Shell: bash 4.4.19 
 $$;      Y$b._   _,d$P'      Resolution: 1280x800 
 Y$$.    `.`"Y$$$$P"'         WM: awesome 
 `$$b      "-.__              Terminal: sakura 
  `Y$$                        Terminal Font: Fira Code 11 
   `Y$$.                      CPU: Intel Core 2 Duo P8400 (2) @ 2.267GHz 
     `$$b.                    GPU: Intel® GM45 Express Chipset 
       `Y$$b.                 Memory: 6579MiB / 7871MiB 
          `"Y$b._ 
              `"""                                    

$ dpkg-query -W macchanger
macchanger      1.7.0-5.3+b1

Devuan jessieをasciiにdist-upgradeしてみた

screenshot

Devuan asciiもRelease Candidateが出てそろそろ正式版になりそうです.てことで手元のDevuan jessie i386環境をascii環境にdist-upgradeしてみました.

DevuanはDebianからフォークした脱Systemdなディストリビューションです.コードネームはjessieはDebianと同じですがその次のバージョンから独自になっていて,Devuan asciiはDebian stretch相当になります.

アップグレードのドキュメントは以下にありました.

うーんシンプル.念の為Debianの文章も参考にします.

これらの文章と違うところはsources.list編集時にapt edit-sourcesコマンドを使ったくらいです.今回はこんな感じに.

diff --git a/apt/sources.list b/apt/sources.list
index 142945f..afaa14d 100644
--- a/apt/sources.list
+++ b/apt/sources.list
@@ -1,16 +1,16 @@
-# deb http://jp.mirror.devuan.org/merged/ jessie main
+# deb http://jp.mirror.devuan.org/merged/ ascii main
 
-deb http://jp.mirror.devuan.org/merged/ jessie main non-free contrib
-deb-src http://jp.mirror.devuan.org/merged/ jessie main non-free contrib
+deb http://jp.mirror.devuan.org/merged/ ascii main non-free contrib
+deb-src http://jp.mirror.devuan.org/merged/ ascii main non-free contrib
 
-# jessie-security, previously known as 'volatile'
-deb http://jp.mirror.devuan.org/merged/ jessie-security main contrib non-free
-deb-src http://jp.mirror.devuan.org/merged/ jessie-security main contrib non-free
+# ascii-security, previously known as 'volatile'
+deb http://jp.mirror.devuan.org/merged/ ascii-security main contrib non-free
+deb-src http://jp.mirror.devuan.org/merged/ ascii-security main contrib non-free
 
-# jessie-updates, previously known as 'volatile'
-deb http://jp.mirror.devuan.org/merged/ jessie-updates main contrib non-free
-deb-src http://jp.mirror.devuan.org/merged/ jessie-updates main contrib non-free
+# ascii-updates, previously known as 'volatile'
+deb http://jp.mirror.devuan.org/merged/ ascii-updates main contrib non-free
+deb-src http://jp.mirror.devuan.org/merged/ ascii-updates main contrib non-free
 
-# jessie-backports, previously on backports.debian.org
-deb http://jp.mirror.devuan.org/merged/ jessie-backports main contrib non-free
-deb-src http://jp.mirror.devuan.org/merged/ jessie-backports main contrib non-free
+# ascii-backports, previously on backports.debian.org
+deb http://jp.mirror.devuan.org/merged/ ascii-backports main contrib non-free
+deb-src http://jp.mirror.devuan.org/merged/ ascii-backports main contrib non-free

特に問題なく処理は進んでいましたが,apt dist-upgradeでエラーが発生しました.bluemanで以下のようなエラーとなりました.

Setting up blueman (2.0.4-1) ...
Reloading system message bus config...Error org.freedesktop.DBus.Error.FileNotFound: Failed to open "/etc/dbus-1/system.conf": No such file or directory
invoke-rc.d: initscript dbus, action "reload" failed.
dpkg: error processing package blueman (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 blueman
E: Sub-process /usr/bin/dpkg returned an error code (1)

一旦削除して再起動後導入し直したら導入に成功しました.

$ sudo apt remove blueman
$ sudo reboot
$ sudo apt install blueman

ということでシンプルなシステムだったせいかさっくりとdist-upgradeに成功しました :)

<追記>
うまく行かなかった人も居るよう.

</追記>

terminalで動作するMastodon clientのnanotodonを試してみた

mikutodonをDebian jessie armhfに入れてみた.Makefileを修正したら動いたけど文字化けする.ちなみにDebian sid amd64では問題なく動作した.

$ cat /etc/debian_version 
8.10
$ uname -m
armv7l

ライブラリ等導入

$ sudo apt install build-essential libcurl4-openssl-dev libjson-c-dev libncurses-dev libncursesw5
$ dpkg-query -W build-essential libcurl4-openssl-dev libjson-c-dev libncurses-dev libncursesw5
build-essential 11.7
libcurl4-openssl-dev:armhf      7.38.0-4+deb8u11
libjson-c-dev:armhf     0.11-4
libncurses-dev  
libncursesw5:armhf      5.9+20140913-1+deb8u2

<追記>
入ってない場合gitも必要ですね $ sudo apt install git
</追記>

source入手

$ git clone https://github.com/taka-tuos/nanotodon

make

コケた

$ cd nanotodon
$ make
make -r nanotodon
make[1]: Entering directory '/home/chip/src/nanotodon'
gcc -c -g -o nanotodon.o nanotodon.c
nanotodon.c: In function 'stream_event_notify':
nanotodon.c:110:12: warning: initialization discards 'const' qualifier from pointer target type
  char *t = json_object_get_string(notify_type);
            ^
nanotodon.c: At top level:
nanotodon.c:138:6: warning: conflicting types for 'stream_event_update'
 void stream_event_update(struct json_object *jobj_from_string)
      ^
nanotodon.c:128:3: note: previous implicit declaration of 'stream_event_update' was here
   stream_event_update(status);
   ^
nanotodon.c: In function 'stream_event_update':
nanotodon.c:180:14: warning: initialization discards 'const' qualifier from pointer target type
  char *src = json_object_get_string(content);
              ^
nanotodon.c:226:3: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
   for (int i = 0; i < json_object_array_length(media_attachments); ++i) {
   ^
nanotodon.c:226:3: note: use option -std=c99, -std=gnu99, -std=c11 or -std=gnu11 to compile your code
nanotodon.c:245:3: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
   for(int i = 0; i < term_w - (l + 4); i++) waddstr(scr, " ");
   ^
nanotodon.c: At top level:
nanotodon.c:589:6: warning: conflicting types for 'do_htl'
 void do_htl()
      ^
nanotodon.c:303:2: note: previous implicit declaration of 'do_htl' was here
  do_htl();
  ^
nanotodon.c: In function 'do_htl':
nanotodon.c:618:3: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
   for (int i = json_object_array_length(jobj_from_string) - 1; i >= 0; i--) {
   ^
nanotodon.c: In function 'main':
nanotodon.c:751:2: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
  for(int i = 0; i < term_w; i++) mvaddch(5, i, '-');
  ^
nanotodon.c:777:4: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
    for(int i = 0; i < term_w; i++) mvaddch(5, i, '-');
    ^
nanotodon.c:802:3: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
   for(int i = 0; i < txt.stringlen; i++) {
   ^
Makefile.in:21: recipe for target 'nanotodon.o' failed
make[1]: *** [nanotodon.o] Error 1
make[1]: Leaving directory '/home/chip/src/nanotodon'
Makefile.in:11: recipe for target 'default' failed
make: *** [default] Error 2

Makefileを修正したら通った

diff --git a/Makefile b/Makefile
index ac1828f..a35ee6a 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 TARGET         = nanotodon
 OBJS_TARGET    = nanotodon.o
 
-CFLAGS = -g
+CFLAGS = -g -std=gnu99
 LDFLAGS = 
 LIBS = -lc -lm -lcurl -ljson-c -lncursesw -lpthread
 

文字化け><

20180521_20:05:50-30304

Debian sid amd64ではMakefileの書き換えも必要なく文字化けもしない.

20180521_20:05:01-31796

$ cat /etc/debian_version 
buster/sid
$ uname -m
x86_64
$ dpkg-query -W build-essential libcurl4-openssl-dev libjson-c-dev libncurses-dev libncursesw5
build-essential 12.5
libcurl4-openssl-dev:amd64      7.60.0-1
libjson-c-dev:amd64     0.12.1-1.3
libncurses-dev:amd64    6.1+20180210-3
libncursesw5:amd64      6.1+20180210-3

system fontが汎用CJKになっていた

なんかPCを再起動してからフォントが変になっていました.中国語混じりのような汎用CJKらしきフォントになっています.今のフォントを調べるのは何だろうと探すと以下のページを見つけました.

fc-matchコマンドで確認するとWenQuanYi Zen Heiというフォントが設定されている状態のようです.パッケージを確認するとfonts-wqy-microheiのようです.おまけにfonts-wqy-zenheiという中国語フォントも入っていたのでこれらを削除しました.(fonts-notoも入っているのでもし中国語を表示する必要が出ても問題ないはず)

$ fc-match :lang=ja
wqy-zenhei.ttc: "WenQuanYi Zen Hei" "Regular"
$ apt-cache search WenQuanYi
fonts-wqy-microhei - Sans-serif style CJK font derived from Droid
fonts-wqy-zenhei - "WenQuanYi Zen Hei" A Hei-Ti Style (sans-serif) Chinese font
xfonts-wqy - WenQuanYi Bitmap Song CJK font for X
$ dpkg -l|grep -i  fonts-wqy
ii  fonts-wqy-microhei                            0.2.0-beta-3                            all          Sans-serif style CJK font derived from Droid
ii  fonts-wqy-zenhei                              0.9.45-7                                all          "WenQuanYi Zen Hei" A Hei-Ti Style (sans-serif) Chinese font
$ sudo apt purge fonts-wqy-microhei fonts-wqy-zenhei

dgm3を再起動してログインし直すと以前設定したフォントになっていました.

$ fc-match 
umeplus-p-gothic.ttf: "UmePlus P Gothic" "Regular"

logを見るとfonts-wqy-microheiの0.2.0-beta-3 で0.2.0-beta-2をアップデートしたものが見つかりました.恐らくこのタイミングで置き換わったのではないかと思います.それ以前の1年ほどのログの中にはなかったのでそれ以前に導入されたパッケージのようです.

中を見るとこのような設定が.

$ find fonts-wqy-microhei_0.2.0-beta-3_all -type f -print | grep etc
fonts-wqy-microhei_0.2.0-beta-3_all/etc/fonts/conf.avail/65-wqy-microhei.conf

以下を見ると標準より大きい数字なので手動で設定したフォントより優先度が高いので置き換わったのでしょうか?だとすると中途半端に設定をいじっていた自分のせいのようですorz

  1. 各日本語フォントパッケージは、/usr/share/fonts/truetype/

ttf-japanese-mincho.ttf または ttf-japanese-gothic.ttf をalternativesパスとして登録する。alternatives優先順位は次のように 規定する。

100より上: サードパーティまたはユーザ作成のフォント(IPA フォントなどはこのカテゴリに入る)
60: vl-gothic(標準)
50: ttf-sazanami-mincho, ttf-sazanami-gothic
20: ttf-kochi-mincho, ttf-kochi-gothic
20より下: 日本語を字形に含むがunified領域で中国語字形が使われているなど
日本語の表現には使いにくいフォント

とりあえず使わないであろうフォントが削除できてディスクスペースが開いたので良かったとしましょう.

環境

$ uname -m
x86_64
$ lsb_release -d
Description:    Debian GNU/Linux unstable (sid)
$ dpkg-query -W fontconfig
fontconfig      2.13.0-5

SteamのアプリがAndroidでリモートプレイが出来るSteam Linkを試す

20180521_01:05:06-2769

AndroidでSteamのホームストリーミングで遊べるSteam Linkというアプリが公開されていたのでちょっと試してみました.

先ずはPCのSteamでホームストリーミングを有効にしておきます.
20180519_01:05:27-31428

firewallはこの辺りを参考に空けておきます.

ホームストリーミングだけならこの辺?

UDP 27031 and 27036 (incoming, for In-Home Streaming)
TCP 27036 and 27037 (incoming, for In-Home Streaming)

PCでSteamを起動した状態でAndroidのSteam Linkを起動したらPCが見つかりました.しかしネットワークテストがいまいち.Wi-Fiが2.4GHz 11gの54MbpsでHostのPCもClientのAndroidも同じAPなのでこのままでは無理がありますね…….

Screenshot_20180519-015144

とりあえず強行してみるとHostPC側では動いていますが,Androidでは表示が崩れてこんな感じ.

Screenshot_20180519-015239

ちなみにHostPCはCore2DuoかつGPUもCPUのものなのでかなりスペック低いのでそのせいもありそうです.
近いうちに回線は有線1GHz+Wi-Fi 300Mbpsの環境で試してみようと思います.

このアプリケーションはPCのHost側もゲーム画面を表示してそれをAndroidに転送して動いているのでPCで別の作業をするという向けには使いづらい感じです.もし併用するなら仮想画面や別モニタに別のXを動かすとかしないといけないと思います.
とはいえAndroidでSteamゲームが遊べるのは便利そう.それにまだBETAなのでもっと良くなるでしょう.

add 2018-05-26)
iOS版はblockされたようです(◞‸◟)

画像ファイルのタイムスタンプをexifの時間に合わせる

画像ファイルをSNSなどにアップロードするときに回線が細かったりデータ転送料金が従量制だったりするときにリサイズしてアップロードしたりするのですが,サービスによってはファイルのタイムスタンプを参照して悲しいことになることも.
オリジナルのexifが残っている場合はそれを参照してファイルのタイムスタンプを修正することが可能です.
というメモ.

$ exiftool "-FileModifyDate<DateTimeOriginal" DP1M0???.resized.JPG
   10 image files updated

環境

$ dpkg-query -W libimage-exiftool-perl
libimage-exiftool-perl  10.96-1
$ lsb_release -d
Description:    Debian GNU/Linux unstable (sid)
$ uname -m
x86_64

関連

Mozcでシークレットモードやサジェストのオンオフをするコマンド機能を試す

以下のスライドを見て案外絵文字対応サービス多いのかもと思ったけど入力に日本語入力システムを使うとパスワードを覚えちゃうのが嫌だなとか,Emoji Pickerみたいなのを使うのも面倒.Mozcにはシークレットモードがあるけど( mozc_tool --mode=config_dialog のプライバシータブ )設定画面を呼び出して設定しないといけないので面倒.ショートカットか何かで切り替えが出来ないかなと探してみました.

Google日本語入力のヘルプページを見ても載っていない

フォーラムを検索すると以下ような要望と解答が.

試してみると問題なく動作するようです.

shutter_18-05-03_18:22:31_001

以下のページを見ると「こまんど」以外にも複数の単語で切り替えが出来るようです.

  • Google Developers Japan: Google 日本語入力の開発版をアップデートしました。(1.4.1003.10x)

    「コマンド」機能が追加されました。「コマンド」と入力し、変換候補を選択することで、設定ツールを起動することなく、【シークレットモード】のオン・オフ、および【プレゼンテーションモード】のオン・オフを変更することができます。

    「秘密」「シークレット」「シークレットモード」「プライバシー」「プライベート」と入力することで、【シークレットモード】のオン・オフを変更することができます。
    「サジェスト」「予測」「予測入力」「予測変換」「プレゼンテーション」「プレゼン」と入力することで、【プレゼンテーションモード】のオン・オフを変更することができます。

「きょう」「きのう」「おととい」「ことし」「きょねん」などで年月,「2018ねん」等で和暦,郵便番号で住所,「ばーじょん」でMozcのバージョンなどは知っていましたが「こまんど」は知りませんでした.
この辺りの一覧をヘルプページ辺りに作ってくれるといいのになとか.

環境

$ dpkg-query -W mozc-server
mozc-server     2.23.2815.102+dfsg-1
$ neofetch
       _,met$$$$$gg.          mk@x200 
    ,g$$$$$$$$$$$$$$$P.       ------- 
  ,g$$P"     """Y$$.".        OS: Debian GNU/Linux unstable (sid) x86_64 
 ,$$P'              `$$$.     Model: 74574PJ ThinkPad X200 
',$$P       ,ggs.     `$$b:   Kernel: 4.14.0-2-amd64 
`d$$'     ,$P"'   .    $$$    Uptime: 8 hours, 52 minutes 
 $$P      d$'     ,    $$P    Packages: 5617 
 $$:      $$.   -    ,d$$'    Shell: bash 4.4.19 
 $$;      Y$b._   _,d$P'      Resolution: 1280x800 
 Y$$.    `.`"Y$$$$P"'         WM: awesome 
 `$$b      "-.__              Terminal: sakura 
  `Y$$                        Terminal Font: Fira Code 11 
   `Y$$.                      CPU: Intel Core 2 Duo P8400 (2) @ 2.267GHz 
     `$$b.                    GPU: Intel® GM45 Express Chipset 
       `Y$$b.                 Memory: 5292MiB / 7878MiB 
          `"Y$b._ 
              `"""                                    

OpenJDK で JOSM

Javaで動作するOpenStreetMapエディタのJOSMをLinux上のOpenJDKで動かすメモです.
Debian sid amd64 / Ubuntu 16.04 LTS ARM64 で確認しています.

JOSMの入手

JOSMを次のページから入手します.josm-tested.jar をよく使っています.

OpenJDKインストール

2015年12月くらいにはこんなメッセージが出ていて現在はJava 8以上が必要になっています.

このバージョンのJavaはもうすぐサポート対象から外れます。 Java 8以上にアップグレードしてください!

ここでは OpenJDK 8 を導入

$ sudo apt install openjdk-8-jre

javaの確認

OpenJDK 8になっている.もし違うバージョンが表示されたら次の項目へ.

$ java -version
openjdk version "1.8.0_151"
OpenJDK Runtime Environment (build 1.8.0_151-8u151-b12-0ubuntu0.16.04.2-b12)
OpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode)

javaが複数入っていてjavaコマンドの結果が想定しているバージョンではない場合切り替える

OpenJDK 8の場合はここはスキップする.

$ sudo update-alternatives --config java

JOSM起動

-Dawt.useSystemAAFontSettings=onはフォントのアンチエイリアスを有効にするオプション.LCDの場合onの代わりにlcd.

$ java -jar -Dawt.useSystemAAFontSettings=on ./josm-latest.jar
追記)
他の環境だとこの辺のどれかが使えそう(未確認)

Let’s Encryptの更新に失敗する

最近はこんな感じでLet’s Encryptの証明書の更新を更新しているのですが今回失敗しました.
(DocumenteRootをFQDNにしている前提)

$ sudo /bin/sh -c "/usr/bin/find /etc/letsencrypt/renewal/*.conf -type f | /usr/bin/xargs /usr/bin/basename -s .conf | xargs -n1 -I{} /usr/bin/letsencrypt renew --webroot -w /var/www/{}/ -d {}"

こんなふうに怒られます.
(仕様が変わった?)

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Currently, the renew verb is capable of either renewing all installed certificates that are due to be renewed or renewing a single certificate specified by its name. If you would like to renew specific certificates by their domains, use the certonly command. The renew verb may provide other options for selecting certificates to renew in the future.

とりあえずはletsencrypt renewletsencrypt certonlyにしたら通りました.

$ sudo /bin/sh -c "/usr/bin/find /etc/letsencrypt/renewal/*.conf -type f | /usr/bin/xargs /usr/bin/basename -s .conf | xargs -n1 -I{} /usr/bin/letsencrypt certonly --webroot -w /var/www/{}/ -d {}"

これで更新できたと思ったら1つのドメインで失敗しています.

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Cert is due for renewal, auto-renewing...
Renewing an existing certificate
Performing the following challenges:
http-01 challenge for files.matoken.org
Using the webroot path /var/www/files.matoken.org for all unmatched domains.
Waiting for verification...
Cleaning up challenges
Failed authorization procedure. files.matoken.org (http-01): urn:acme:error:unauthorized :: The client lacks sufficient authorization :: Invalid response from http://files.matoken.org/.well-known/acme-challenge/Be7Aiai4UH9CDqacTaEZOMH4SxSQbtFqxFcPXcCtJEs: "<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>  
</head><body>
<h1>Not Found</h1>
<p"

IMPORTANT NOTES:
 - The following errors were reported by the server:

   Domain: files.matoken.org  
   Type:   unauthorized
   Detail: Invalid response from
   http://files.matoken.org/.well-known/acme-challenge/Be7Aiai4UH9CDqacTaEZOMH4SxSQbtFqxFcPXcCtJEs:
   "<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
   <html><head>
   <title>404 Not Found</title>
   </head><body>
   <h1>Not Found</h1>
   <p"

   To fix these errors, please make sure that your domain name was
   entered correctly and the DNS A record(s) for that domain
   contain(s) the right IP address.

ファイルをDoumentRootに置いてLet’s Encryptからアクセスされるのですがそこでそのファイルが見つからないと失敗しています.このドメインはhttpを設定していませんでした.
てことでapacheでRewriteの設定をしてあげると

RewriteEngine On
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]

通りました.

$ sudo /usr/bin/letsencrypt certonly --webroot -w /var/www/files.matoken.org/ -d files.mato
ken.org
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Cert is due for renewal, auto-renewing...
Renewing an existing certificate
Performing the following challenges:
http-01 challenge for files.matoken.org
Using the webroot path /var/www/files.matoken.org for all unmatched domains.
Waiting for verification...
Cleaning up challenges
Generating key (2048 bits): /etc/letsencrypt/keys/0003_key-certbot.pem
Creating CSR: /etc/letsencrypt/csr/0003_csr-certbot.pem

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at
   /etc/letsencrypt/live/files.matoken.org/fullchain.pem. Your cert
   will expire on 2018-05-31. To obtain a new or tweaked version of
   this certificate in the future, simply run certbot again. To
   non-interactively renew *all* of your certificates, run "certbot
   renew"
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

certbotのversionがかなり古いですね…….

$ dpkg -l|grep -i certbot
ii  certbot                               0.10.2-1                          all          automatically configure HTTPS using Let's Encrypt
ii  python-certbot                        0.10.2-1                          all          main library for certbot

てことでbackportのものに入れ替え.

$ sudo apt remove certbot
$ sudo apt install python-certbot-apache -t stretch-backports
$ apt show certbot
Package: certbot
Version: 0.21.1-1~bpo9+1
Priority: optional
Section: web
Source: python-certbot
Maintainer: Debian Let's Encrypt <letsencrypt-devel@lists.alioth.debian.org>
Installed-Size: 53.2 kB
Provides: letsencrypt
Depends: python3-certbot (= 0.21.1-1~bpo9+1), python3:any
Suggests: python3-certbot-apache, python3-certbot-nginx, python-certbot-doc
Breaks: letsencrypt (<= 0.6.0)
Replaces: letsencrypt
Homepage: https://certbot.eff.org/
Download-Size: 20.4 kB
APT-Manual-Installed: no
APT-Sources: http://ftp.jp.debian.org/debian stretch-backports/main amd64 Packages
Description: automatically configure HTTPS using Let's Encrypt
 The objective of Certbot, Let's Encrypt, and the ACME (Automated
 Certificate Management Environment) protocol is to make it possible
 to set up an HTTPS server and have it automatically obtain a
 browser-trusted certificate, without any human intervention. This is
 accomplished by running a certificate management agent on the web
 server.
 .
 This agent is used to:
 .
   - Automatically prove to the Let's Encrypt CA that you control the website
   - Obtain a browser-trusted certificate and set it up on your web server
   - Keep track of when your certificate is going to expire, and renew it
   - Help you revoke the certificate if that ever becomes necessary.
 .
 This package contains the main application, including the standalone
 and the manual authenticators.

N: There is 1 additional record. Please use the '-a' switch to see it

てことでclientが古かったのであまり参考になら無さそうなメモでした.