DebianでVSCodiumがアップデートできなくなって困る

VSCodeのMicroSoftのバイナリブロブ等を除外したVSCodiumを使うのに以下のリポジトリを利用しています.Debianだとamd64, i386, arm64, armhfのArchtectureに対応していて便利です.

しかし最近アップデートに失敗します.

apt update に失敗する
Err:7 https://gitlab.com/paulcarroty/vscodium-deb-rpm-repo/raw/repos/debs vscodium InRelease
  429  Too Many Requests [IP: 192.168.1.102 3142]
  :
  :
W: Failed to fetch https://gitlab.com/paulcarroty/vscodium-deb-rpm-repo/raw/repos/debs/dists/vscodi
  :
  :

apt-cacher-ng を挟んでいるのでそこのキャッシュがおかしいのかなとか思いましたが https なのでキャッシュしていません.念の為デーモンを再起動しても変わらず.
直にアクセスしても同じステータスです.

proxyなしで直にアクセス
$ HTTP_PROXY='' w3m -dump_head https://gitlab.com/paulcarroty/vscodium-deb-rpm-repo/raw/repos/debs/dists/vscodium/InRelease | grep ^HTTP
HTTP/1.1 429 Too Many Requests

429 Too Many Requests ってことはサーバ側の問題かな?少し待てば復旧する?と思ったけど1日経っても状況は変わらず.

てことでsiteを見に行くと導入手順のsource.listのurlが変わっているようです.

Add the repository:

echo 'deb [signed-by=/etc/apt/trusted.gpg.d/vscodium-archive-keyring.gpg] https://paulcarroty.gitlab.io/vscodium-deb-rpm-repo/debs/ vscodium main' | sudo tee /etc/apt/sources.list.d/vscodium.list

これに合わせて自分のsource.listを書き換えました.( /etc/apt/sources.list, /etc/apt/sources.list.d/codium.list 等)

apt edit-sources <sourcefile>
-deb https://gitlab.com/paulcarroty/vscodium-deb-rpm-repo/raw/repos/debs/ vscodium main
+deb https://paulcarroty.gitlab.io/vscodium-deb-rpm-repo/debs/ vscodium main

鍵は変わっていないようでurlを書き換えてupdate&&upgradeを行うとOKでした.

apt updateが成功
Get:8 https://paulcarroty.gitlab.io/vscodium-deb-rpm-repo/debs vscodium InRelease [3,828 B]

最新になりました :)

$ codium --version
1.48.1
3dd905126b34dcd4de81fa624eb3a8cbe7485f13
x64

アイコンも変わったようです.

vscodium old 100vscodium 100

そいてこの記事を書くためにsiteを見直すと以下の記述に気づきました.はじめからこれを見ていれば…….

Warning: repository migrated to Gitlab Pages, update your configs

環境
$ dpkg-query -W codium apt dpkg
apt     2.1.10
codium  1.48.1-1598037458
dpkg    1.20.5
$ lsb_release -dr
Description:    Debian GNU/Linux bullseye/sid
Release:        unstable
$ uname -m
x86_64

basE91で少し効率よくバイナリをテキストに変換

バイナリを利用できない環境でのデータ転送時にUNIX環境では古くは uudecode, uuencode が,日本のパソコン通信では ish などが使われていました.近頃は base64 がよく使われているように感じます.

これらのツールではバイナリをASCIIで表現するためサイズが大きくなってしまいます.でも全てのASCIIを使っていません.

今回見つけたbasE91はASCIIの0x21-0x7Eのうち -, \, ' を除いた91文字を使ってデコードすることで効率よくするもののようです.

早速試してみます.Debianパッケージがないかなと探しましたがありませんでした.

sourceを貰ってきてmakeします.
※hashは「 basE91 – Browse /basE91/0.6.0 at SourceForge.net 」で確認できる.

$ wget http://downloads.sourceforge.net/base91/base91-0.6.0.tar.gz
$ md5sum base91-0.6.0.tar.gz
e227841d900cc463a162bd79775aeb54  base91-0.6.0.tar.gz
$ sha1sum base91-0.6.0.tar.gz
00cfd573ec8b3d0160dbf53e2c7a49b99a1aa720  base91-0.6.0.tar.gz
$ tar tvf base91-0.6.0.tar.gz
-rw-r--r-- 0/0             575 2005-06-25 00:00 base91-0.6.0/AWK/README
-rwxr-xr-x 0/0             727 2006-11-02 05:13 base91-0.6.0/AWK/b91dec.awk
-rw-r--r-- 0/0             932 2006-09-04 03:00 base91-0.6.0/PHP4/README
-rw-r--r-- 0/0            1513 2006-11-02 05:13 base91-0.6.0/PHP4/base91.php
-rw-r--r-- 0/0             149 2006-09-04 03:00 base91-0.6.0/test/Makefile
-rw-r--r-- 0/0            4265 2006-11-02 05:13 base91-0.6.0/test/test.sh
-rw-r--r-- 0/0             332 2006-08-25 17:00 base91-0.6.0/DOS-asm/readme.txt
-rw-r--r-- 0/0            3487 2006-11-02 05:13 base91-0.6.0/DOS-asm/b91enc.asm
-rw-r--r-- 0/0            5034 2006-11-02 05:13 base91-0.6.0/Java/b91cli.java
-rw-r--r-- 0/0            3297 2006-11-02 05:13 base91-0.6.0/Java/basE91.java
-rw-r--r-- 0/0            1526 2006-11-02 05:13 base91-0.6.0/Java/license.txt
-rw-r--r-- 0/0             793 2006-11-02 05:13 base91-0.6.0/Java/readme.txt
-rw-r--r-- 0/0             112 2006-09-04 03:00 base91-0.6.0/Java/manifest.mf
-rwxr-xr-x 0/0             178 2006-11-02 05:13 base91-0.6.0/Java/build_jar.sh
-rw-r--r-- 0/0            7502 2006-11-02 05:13 base91-0.6.0/cli.c
-rw-r--r-- 0/0            5066 2006-11-02 05:13 base91-0.6.0/base91.c
-rw-r--r-- 0/0            1501 2006-11-02 05:13 base91-0.6.0/LICENSE
-rw-r--r-- 0/0             561 2006-11-02 05:13 base91-0.6.0/base91.h
-rw-r--r-- 0/0            2360 2006-11-02 05:13 base91-0.6.0/README
-rw-r--r-- 0/0            1762 2006-11-02 05:13 base91-0.6.0/base91.1
-rw-r--r-- 0/0             903 2006-09-04 03:00 base91-0.6.0/Makefile
-rw-r--r-- 0/0            2330 2006-11-02 05:13 base91-0.6.0/NEWS
$ tar xf base91-0.6.0.tar.gz
$ cd base91-0.6.0
$ make
$ ./base91 -h
Usage: base91 [OPTION]... [FILE]
basE91 encode or decode FILE, or standard input, to standard output.

  -d, --decode          decode data
  -m SIZE               use SIZE bytes of memory for buffers (suffixes b, K, M)
  -o, --output=FILE     write to FILE instead of standard output
  -v, --verbose         verbose mode
  -w, --wrap=COLS       wrap encoded lines after COLS characters (default 76)
  --help                display this help and exit
  --version             output version information and exit

With no FILE, or when FILE is -, read standard input.

encodeしてdecodeしてみます.
当たり前ですが,encode, decodeしてもdiffもhashも同じです.

$ ./base91 ./base91 -o ./base91.base91
$ ./base91 -d ./base91.base91 -o ./base91.tmp
$ diff ./base91 ./base91.tmp
$ sha512sum ./base91
bc903be7c5b694841a9d0303351846f80f4798ad8848e8f298cf2c4818c68a2270b065db495b969503b25cdf672632e1cced18094f935fed47b75718c3c3e976  ./base91
$ ./base91 ./base91 | ./base91 -d | sha512sum
bc903be7c5b694841a9d0303351846f80f4798ad8848e8f298cf2c4818c68a2270b065db495b969503b25cdf672632e1cced18094f935fed47b75718c3c3e976  -

basE91, base64, base32, uudecode で変換してみます.
basE91 が一番小さいですね

$ ls --block-size=1 -s ./base91
16384 ./base91
$ ./base91 ./base91 | wc -c
17340
$ base64 ./base91 | wc -c
19615
$ uuencode ./base91 - | wc -c
20024
$ base32 ./base91 | wc -c
23538

圧縮すると大分小さくなります.圧縮のほうがずっと効きますね.

$ xz -c ./base91 | wc -c
4528
$ xz -c ./base91 | ./base91 | wc -c
5640
$ xz -c ./base91 | base64 | wc -c
6120
$ xz -c ./base91 | uuencode - | wc -c
6260
$ xz -c ./base91 | base32 | wc -c
7344

他のファイルも試してみます./usr/bin 以下のファイルを適当に見繕って比較x5です.

#!/bin/bash

XZ=`mktemp`
for i in `seq 1 5`
do
  CMD=`find /usr/bin -type f | shuf -n 1`
  echo $CMD
  echo -n "raw  "
  stat -c %s $CMD
  xz -9 -c $CMD > $XZ
  echo -n "xz "
  stat -c %s $XZ
  echo -n "xz.uu  "
  uuencode $XZ - | wc -c
  echo -n "xz.base64  "
  base64 $XZ | wc -c
  echo -n "xz.base91  "
  base91 $XZ | wc -c
done
rm $XZ
$ bash ./bin2ascii.bash | column -t
/usr/bin/lxc-snapshot
raw                          27632
xz                           6756
xz.uu                        9328
xz.base64                    9127
xz.base91                    8418
/usr/bin/dh_installtmpfiles
raw                          3263
xz                           1540
xz.uu                        2144
xz.base64                    2084
xz.base91                    1917
/usr/bin/pbmtogo
raw                          10384
xz                           3164
xz.uu                        4380
xz.base64                    4276
xz.base91                    3942
/usr/bin/chartread
raw                          3966528
xz                           772956
xz.uu                        1064980
xz.base64                    1044169
xz.base91                    963047
/usr/bin/spamassassin
raw                          29898
xz                           9608
xz.uu                        13258
xz.base64                    12981
xz.base91                    11971

おまけ?armelでstatic linkなバイナリを作ってみました.Sipeed Lichee Nano で動かないかな?と.

$ git diff HEAD~~ Makefile
diff --git a/Makefile b/Makefile
index 246aede..129acff 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
-CFLAGS = -Wall -W -O2
-LDFLAGS = -s
+CFLAGS = -static -Wall -W -O2
+LDFLAGS = -static -s

-CC = gcc
+CC = arm-linux-gnueabi-gcc
 INSTALL = install
 INSTALL_DATA = $(INSTALL) -m 444
 INSTALL_PROGRAM = $(INSTALL) -m 555

qemu-arm-static では動くのを確認したけど実機では未確認です.

$ file ./base91
./base91: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, BuildID[sha1]=88ec4ccbf69c4bb41640b5de63b6b5373b7e5365, for GNU/Linux 3.2.0, stripped
$ ldd ./base91
        not a dynamic executable
$ echo 😺 | qemu-arm-static ./base91 | pee cat "qemu-arm-static ./base91 -d"
=~m6xHA
😺

以下にバイナリとuuencodeしたものが置いてあります.

blog元のmemo

環境
$ dpkg-query -W gcc-10-arm-linux-gnueabi qemu-user-static gcc coreutils sharutils
coreutils       8.32-3
gcc     4:10.1.0-1
gcc-10-arm-linux-gnueabi        10.2.0-3cross2
qemu-user-static        1:5.0-13
sharutils       1:4.15.2-5
$ lsb_release -dr
Description:    Debian GNU/Linux bullseye/sid
Release:        unstable
$ uname -m
x86_64

Raspberry Pi OS/Debian/Ubuntuでの既定のPython切り替え

最近使うPythonアプリはPython3が多くなっています.Python2のEoLが迫っているので正しいのですが,手元の環境では python コマンドは python2 に向いています.python3 コマンドを叩けばいいのですが,これを python3 に向けられないかなと試してみました.

Raspberry Pi OS arm64(busterベース)でのPython確認してみます.python コマンドは python2.7 を呼ぶようになっています.

$ python --version
Python 2.7.16
$ ls -l `which python`
lrwxrwxrwx 1 root root 7  3月  5  2019 /usr/bin/python -> python2
$ ls -l `which python2`
lrwxrwxrwx 1 root root 9  3月  5  2019 /usr/bin/python2 -> python2.7
$ ls -l `which python3`
lrwxrwxrwx 1 root root 9  3月 26  2019 /usr/bin/python3 -> python3.7

update-alternatives で管理されてるのかな?と思いましたが設定がなさそうです.

$ update-alternatives --get-selections|grep -i ^python

update-alternatives を手動で設定してみます.
これで python コマンドが python3.7 を呼ぶようになりました.

$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
update-alternatives: /usr/bin/python (python) を提供するために自動モードで /usr/bin/python2.7 を使います
$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.7 2
update-alternatives: /usr/bin/python (python) を提供するために自動モードで /usr/bin/python3.7 を使います
$ ls -l `which python`
lrwxrwxrwx 1 root root 24  7月 28 08:47 /usr/bin/python -> /etc/alternatives/python
$ python --version
Python 3.7.3
$ update-alternatives --query python
Name: python
Link: /usr/bin/python
Status: auto
Best: /usr/bin/python3.7
Value: /usr/bin/python3.7

Alternative: /usr/bin/python2.7
Priority: 1

Alternative: /usr/bin/python3.7
Priority: 2

切り替えたいときはこんな感じで選択肢なおせばok.

$ sudo update-alternatives --config python
alternative python (/usr/bin/python を提供) には 2 個の選択肢があります。

  選択肢    パス              優先度  状態
------------------------------------------------------------
* 0            /usr/bin/python3.7   2         自動モード
  1            /usr/bin/python2.7   1         手動モード
  2            /usr/bin/python3.7   2         手動モード

現在の選択 [*] を保持するには <Enter>、さもなければ選択肢の番号のキーを押してください:

Debian asid amd64, Ubuntu 20.04 LTS amd64 でも設定してみました.

Debian sid amd64
$ update-alternatives --query python
Name: python
Link: /usr/bin/python
Status: auto
Best: /usr/bin/python3.8
Value: /usr/bin/python3.8

Alternative: /usr/bin/python2.7
Priority: 1

Alternative: /usr/bin/python3.7
Priority: 2

Alternative: /usr/bin/python3.8
Priority: 3
Ubuntu 20,04 LTS amd64
$ update-alternatives --query python
Name: python
Link: /usr/bin/python
Status: auto
Best: /usr/bin/python3.8
Value: /usr/bin/python3.8

Alternative: /usr/bin/python2.7
Priority: 1

Alternative: /usr/bin/python3.5
Priority: 2

Alternative: /usr/bin/python3.8
Priority: 3

てことで python コマンドが python3 になりました.しかしシステムワイドな設定なのでシステムのプログラムなどで問題が出るかもしれないですね.
問題が起こったらpython2に戻しましょう.

Rasoberry Pi OS amd64
$ dpkg-query -W python python3
python  2.7.16-1
python3 3.7.3-1
$ lsb_release -dr
Description:    Debian GNU/Linux 10 (buster)
Release:        10
$ uname -m
aarch64
$ cat /proc/device-tree/model&&echo
Raspberry Pi 3 Model B Rev 1.2
Debian sid amd64
$ dpkg-query -W python python3 python3.7
python  2.7.17-2
python3 3.8.2-3
python3.7       3.7.7-1+b1
$ lsb_release -dr
Description:    Debian GNU/Linux bullseye/sid
Release:        unstable
$ uname -m
x86_64
Ubuntu 20.04 LTS amd64
$ dpkg-query -W python python3 python3.7
python  2.7.17-1
python3 3.8.2-0ubuntu2
python3.7
$ lsb_release -dr
Description:    Ubuntu 20.04.1 LTS
Release:        20.04
$ uname -m
x86_64

Sipeed Lichee Nanoでhello world

2020-07-23低レベル勉強会に参加しました.Zoom.usでの開催でした.

内容はLinux名刺的なものを開発しようという内容で,リファレンスとしてSDカードサイズの小さなLinuxの動作するarmコンピュータのSipeed Lichee Nanoを使いました.

欲しい場合は1000円ちょいくらいからで入手できそうです.

Lichee Nanoを持っていない人はリモートで触れるようにしてあったので持っていない私も楽しめました.

このリモート開発の仕組みはLichee NanoとRaspberry PiをUSB経由のUARTで接続し,Raspberry PiでGNU screenを起動,ssh経由でGNU screenに繋いで操作という感じです.
GNU screenをGotty等にするとウェブブラウザで参加できてちょっと便利かもと思ったりも.(GoTTYは開発止まってるように見えるから別のもののほうがいいかもしれない)

Lichee Nanoで何かを動かしたい.armだけどarmhf動くのかな?とりあえずなにか転送して動かしてみようと.

とりあえずDebianのarmhfバイナリをuuencodeしてコピペで転送してみます.これが動けばDebianのパッケージ群が利用できるかもだけど…….

まずは簡単そうなfortuneを試します.

Debian sidでfortune-modパッケージのarmhfバイナリパッケージをダウンロードして展開(add archtecture armhfしてある環境)
$ apt download -t armhf fortune-mod
$ unar fortune-mod_1.99.1-7+b1_armhf.deb
$ cd fortune-mod_1.99.1-7+b1_armhf
$ tar xf data.tar.xz
$ cd usr/games

Lichee Nanoはserialで接続されていて,Internetには繋がっていないのでバイナリファイルの転送にはuudecode/uuencodeを使いました.久々です.
手元のGNU sharutils 4.15.2のuudecodeにはbase64を使う -m, --base64 があるので良さそう.と思ったけどLichee Nanoの方はbusyboxのもので非対応でした.

ローカル端末で圧縮してuuencodeしてクリップボードへ
$ gzip -c fortune | uuencode fortune.gz > fortune.gz.uu
$ cat fortune.gz.uu | xclip
リモートで伸張して解凍
# cat | uudecode    #ここでクリップボードから貼り付け
# zcat fortune.gz > fortune
# rm fortune.gz

そして…​…​

# ./fortune
-sh: ./fortune: not found
# ldd ./fortune
checking sub-depends for 'not found'
checking sub-depends for '/lib/libc.so.6'
/lib/ld-linux.so.3 (0xb6fa0000)
librecode.so.0 => not found (0x00000000)
libc.so.6 => /lib/libc.so.6 (0x00000000)
/lib/ld-linux.so.3 => /lib/ld-linux.so.3 (0x00000000)

これを動かすのはダイナミックリンクされているものを用意してあげないといけないのでストレージの容量的に難しいですね.

ここではgzipで圧縮しましたが,Lichee Nanoのbusyboxにxzがありました.gzipよりxzにしたほうが小さくなりますね.試してみるとこんな感じでした.$ xz -c fortune | uuencode fortune.xz > fortune.xz.uu

サイズ比較
-rw-r--r-- 1 matoken matoken 22368 Jul 23 15:11 fortune #元ファイル
-rw-r--r-- 1 matoken matoken 30844 Jul 23 14:58 fortune.uu #uudecode
-rw-r--r-- 1 matoken matoken 14975 Jul 23 15:08 fortune.gz.uu #zip + uudecode
-rw-r--r-- 1 matoken matoken 13047 Jul 23 15:47 fortune.xz.uu #xz + uudecode

そういえばあまり有名ではないですがbasE91なんてものもあります.base64よりサイズが小さくなりますが導入からやらないといけないのでちょっと面倒.

Hello worldを試してみます.適当にプログラムを用意してスタティックリンクでコンパイルしてみます.

$ cat hello.c
#include <stdio.h>
int
main(void)
{
    printf("Hello, world!\n");
    return 0;
}
$ gcc -static ./hello.c
$ ./a.out
Hello, world!
$ ls -l a.out
-rwxr-xr-x 1 pi pi 571120 7月 23 16:18 a.out

でかい…​…​

とりあえずでかいのはおいといてこれだとarm64なので動くはずがない.ということでクロスコンパイル環境を用意します.

今回試したホストはDebian sid amd64/Ubuntu 20.04 LTS arm64/Raspberry Pi OS arm64です.いずれも同じ手順でOKでした.

crossbuild-essential-<arch> パッケージで各種アーキテクチャの環境が導入できるようです.

$ apt-cache search crossbuild-essential-
crossbuild-essential-amd64 - Informational list of cross-build-essential packages
crossbuild-essential-arm64 - Informational list of cross-build-essential packages
crossbuild-essential-armel - Informational list of cross-build-essential packages
crossbuild-essential-armhf - Informational list of cross-build-essential packages
crossbuild-essential-i386 - Informational list of cross-build-essential packages
crossbuild-essential-powerpc - Informational list of cross-build-essential packages
crossbuild-essential-ppc64el - Informational list of cross-build-essential packages
crossbuild-essential-s390x - Informational list of cross-build-essential packages
crossbuild-essential-mips - Informational list of cross-build-essential packages
crossbuild-essential-mips64 - Informational list of cross-build-essential packages
crossbuild-essential-mips64el - Informational list of cross-build-essential packages
crossbuild-essential-mips64r6 - Informational list of cross-build-essential packages
crossbuild-essential-mips64r6el - Informational list of cross-build-essential packages
crossbuild-essential-mipsel - Informational list of cross-build-essential packages
crossbuild-essential-mipsr6 - Informational list of cross-build-essential packages
crossbuild-essential-mipsr6el - Informational list of cross-build-essential packages

沢山あります.今回はarmlf/armhfの crossbuild-essential-armel, crossbuild-essential-armhf を導入しました.

$ sudo apt install crossbuild-essential-armel crossbuild-essential-armhf

gccだけでいい場合はarmlfは gcc-arm-linux-gnueabi,armhfは gcc-arm-linux-gnueabihf だけでOKです.

まずは arm-linux-gnueabihf-gcc を使ってarmhfのバイナリを作ります.

$ /usr/bin/arm-linux-gnueabihf-gcc -static ./hello.c
$ strip a.out
$ xz -c a.out | uuencode a.out.xz > a.out.xz.uu

armhfは駄目そうです.

# cat | uudecode
^d
# xzcat ./a.out.xz > ./a.out
# chmod +x ./a.out
# ./a.out
Segmentation fault

次は gcc-arm-linux-gnueabi でarmlfのバイナリを作って試すと動きました.

$ /usr/bin/arm-linux-gnueabi-gcc -static ./hello.c
$ strip a.out
$ xz -c a.out | uuencode a.out.xz > a.out.xz.uu
# cat | uudecode
^d
# xzcat ./a.out.xz > ./a.out
# chmod +x ./a.out
# ./a.out
Hello, world!
# /usr/bin/time -f "%M KB" ./a.out
Hello, world!
2144 KB

この辺りで今回は時間切れ.次回の同じような感じになりそうです.興味のある方は以下のページから.

とりあえずarmelのバイナリが動くようなのがわかったので面白そうな小さなプログラムを試そうかなと思っています.cowsayとか好きなんだけどこれはPerlなので容量的に難しそう.とりあえずfortuneあたりかな?

以前PQI Air PenでやったようにSD cardを用意してそこにDebian armlf環境を展開してchrootとかもできそうです.

rsync 3.2.0の新機能を少し試す

ファイル同期にとても便利なrsyncの3.2.0がリリースされました.

バグフィクスや,いくつかの新機能が入ったようなので少し試してみました.

※1. この記事投稿時には 3.2.2 が出ています.
※2. 鹿児島Linux勉強会 2020.06で発表したものと同じ内容です.

導入例

Debian sid amd64 & Ubuntu 20.04 LTS amd64

$ sudo apt build-dep rsync
$ sudo apt install libxxhash-dev libzstd-dev liblz4-dev
$ wget -c \
https://download.samba.org/pub/rsync/rsync-3.2.0.tar.gz \
https://download.samba.org/pub/rsync/rsync-3.2.0.tar.gz.asc \
https://opencoder.net/WayneDavison.key
$ gpg2 --import ./WayneDavison.key
$ gpg2 --verify ./rsync-3.2.0.tar.gz.asc
$ tar tvzf ./rsync-3.2.0.tar.gz
$ tar xzf ./rsync-3.2.0.tar.gz
$ cd rsync-3.2.0
$ ./configure --help
$ ./configure
$ make
$ ./rsync --version
rsync  version 3.2.0  protocol version 31
Copyright (C) 1996-2020 by Andrew Tridgell, Wayne Davison, and others.
Web site: http://rsync.samba.org/
Capabilities:
    64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints,
    socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace, append,
    ACLs, xattrs, iconv, symtimes, prealloc, SIMD
Checksum list:
    xxh64 (xxhash) md5 md4 none
Compress list:
    zstd lz4 zlibx zlib none

rsync comes with ABSOLUTELY NO WARRANTY.  This is free software, and you
are welcome to redistribute it under certain conditions.  See the GNU
General Public Licence for details.
Note
gpg鍵は次から入手できます.rsync download

Raspberri Pi OS amd64

Raspberry Pi OS arm64の場合 libzstd-dev のバージョンが 1.3.8+dfsg-3 と少し古くbuildに失敗します. ./configure --disable-zstd としてzstdを無効にするか,sourceから zstd 1.4.5 を導入することでbuild出来ました.

$ make
  :
token.c: In function ‘init_compression_level’:
token.c:73:40: warning: implicit declaration of function ‘ZSTD_minCLevel’; did you mean ‘ZSTD_maxCLevel’? [-Wimplicit-function-declaration]
   min_level = skip_compression_level = ZSTD_minCLevel();
                                        ^~~~~~~~~~~~~~
                                        ZSTD_maxCLevel
token.c: In function ‘send_zstd_token’:
token.c:685:2: error: unknown type name ‘ZSTD_EndDirective’; did you mean ‘ZSTD_DDict’?
  ZSTD_EndDirective flush = ZSTD_e_continue;
  ^~~~~~~~~~~~~~~~~
  ZSTD_DDict
token.c:685:28: error: ‘ZSTD_e_continue’ undeclared (first use in this function)
  ZSTD_EndDirective flush = ZSTD_e_continue;
                            ^~~~~~~~~~~~~~~
token.c:685:28: note: each undeclared identifier is reported only once for each function it appears in
token.c:701:3: warning: implicit declaration of function ‘ZSTD_CCtx_setParameter’ [-Wimplicit-function-declaration]
   ZSTD_CCtx_setParameter(zstd_cctx, ZSTD_c_compressionLevel, do_compression_level);
   ^~~~~~~~~~~~~~~~~~~~~~
token.c:701:37: error: ‘ZSTD_c_compressionLevel’ undeclared (first use in this function); did you mean ‘skip_compression_level’?
   ZSTD_CCtx_setParameter(zstd_cctx, ZSTD_c_compressionLevel, do_compression_level);
                                     ^~~~~~~~~~~~~~~~~~~~~~~
                                     skip_compression_level
token.c:751:13: error: ‘ZSTD_e_flush’ undeclared (first use in this function); did you mean ‘ZSTD_DCtx_s’?
     flush = ZSTD_e_flush;
             ^~~~~~~~~~~~
             ZSTD_DCtx_s
token.c:753:8: warning: implicit declaration of function ‘ZSTD_compressStream2’; did you mean ‘ZSTD_compressStream’? [-Wimplicit-function-declaration]
    r = ZSTD_compressStream2(zstd_cctx, &zstd_out_buff, &zstd_in_buff, flush);
        ^~~~~~~~~~~~~~~~~~~~
        ZSTD_compressStream
$ cd ..
$ sudo apt remove libzstd-dev
$ wget https://github.com/facebook/zstd/releases/download/v1.4.5/zstd-1.4.5.tar.gz \
https://github.com/facebook/zstd/releases/download/v1.4.5/zstd-1.4.5.tar.gz.sha256
$ sha256sum -c ./zstd-1.4.5.tar.gz.sha256
$ tar tvf ./zstd-1.4.5.tar.gz | lv
$ tar xf ./zstd-1.4.5.tar.gz
$ cd zstd-1.4.5
$ make
$ sudo make install
$ cd ../rsync-3.2.0
$ ./configure && make

Debian sid amd64

Debian sid amd64 環境にはすでに降ってきているのでパッケージから導入するだけでOKです.

$ sudo apt install rsync
$ rsync --version
rsync  version 3.2.0  protocol version 31
Copyright (C) 1996-2020 by Andrew Tridgell, Wayne Davison, and others.
Web site: http://rsync.samba.org/
Capabilities:
    64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints,
    socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace, append,
    ACLs, xattrs, iconv, symtimes, prealloc, SIMD
Checksum list:
    xxh64 (xxhash) md5 md4 none
Compress list:
    zstd lz4 zlibx zlib none

rsync comes with ABSOLUTELY NO WARRANTY.  This is free software, and you
are welcome to redistribute it under certain conditions.  See the GNU
General Public Licence for details.
$ dpkg-query -W rsync
rsync   3.2.0-1

ってことで試せるようになりました.NEWSを見てみます.

BUG FIX

Avoid a hang when an overabundance of messages clogs up all the I/O buffers.

このバグ修正がちょっと気になります.fat32の制限に引っかかったときに帰ってこない問題もこれで解決してるかも?未確認.

ENHANCEMENTS

–checksum-choice=STR, –cc=STR

チェックサム形式を選べるようになったようです.現在選択できるのは xxh64/md5/md4 の3種類 or none or auto(既定値)

man(1)より
              o      auto (the default)
              o      xxh64 (aka xxhash)
              o      md5
              o      md4
              o      none

--version にも出力されます.

$ rsync --version | grep Checksum -A1
Checksum list:
    xxh64 (xxhash) md5 md4 none

configure option に --disable-xxhash がありました.

  --disable-xxhash        disable xxhash checksums

環境変数 RSYNC_CHECKSUM_LIST でも指定できます.オプション --checksum-choice がある場合はオプションのほうが優先なようです.

ちなみに --checksum-choice オプションに対応していない 3.1.3 に対して xxh64 を向けて叩いてみると以下のようなエラーになりました.(md4, md5 はok)

$ rsync --checksum-choice=xxh64 -avc ./* user@remote:/tmp/
unknown checksum name: xxh64
rsync error: requested action not supported (code 4) at checksum.c(73) [server=3.1.3]
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(235) [sender=3.2.0]

時間がどのくらい変わるかちょうど転がっていたkernel source(小さいファイルが沢山)で試してみました.はじめ普通に同期した後,キャッシュクリアして md4, md5, xxh64 で試してみました.思ったより差が出ない感じ?

md4
$ find ./linux-5.6 | wc -l
82114
$ du -ms ./linux-5.6
1310    ./linux-5.6
$ rsync --checksum-choice=auto -ac ./linux-5.6 /tmp/
$ sync ; echo 3 | sudo tee /proc/sys/vm/drop_caches ; time rsync --checksum-choice=md4 -ac ./linux-5.6 /tmp/
3

real    0m52.393s
user    0m5.051s
sys     0m12.246s
md5
$ sync ; echo 3 | sudo tee /proc/sys/vm/drop_caches ; time rsync --checksum-choice=md5 -ac ./linux-5.6 /tmp/
3

real    0m57.716s
user    0m6.976s
sys     0m13.486s
xxh64
$ sync ; echo 3 | sudo tee /proc/sys/vm/drop_caches ; time rsync --checksum-choice=xxh64 -ac ./linux-5.6 /tmp/
3

real    1m5.520s
user    0m2.507s
sys     0m13.625s

大きめのファイルでも試してみました.4GB程のisoファイル1つです.md4, md5 はあまり代わりませんが,xxh64 はかなり高速ですね.

md4
$ ls -s ./Parrot-security-4.9.1_x64.iso*
3909164 ./Parrot-security-4.9.1_x64.iso  3909164 ./Parrot-security-4.9.1_x64.iso2
$ sync ; echo 3 | sudo tee /proc/sys/vm/drop_caches ; time rsync --checksum-choice=md4 -ac ./Parrot-security-4.9.1_x64.iso ./Parrot-security-4.9.1_x
64.iso2
3

real    0m23.276s
user    0m10.601s
sys     0m4.387s
md5
$ sync ; echo 3 | sudo tee /proc/sys/vm/drop_caches ; time rsync --checksum-choice=md5 -ac ./Parrot-security-4.9.1_x64.iso ./Parrot-security-4.9.1_x64.iso2
3

real    0m28.150s
user    0m16.945s
sys     0m4.399s
xxh64
$ sync ; echo 3 | sudo tee /proc/sys/vm/drop_caches ; time rsync --checksum-choice=xxh64 -ac ./Parrot-security-4.9.1_x64.iso ./Parrot-security-4.9.1_x64.iso2
3

real    0m12.767s
user    0m1.375s
sys     0m4.060s

この辺の速度は環境により大分変わると思うので参考程度に.

–compress-choice=STR, –zc=STR

--compress オプション利用時の圧縮形式を指定できるようです.

圧縮形式はrsync 3.2.0 同士では zlibx 形式が zlib 形式よりも優先されるようです.
選択できるオプションは zstd, lz4, zlibx, zlib, none のようです.

man(1)より
              o      zstd
              o      lz4
              o      zlibx
              o      zlib
              o      none

rsync --version でも確認できます.

$ rsync --version | grep Compress -A1
Compress list:
    zstd lz4 zlibx zlib none

configure oprion に --disable-zstd, --disable-lz4 があります.

  --disable-zstd          disable zstd compression
  --disable-lz4           disable LZ4 compression

環境変数 RSYNC_COMPRESS_LIST でも指定できるようです.

未対応の 3.1.3 に対して指定すると unknown option と言われます.

$ time rsync --compress-choice=zstd --compress -a ./hoge mk@x201i.local:/tmp/
rsync: on remote machine: --compress-choice=zstd: unknown option
rsync error: syntax or usage error (code 1) at main.c(1596) [server=3.1.3]
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(235) [sender=3.2.0]

こちらも簡単にベンチを.でもWi-Fi環境だし参考程度に.

zstd
$ ssh user@remote rm -rf ~/tmp/linux-5.6; echo 3 | sudo tee /proc/sys/vm/drop_caches; time rsync --compress-choice=zstd --compress -a --rsync-path=~/src/rsync-3.2.0/rsync ~/src/linux-5.6 user@remote:~/tmp/
3

real    4m38.921s
user    0m24.463s
sys     0m7.182s
lz4
$ ssh user@remote rm -rf ~user/tmp/linux-5.6; echo 3 | sudo tee /proc/sys/vm/drop_caches; time rsync --compress-choice=lz4 --compress -a --rsync-path=~/src/rsync-3.2.0/rsync ~/src/linux-5.6 user@remote:~/tmp/
3

real    9m28.829s
user    0m4.878s
sys     0m6.177s
zlibx
$ ssh user@remote rm -rf ~user/tmp/linux-5.6; echo 3 | sudo tee /proc/sys/vm/drop_caches; time rsync --compress-choice=zlibx --compress -a --rsync-path=~/src/rsync-3.2.0/rsync ~/src/linux-5.6 user@remote:~/tmp/
3

real    5m21.702s
user    0m46.740s
sys     0m6.541s
zlib
$ ssh user@remote rm -rf ~user/tmp/linux-5.6; echo 3 | sudo tee /proc/sys/vm/drop_caches; time rsync --compress-choice=zlib --compress -a --rsync-path=~/src/rsync-3.2.0/rsync ~/src/linux-5.6 user@remote:~/tmp/
3

real    5m28.722s
user    0m45.861s
sys     0m6.381s
none
$ ssh user@remote rm -rf ~user/tmp/linux-5.6; echo 3 | sudo tee /proc/sys/vm/drop_caches; time rsync --compress-choice=none -a --rsync-path=~/src/rsync-3.2.0/rsync ~/src/linux-5.6 user@remote:~/tmp/
3

real    22m56.712s
user    0m1.848s
sys     0m7.323s

–debug=NSTR

チェックサムと圧縮の詳細を表示するオプションのようです.どのアルゴリズムを利用しているのかが確認できます.

–debug=NSTR を付けたときのの実行結果例
Client negotiated checksum: xxh64
Client compress: zstd (level 3)

–debug=OPTS, -M—​debug=OPTS

--debug=OPTS を使うとリモートのrsyncにデバッグオプションを送らなくなるようです.これによりクライアント側とサーバ側で異なるデバッグレベルを指定できるようになったそうです.
リモート側にオプションを送る場合には -M—​debug=OPTS

SIGINFO & SIGVTALRM

rsyncプロセスに SIGINFO & SIGVTALRM シグナルを送信することでステータスを表示できるようになったようです.Linuxは SIGINFO に対応していないので, SIGVTALRM を試しました.

rsyncを実行している状態で SIGVTALRM を送信
$ pkill -SIGVTALRM rsync
rsyncがステータスを表示
linux-5.6/arch/sparc/lib/lshrdi3.S
    114,384,392  81%  931.12kB/s    0:01:59 (xfr#21058, ir-chk=1030/23451)

–copy-as=USER[:GROUP]

指定ユーザ/グループ権限でファイルをコピーするようです.

コピー元に3ユーザのファイル
$ ls -Al /tmp/rsync-test/
total 0
-rw-r--r-- 1 matoken  matoken  0 Jun 25 18:50 matokenfile
-rw-r--r-- 1 root     root     0 Jun 25 18:51 root
-rw-r--r-- 1 www-data www-data 0 Jun 25 18:51 www-data
普通にコピーするとユーザが引き継がれる
$ sudo ./rsync -a /tmp/rsync-test/ /tmp/rsync-test2
$ ls -lA /tmp/rsync-test2
total 0
-rw-r--r-- 1 matoken  matoken  0 Jun 25 18:50 matokenfile
-rw-r--r-- 1 root     root     0 Jun 25 18:51 root
-rw-r--r-- 1 www-data www-data 0 Jun 25 18:51 www-data
--copy-as=matoken を指定するとすべてmatokenになる
$ sudo \rm -rf /tmp/rsync-test2
$ sudo ./rsync --copy-as=matoken -a /tmp/rsync-test/ /tmp/rsync-test2
$ ls -lA /tmp/rsync-test2
total 0
-rw-r--r-- 1 matoken matoken 0 Jun 25 18:50 matokenfile
-rw-r--r-- 1 matoken matoken 0 Jun 25 18:51 root
-rw-r--r-- 1 matoken matoken 0 Jun 25 18:51 www-data

-V

--version の短いオプションとして -V が入りました.

$ ./rsync --help|grep -- -V
--version, -V            print the version + other info and exit
$ ./rsync --help|grep \-V
grep (GNU grep) 3.4
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Mike Haertel and others; see
<https://git.sv.gnu.org/cgit/grep.git/tree/AUTHORS>.

–ipv4, -4 / –ipv6, -6

ipv4, ipv6 を指定したいときに rsh='ssh -4' とするより便利な --ipv4, -4, --ipv6, -6 オプションが入りました.

ipv4しかない環境で -6 を指定して失敗する
$ rsync -avc6 ./ user@remote:/tmp/
ssh: Could not resolve hostname remote: Name or service not known
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(235) [sender=3.2.1]

awesome wmでの壁紙変更設定を変更(crontabからDISPLAY番号取得)

awesome wm環境での壁紙自動変更にcrontab経由で feh コマンドを利用しています.

30分ごとに~/Pictures/wp/以下のファイルをダンダムに設定
*/30 * * * *    DISPLAY=:0 feh --bg-scale "$(find ~/Pictures/wp/ -type f | shuf -n 1)"

このときXのディスプレイ番号を固定で書いているのですがディスプレイ番号が変わることもあってその時エラーになってしまいます.
ウィンドウマネージャを変更したときもよくなさそう.

ということでcronからユーザのawesome wmのディスプレイ番号を探すようにしてみました.

まずは対象ユーザのawesome wmのプロセス番号を調べます.

$ pgrep -u $(id -u) awesome
2932

/proc/$PID/environ からDISPLAYを探します.

$ cat /proc/2932/environ 2> /dev/null | tr '\0' '\n' | grep ^DISPLAY=:
DISPLAY=:1

カレントユーザのawesome wmのディスプレイ番号が :1 なのが解りました :)

これを組み合わせてこのようにしてみました.これでディスプレイ番号が変わっても大丈夫で,awesome以外のウィンドウマネージャを使ったときには何もしないはず( xargs --no-run-if-empty )です.
同じユーザでawesomeを複数起動した場合は先に起動した方しか反映されないはずですが,あまりそういったことはしないと思うので大丈夫かなと.

*/30 * * * *    cat /proc/$(pgrep -u $(id -u) awesome)/environ 2> /dev/null | tr '\0' '\n' | grep ^DISPLAY=: | xargs --no-run-if-empty -I{} sh -c '{} feh --bg-scale "$(find ~/Pictures/wp/ -type f | shuf -n 1)"'

2020-07-17 ADD
fehに -z, --randomize と言うオプションがありました.これを使うとコマンドが2つ減って少しわかりやすく……あまり変わらないか.

*/30 * * * *    cat /proc/$(pgrep -u $(id -u) awesome)/environ 2> /dev/null | tr '\0' '\n' | grep ^DISPLAY=: | xargs --no-run-if-empty -I{} {} feh --bg-scale -z ~/Pictures/wp/
環境
$ dpkg-query -W awesome feh procps findutils grep
awesome 4.3-4
feh     3.4.1-1
findutils       4.7.0-1
grep    3.4-1
procps  2:3.3.16-5
$ lsb_release -dr
Description:    Debian GNU/Linux bullseye/sid
Release:        unstable
$ uname -m
x86_64

snapでNextcloudを導入して手軽にGoogleDocぽく使う(snap版Nextcloud + OnlyOffice)

Nextcloud導入が面倒?snapを使うとこれだけでGoogleDocみたいなことができます(Debian sid amd64/Ubuntu 20.04 LTSで確認済み).

$ sudo apt update && sudo apt upgrade
$ sudo apt install snapd
$ sudo snap install nextcloud
$ sudo /snap/bin/nextcloud.occ app:install documentserver_community
$ sudo /snap/bin/nextcloud.occ app:install onlyoffice

snap nextcloud 20200610 00:06:05 415116

簡単に説明していきます.

OSの状態を最新にしておきます.
$ sudo apt update && sudo apt upgrade
snapを使うためにsnapdを導入します(最近のUbuntuだと標準で入ってると思います).
$ sudo apt install snapd
snapでNextcloudを検索してみます.
$ snap find nextcloud
Name                       Version                    Publisher         Notes  Summary
nextcloud                  18.0.4snap3                nextcloud✓        -      Nextcloud Server - A safe home for all your data
spreedme                   0.29.5snap1                nextcloud✓        -      Spreed.ME audio/video calls and conferences feature for the Nextcloud Snap
onlyoffice-desktopeditors  5.5.1                      onlyoffice✓       -      A comprehensive office suite for editing documents, spreadsheets and presentations
qownnotes                  20.6.2                     pbek              -      Plain-text file markdown note taking with Nextcloud / ownCloud integration
nextcloud-port8080         1.01                       arcticslyfox      -      Nextcloud Server
nextcloud-snap-abacao      11.0.3snap4                abacao            -      Nextcloud Server
nextcloud-nextant          11.0.0snap3                rmescandon        -      Nextcloud Server + search support
nextcloud-abacao           11.0.3snap4                abacao            -      Nextcloud Server
cashbox-nextcloud          11.0.2snap2                cashbox           -      Nextcloud Server for www.cashBOX.plus
nextcloudsnap              12.0.4snap1                oscarbrolin       -      Nextcloud Server - A safe home for all your data
ghostcloud                 0.9.5                      beidl             -      A modern cross-platform client for Nextcloud, ownCloud, WebDav.
htxucloud                  12.0.3snap7                htxu              -      Nextcloud Server
carnet                     0.22.1                     alexandre-roux-m  -      Powerful note taking app with sync, online editor and android app
opentodolist               3.23.0                     mhoeher           -      Todo list and note taking application
solr                       0.1                        rmescandon        -      Starts up solr as forking daemon
mdns-hostname              0.0.1                      welike            -      mDNS mini-daemon to published hostname.local
nextcloud-stondino         15.0.10snap3+git1.ff25cb9  zmusselman        -      Nextcloud Server - A safe home for all your data
vmcloud-nextcloud          1.0.0                      victoriususm      -      Nextcloud 16.0.3 Optimized-Boosted
feedreader                 0+git.9ac478f7             ken-vandine       -      RSS client for various webservices
test003-nc                 13.0.4.snap1               reinism           -      Nextcloud Server - A safe home for all your data
$ snap info nextcloud
name:      nextcloud
summary:   Nextcloud Server - A safe home for all your data
publisher: Nextcloud*
store-url: https://snapcraft.io/nextcloud
contact:   https://github.com/nextcloud/nextcloud-snap
license:   unset
description: |
  Where are your photos and documents? With Nextcloud you pick a server of
  your choice, at home, in a data center or at a provider. And that is where
  your files will be. Nextcloud runs on that server, protecting your data and
  giving you access from your desktop or mobile devices. Through Nextcloud
  you also access, sync and share your existing data on that FTP drive at
  school, a Dropbox or a NAS you have at home.
commands:
  - nextcloud.disable-https
  - nextcloud.enable-https
  - nextcloud.export
  - nextcloud.import
  - nextcloud.manual-install
  - nextcloud.mysql-client
  - nextcloud.mysqldump
  - nextcloud.occ
services:
  nextcloud.apache:          simple, enabled, active
  nextcloud.mdns-publisher:  simple, enabled, active
  nextcloud.mysql:           simple, enabled, active
  nextcloud.nextcloud-cron:  simple, enabled, active
  nextcloud.nextcloud-fixer: simple, enabled, inactive
  nextcloud.php-fpm:         simple, enabled, active
  nextcloud.redis-server:    simple, enabled, active
  nextcloud.renew-certs:     simple, enabled, active
snap-id:      njObIbGQEaVx1H4nyWxchk1i8opy4h54
tracking:     latest/stable
refresh-date: yesterday at 21:53 JST
channels:
  latest/stable:    18.0.4snap4               2020-06-08 (21413) 264MB -
  latest/candidate: ^
  latest/beta:      18.0.4snap4+git5.31f0acd  2020-06-09 (21469) 264MB -
  latest/edge:      master-2020-06-10         2020-06-10 (21487) 267MB -
  18/stable:        18.0.4snap4               2020-06-08 (21413) 264MB -
  18/candidate:     ^
  18/beta:          ^
  18/edge:          18-2020-06-10             2020-06-10 (21482) 265MB -
  17/stable:        17.0.6snap1               2020-05-03 (20616) 229MB -
  17/candidate:     ^
  17/beta:          17.0.6snap1+git10.8f765f8 2020-06-09 (21474) 249MB -
  17/edge:          17-2020-06-10             2020-06-10 (21483) 250MB -
  16/stable:        16.0.11snap1              2020-06-08 (21459) 225MB -
  16/candidate:     ^
  16/beta:          ^
  16/edge:          ^
  15/stable:        15.0.14snap1              2020-01-20 (18374) 216MB -
  15/candidate:     ^
  15/beta:          ^
  15/edge:          ^
  14/stable:        14.0.10snap1              2019-05-04 (13208) 202MB -
  14/candidate:     ^
  14/beta:          ^
  14/edge:          ^
  13/stable:        13.0.12snap1              2019-05-03 (13155) 193MB -
  13/candidate:     ^
  13/beta:          ^
  13/edge:          ^
  12/stable:        12.0.13snap1              2019-01-07 (10632) 206MB -
  12/candidate:     ^
  12/beta:          ^
  12/edge:          ^
  11/stable:        11.0.8snap1               2018-05-10  (6942) 202MB -
  11/candidate:     ^
  11/beta:          ^
  11/edge:          ^

いくつかでてきますが,Publisherが nextcloud になっている公式のstableを使います.ちなみにこのコマンドを叩いた時点で19.0.0や18.0.5が出ていてこの記事執筆時点で18.0.6が出ています.ちょっと反映が遅いみたいですね.

snap版Nextcloudを導入
$ sudo snap install nextcloud

しばらく時間がかかりますが,これでNextcloudと関連のApache httpd/PHP/MySQL等が設定済みの状態で導入されます.

$ ps aux | grep -i nextcloud
root     17628  0.0  0.0   1872   196 ?        Ss   00:10   0:00 /bin/sh /snap/nextcloud/21169/bin/delay-on-failure mdns-publisher nextcloud
root     17615  0.0  0.1   1872  1168 ?        Ss   00:10   0:00 /bin/sh /snap/nextcloud/21169/bin/nextcloud-cron
root     17657  0.0  0.1   1872  1200 ?        Ss   00:10   0:00 /bin/sh /snap/nextcloud/21169/bin/renew-certs
root     17681  0.0  0.1   1872  1272 ?        Ss   00:10   0:00 /bin/sh /snap/nextcloud/21169/bin/start-php-fpm
root     17712  0.0  0.1   1872  1216 ?        Ss   00:10   0:00 /bin/sh /snap/nextcloud/21169/bin/start-redis-server
root     17765  0.0  0.6 258120  6008 ?        Sl   00:10   0:00 mdns-publisher nextcloud
root     17987  0.0  0.1   1872  1200 ?        Ss   00:10   0:00 /bin/sh /snap/nextcloud/21169/bin/run-httpd -k start -DFOREGROUND
root     18069  0.1  0.1   1872  1168 ?        Ss   00:10   0:01 /bin/sh /snap/nextcloud/21169/bin/start_mysql
root     18111  0.0  0.1   1872  1100 ?        S    00:10   0:00 /bin/sh /snap/nextcloud/21169/bin/mysqld_safe --datadir=/var/snap/nextcloud/21169/mysql --pid-file=/tmp/pids/mys
ql.pid --lc-messages-dir=/snap/nextcloud/21169/share --socket=/tmp/sockets/mysql.sock
root     18128  0.9 22.0 1815000 210060 ?      Sl   00:10   0:08 /snap/nextcloud/21169/bin/mysqld --basedir=/snap/nextcloud/21169 --datadir=/var/snap/nextcloud/21169/mysql --plu
gin-dir=/snap/nextcloud/21169/lib/plugin --lc-messages-dir=/snap/nextcloud/21169/share --log-error=error.log --pid-file=/tmp/pids/mysql.pid --socket=/tmp/sockets/mysql.sock
root     18196  0.0  2.1 200580 21712 ?        Ss   00:10   0:00 php-fpm: master process (/snap/nextcloud/21169/config/php/php-fpm.conf)
root     18980  0.0  0.1   1872  1276 ?        S    00:10   0:00 /bin/sh /snap/nextcloud/21169/bin/httpd-wrapper -k start -DFOREGROUND
root     19017  0.0  0.0   6168  0280 ?        S    00:10   0:00 httpd -d /snap/nextcloud/21169 -k start -DFOREGROUND
root     19018  0.0  0.1 1211772 1612 ?        Sl   00:10   0:00 httpd -d /snap/nextcloud/21169 -k start -DFOREGROUND
root     19019  0.0  0.1 880108  1668 ?        Sl   00:10   0:00 httpd -d /snap/nextcloud/21169 -k start -DFOREGROUND
root     19020  0.0  0.1 1080512 1656 ?        Sl   00:10   0:00 httpd -d /snap/nextcloud/21169 -k start -DFOREGROUND
root     19221  0.0  0.0 1716012 0292 ?        Sl   00:10   0:00 httpd -d /snap/nextcloud/21169 -k start -DFOREGROUND

これでもうデーモンも起動しているので対象マシンのホスト名やipアドレスをウェブブラウザに入力して任意の管理者ユーザのユーザ名とパスワードを入力して登録します.同じネットワークだと誰でも繋いで設定できてしまうので注意しましょう.

管理者ユーザ登録画面

snap nextcloud 20200609 22:06:09 329531

「推奨アプリをインストール」にチェックを入れておくと便利な推奨アプリが導入されます.時間がかかるので後でもいいかもしれません.

これでとりあえずNextcloudが利用できるようになりました.実はここまでは snapパッケージが amd64以外にも arm64. armhf, i386, ppc64el に対応しているので armhf/arm64 な Raspberry Pi などでも動作します.

続いて OnlyOffice, community edition の server版を導入します.

Nextcloudのウェブからも導入できるのですが,300MB程とサイズが大きく回線によってはタイムアウトしてしまいます.

snap nextcloud 20200606 19:06:50 477356

その場合は occ コマンドで導入します.(snapなので nextcloud.occ コマンドを使います)

$ sudo /snap/bin/nextcloud.occ app:install documentserver_community

これでも失敗することがあります.その場合は手動でGitHub からアーカイブを入手して手動で展開して有効化します.(この方法だとamd64以外でも導入はできちゃいますが動かないので注意)

$ COUNT=1; while :;do wget https://github.com/nextcloud/documentserver_community/releases/download/v0.1.6/documentserver_community.tar.gz && break; c=$(( $c + 1 )) ;sleep 10; done;echo $COUNT
$ sudo tar xvf ./documentserver_community.tar.gz -C /var/snap/nextcloud/current/nextcloud/extra-apps/
$ sudo chown -R root.root /var/snap/nextcloud/current/nextcloud/extra-apps/documentserver_community
$ sudo /snap/bin/nextcloud.occ app:enable documentserver_community

CollaboraはAppImageを使っていたのでファイル数は少なかったですがこちらは普通にディレクトリに展開されるようでたくさんあります.

$ sudo find /var/snap/nextcloud/current/nextcloud/extra-apps/documentserver_community | wc -l
12935

続いてOnlyOfficeアプリも導入します.

これはOnlyOffice Serverに繋いでやり取りするものです.Nextcloud のアプリ画面若しくは以下のコマンドで導入します.

$ sudo /snap/bin/nextcloud.occ app:install onlyoffice

これでNextcloudに戻って対応ドキュメントを開いたり新規作成するとOnlyOfficeが起動して編集できるはずです :)

snap nextcloud 20200609 23:06:12 405447
snap nextcloud 20200610 00:06:05 415116

アプリが導入されているけどうまく行かない場合はOnlyOfficeアプリを導入し直すとうまく行くかもしれません.(OnlyOfficeアプリがServerより先に導入されるとうまく行かない)

$ sudo /snap/bin/nextcloud.occ app:remove onlyoffice
$ sudo /snap/bin/nextcloud.occ app:install onlyoffice

とりあえずこれでお試しは出来る感じです.実際に運用するにはhttps化したりバックアップを定期的に取るようにしたりなど設定したほうがいいですがパスやコマンド以外は通常のNextcloudと同じだと思います.
主なパスやコマンドはこうなっています.

  • 設定ファイル /var/snap/nextcloud/current/nextcloud/config/config.php
  • Nextcloudデータ,ログ /var/snap/nextcloud/common/
  • 関連アプリ格納 /var/snap/nextcloud/current/
  • occ /snap/bin/nextcloud.occ
  • mysql-client /snap/bin/mysql-client
  • mysqldump /snap/bin/nextcloud.mysqldump

dbのアカウント情報は設定ファイルに載っています.

$ sudo grep db /var/snap/nextcloud/current/nextcloud/config/config.php
  'dbtype' => 'mysql',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost:/tmp/sockets/mysql.sock',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'nextcloud',
  'dbpassword' => 'wdwYevflNhziZDUxxG2OXJs6el4zThtkmX20Bijih7Zh_4XU58OkZs3TAt7TCJjt',

設定ファイルを編集してデーモンを再起動したい場合はこんな感じで再起動できます.

$ sudo snap restart nextcloud

てことでsnap版Nextcloudはお試しにはおすすめです.
OnlyOfficeは今のところamd64環境しか提供されていませんがRaspberry Pi などでも動くようにしたいと言っているのでこれも期待です.

Nextcloud 19 だと先日紹介したCollaboraも同様にWebから導入できるのでおすすめです.

Lutrisを使ってLinuxでもEpic Gamesで遊ぶ

Epic Games というゲームプラットホームがあります.定期的にゲームを無料配布してくれるのでたまに貰っています.

しかしこのプラットホームは Stream や itch などと違い PC/Mac のみの対応で Linux には対応していません.

Epic Games Storeはどのプラットフォームに対応していますか?
Epic Games Storeは、現在PCとMacに対応しています。各タイトルのプラットフォームとの互換性については、製品ページの「ゲームについて」で確認することができます。

無料で貰っても遊ばないと意味がないです.
そういえば Lutris 経由で動かないかな?と思いつきました.Lutris はLinux 環境で各種プラットホームのゲーム環境を管理できて,複数のWine 環境を簡単に導入設定できたりして便利です.ここで貰ったゲームが出てきたらお手軽に遊べそうです.

Lutris についての詳細は以下のスライドもどうぞ.

ゲームの前に Lutris で Epic Games で検索すると Epic Games が出てきました.「Install」ボタンを押してウィザードに従うだけで簡単に導入できました.

lutris epic 20200606 03:06:59 18609

後は Epic Games でゲームをインストールしてみると起動しました :)

lutris epic 20200606 08:06:45 150593

lutris epic 20200606 08:06:24 148344
lutris epic 20200606 08:06:15 147780

思ったより手軽に遊べそうです.
しかし暖かくなって排熱が追いつかない感じでちょっと辛い今日この頃です.

//

環境
$ apt show lutris
Package: lutris
Version: 0.5.6
Priority: optional
Section: games
Maintainer: Mathieu Comandon <strider@strycore.com>
Installed-Size: 4,035 kB
Depends: python3-evdev, python3-gi, python3-requests, python3-yaml, python3:any, python3-pil, python3-setproctitle, python3-distro, gir1.2-gtk-3.0, gir1.2-gnomedesktop-3.0, gir1
.2-webkit2-4.0, gir1.2-notify-0.7, psmisc, cabextract, unzip, p7zip, curl, fluid-soundfont-gs, x11-xserver-utils, mesa-utils
Recommends: gvfs-backends, libwine-development, winetricks, libc6-i386, lib32gcc1
Suggests: gamemode
Homepage: https://lutris.net
Download-Size: 1,690 kB
APT-Manual-Installed: yes
APT-Sources: http://download.opensuse.org/repositories/home:/strycore/Debian_Unstable  Packages
Description: open source gaming platform
 Lutris goal is to make gaming on Linux as easy as possible by taking care of
 installing and setting up the game for the user. The only thing you have to do
 is play the game. It aims to support every game that is playable on Linux.

$ lsb_release -dr
Description:    Debian GNU/Linux bullseye/sid
Release:        unstable
$ uname -m
x86_64

Nextcloud 19からのNextcloudアプリ化したCollabora Online を試す

Nextcloud 19がリリースされました.

今回の新機能にCollabora Online がNextcloud Hub に含まれるようになり,簡単にすべてのユーザが利用できるようになったそうです.

Easy to install for every user
Collabora Online will be shipped out of the box with the new Nextcloud 19 Hub. A special community server has been developed, that can easily be installed with a single click by every user, and so avoiding web server and docker containers installation and configuration.

少し前にもデモサーバーを用意してくれてお手軽に試せるようにしてくれていましたが今回は自分の環境でとても簡単に動くようになったようです.

ということでNextcloud 19 にアップデートして試してみました.

Nextcloud 19環境管理者権限で https://$NEXTCLOUDURL/index.php/settings/admin/richdocuments にアクセスして設定を見てみます.

NC19 CODE 01

Use the built-in CODE という設定が増えています.がグレーアウトしています.

Use the built-in CODE – Collabora Online Development Edition
Easy to install, for personal use or for small teams. A bit slower than a standalone server and without the advanced scalability features.

てことで,以下のNextcloud アプリを導入します.

NC19 CODE 02

導入は本当に簡単で「ダウンロードして有効にする」を押すだけです.

コマンドラインではこんな感じで導入できます.

$ sudo -u www-data php ./occ app:install richdocumentscode
richdocumentscode installed
richdocumentscode enabled

導入されると Built-in CODE が選べるようになっているので選択します.後はファイルでオフィス文章を開いたり新規作成すれば自動的に起動して利用できます.

NC19 CODE 03

初回はちょっと時間がかかります.これはCODEが裏で起動する時間がかかるからみたいです.
後は普通に利用できます :)
Demoサーバと違って制限もないので普通に使えます.NextcloudでURL共有をするとGoogleDoc のようにみんなで同時にドキュメントを編集したりも出来ます.(Nextcloudの指定ユーザだけ編集可能とかURLを知ってる人は誰でも編集できるとかも出来ます.)

少し使っていて気になったのは以下のメッセージがたまに出ます.ディスク空き容量が 4GBで出るときと出ないときがありぎりぎり動いているのかなと思いましたが,空き容量を6GBに空けても出たり出なかったりします.もしかしたらバグかも?

NC19 CODE 04

そしてこちらの画面はセッションが数個(2個のつもり)でも出ます.セッションのカウントがおかしいのか他のバグなのか?

NC19 CODE 05

今回のCollabora Online はどんな仕組みなのかなとディレクトリを覗くと,Collabora Online がAppImage 化されてごろっと置かれているようです.

$ ls -l apps/richdocumentscode/collabora/
total 339320
-rwxr--r-- 1 www-data www-data 347455528 Jun  5 01:27 Collabora_Online.AppImage

これが文章を閉じてもずっと起動しているようです.RAMが少ないのでちょっと辛い.

$ ps aux | pee "head -1" "grep Collabora_OnlineAppImage"
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
mk       29361  0.0  0.0   2272   752 pts/2    S+   23:04   0:00 pee head -1 grep Collabora_OnlineAppImage

このマシンはリモートのサーバで日本語フォントがほとんど入っていないのでCollabora Online でもフォントがあまり選べません.システムにフォントを導入します.今回はNoto CJK を導入してみました.

$ sudo apt install fonts-noto-cjk

導入してもそのままではCollabora Online には反映されませんでした.文章を閉じて,AppImage のプロセスをkill して再度文章を開くとまた AppImage が起動して反映されました.

ということでとても簡単にWebだけでNextcloud からCollabora Online が導入できるようになりました.
とても便利なのでおすすめです.

環境
$ sudo -u www-data php ./occ app:list | grep richdocuments
  - richdocuments: 3.7.0
  - richdocumentscode: 4.2.403
$ sudo -u www-data php ./occ status
  - installed: true
  - version: 19.0.0.12
  - versionstring: 19.0.0
  - edition:
$ dpkg-query -W php apache2
apache2 2.4.38-3+deb10u3
php     2:7.3+69
$ lsb_release -dr
Description:    Debian GNU/Linux 10 (buster)
Release:        10
$ uname -m
x86_64

Nextcloud 18から19にbeta channel でアップグレード

Nextcloud 19が06/03にリリースされました.

未だ18からのアップデートは来ていませんが一時的に beta channel にして 19 にアップグレードしてみました.

$ sudo -u www-data php ./updater/updater.phar
Nextcloud Updater - version: v16.0.3-3-ga0c2b25 dirty

Current version is 18.0.5.

No update available.

Nothing to do.

先ずはバックアップをとっておきます.Nextcloudのディレクトリ以下とデータベースをバックアップしておけば最悪データが壊れたり消えてしまって復元できます.データが多いと時間がかかるので日頃取得して差分バックアップするようにしておくといいです.

次にscript コマンド等でログを取っておきます.リモートでssh経由の場合などはGNU screen やtmux などで切断されても復帰出来るようにしておきます.

準備が出来たら先ずは Nextcloud を18 の最新にしておきます.

$ cd $(NEXTCLOUDPATH}
$ sudo -u www-data php ./occ app:update --all
$ sudo -u www-data php ./updater/updater.phar
$ sudo -u www-data php ./occ app:update --all

Nextcloud の update channel を stable から beta にします.

$ sudo -u www-data php ./occ config:system:set updater.release.channel --value 'beta'
System config value updater.release.channel set to string beta

channel はすぐには反映されません.今回は20分ほどで反映されました数時間掛かることもあるよう.
19 が降りてきたら後は普通にアップグレードします.

$ sudo -u www-data php ./updater/updater.phar
Nextcloud Updater - version: v16.0.3-3-ga0c2b25 dirty

Current version is 18.0.5.

Update to Nextcloud 19.0.0 available. (channel: "beta")
Following file will be downloaded automatically: https://download.nextcloud.com/server/releases/nextcloud-19.0.0.zip
Open changelog ↗

Steps that will be executed:
[ ] Check for expected files
[ ] Check for write permissions
[ ] Create backup
[ ] Downloading
[ ] Verify integrity
[ ] Extracting
[ ] Enable maintenance mode
[ ] Replace entry points
[ ] Delete old files
[ ] Move new files in place
[ ] Done

Start update? [y/N] y
Info: Pressing Ctrl-C will finish the currently running step and then stops the updater.

[✔] Check for expected files
[✔] Check for write permissions
[✔] Create backup
[✔] Downloading
[✔] Verify integrity
[✔] Extracting
[✔] Enable maintenance mode
[✔] Replace entry points
[✔] Delete old files
[✔] Move new files in place
[✔] Done

Update of code successful.

Should the "occ upgrade" command be executed? [Y/n]
  :
  :
Keep maintenance mode active? [y/N]
Maintenance mode disabled

Maintenance mode is disabled

Nextcloud 19 になりました :)

Nextcloud19 00

$ sudo -u www-data php /var/www/files.matoken.org/updater/updater.phar
Nextcloud Updater - version: v16.0.3-3-ga0c2b25 dirty

Current version is 19.0.0.

No update available.

Nothing to do.

channel を stable に戻しておきます.一旦19に上げていれば18に戻りません.

$ sudo -u www-data php /var/www/files.matoken.org/occ config:system:set updater.release.channel --value 'stable'
System config value updater.release.channel set to string stable
$ sudo -u www-data php /var/www/files.matoken.org/updater/updater.phar
Nextcloud Updater - version: v16.0.3-3-ga0c2b25 dirty

Current version is 19.0.0.

No update available.

Nothing to do.

https://$NEXTCLOUDURL/index.php/settings/admin/overview の「セキュリティ&セットアップ警告」を確認するといくつかメッセージが出ているので修正します.

Nextcloud19 01

セキュリティ&セットアップ警告
サーバーのセキュリティとパフォーマンスにとって重要なことは、すべてが正確に設定されていることです。あなたの助けとなるよう、Nextcloudでは一部の自動チェックを行っています。詳細な情報は、リンク先のドキュメントを参照してください。

セットアップに関して警告がいくつかあります。
データベースにいくつかのインデックスがありません。 大きなテーブルにインデックスを追加すると、自動的に追加されないまでに時間がかかる可能性があるためです。 “occ db:add-missing-indices”を実行することによって、インスタンスが実行し続けている間にそれらの欠けているインデックスを手動で追加することができます。 インデックスが追加されると、それらのテーブルへのクエリは通常はるかに速くなります。
テーブル “oc_properties”のインデックス “properties_path_index”が見つかりません。
データベースにはオプションのカラムがいくつかありません。大きなテーブルにカラムを追加するには時間がかかるため、オプションのカラムは自動的に追加されませんでした。”occ db:add-missing-columns”を実行することで、不足しているカラムはインスタンスの実行中に手動で追加することができます。カラムが追加されると、応答性や使い勝手が改善される可能性があります。
テーブル “oc_comments” にオプションのカラム “reference_id” が存在しません。
このインスタンスには推奨されるPHPモジュールがいくつかありません。 パフォーマンスの向上と互換性の向上のために、それらをインストールすることを強くお勧めします。
bcmath
gmp
インストールガイド ↗を再確認して、 ログ にあるすべてのエラーや警告を確認してください。

Nextcloudのセキュリティは、セキュリティスキャン ↗でチェックしてください。

と言っても基本的にメッセージに従うだけです.

データベースにいくつかのインデックスがありません。
$ sudo -u www-data php ./occ db:add-missing-indices
Check indices of the share table.
Check indices of the filecache table.
Check indices of the twofactor_providers table.
Check indices of the login_flow_v2 table.
Check indices of the whats_new table.
Check indices of the cards table.
Check indices of the cards_properties table.
Check indices of the calendarobjects_props table.
Check indices of the schedulingobjects table.
Check indices of the oc_properties table.
Adding properties_path_index index to the oc_properties table, this can take some time...
oc_properties table updated successfully.
データベースにはオプションのカラムがいくつかありません。
$ sudo -u www-data php ./occ db:add-missing-columns
Check columns of the comments table.
Adding additional reference_id column to the comments table, this can take some time...
Comments table updated successfully.
このインスタンスには推奨されるPHPモジュールがいくつかありません。

これは環境によって少し代わります.対応パッケージを導入してhttpdを再起動して反映します.以下はDebian Buster amd64 でのパッケージ名.そしてApache httpd でホストしている場合の例です.

$ sudo apt install php7.3-bcmath php7.3-gmp
$ sudo service apache2 reload

これで「セキュリティ&セットアップ警告」ページを再読込すると,「すべてのチェックに合格しました。」となりました :)

Nextcloud19 02

古いバックアップの削除

これは必須ではないのですが,この環境はディスクの空き領域が少ないのでリモートにバックアップした上で最新以外のバックアップは削除しています.以下の updater-ocws62au2wl3 部分は環境によって変わると思います.

$ rm -rf ./data/updater-ocws62au2wl3/backups/nextcloud-18.0.4.2
環境
$ dpkg-query -W php7.3 php7.3-bcmath php7.3-gmp apache2
apache2 2.4.38-3+deb10u3
php7.3  7.3.14-1~deb10u1
php7.3-bcmath   7.3.14-1~deb10u1
php7.3-gmp      7.3.14-1~deb10u1
$ lsb_release -dr
Description:    Debian GNU/Linux 10 (buster)
Release:        10
$ uname -m
x86_64