2022年5月14日土曜日

gitのリポジトリからファイルを削除

% git clone [リポジトリ]
% git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch -r [対象ディレクトリ]' -- --all
% git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d

ディレクトリを削除したいので、「-r [対象ディレクトリ]」で実行した。うまく言った様子。ただ、「git push --all --force origin」でリポジトリに反映させようとしたが、remote(origin)がnon-bareリポジトリだったので、うまくいかず。「.git」ディレクトリ事置き換えてしまいました。(non-bareは関係ないかもしれないけど。。。。。)

(参考)
  • https://hatsune.hatenablog.jp/entry/2013/04/20/112606
  • https://qiita.com/Spring_MT/items/f60c391b5dbf569a1d12
  • https://zenn.dev/flyingbarbarian/articles/aaf59c07b71a34
あと、このコマンドも便利であった
git log --all --name-status --pretty=short --graph

2022年5月8日日曜日

dockerのmailman3でメールのアーカイブができない

GWを使って、mailman3を構築している。下記のサイト(※)を見つつ進めたところ、メールのアーカイブができない事象に遭遇。

※ mailman-coreコンテナのmailman.logがこんな感じ。
tail -f core/var/logs/mailman.log
May 07 16:17:59 2022 (27) Exception in the HyperKitty archiver: <html><title>Auth required</title><body>
                    <h1>Authorization Required</h1><p>The archiver key is now
                     required to be sent over the Authorization HTTP header.
                     You need to upgrade the mailman-hyperkitty package to
                     1.2.0 or newer.
                    </p></body></html>
May 07 16:17:59 2022 (27) Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/mailman_hyperkitty/__init__.py", line 154, in _archive_message
    return url
  File "/usr/lib/python3.8/site-packages/mailman_hyperkitty/__init__.py", line 210, in _send_message
    except ValueError as e:

メッセージのとおり、mailman-hyperkittyモジュールを1.2.0以上にする必要があるようす。githubで、maxking/docker-mailman/Dockerfileを見たら所、4/14にmailman_hyperkittyが1.2.0に変更されているが、コンテナイメージが更新されていない。

対処として、コンテナに入ってmailman-hyperkittyをアップデート(pip install -U mailman-hyperkitty)して、コンテナを再起動(docker container restart mailman-core)したら、無事にアーカイブできるようになった。さらに、過去の投稿も登録された。

  • コンテナイメージをアップデートしてくれないかなぁ…
  • pipを使ったら、pipのバージョンがふるいって言われるなぁ…
  • コンテナイメージとしてrollingを使うのが正しいのかぁ…
(※)サイト

https://github.com/maxking/docker-mailman

https://rohhie.net/ubuntu20-04-building-a-multi-domain-mailing-list-with-mailman3-first-half/

2022年5月5日木曜日

tcpdump で syn/fin/rst をキャプチャする

tcpdump -n \(tcp[tcpflags] \& \( tcp-syn\|tcp-fin\|tcp-rst \) != 0 \)

※ (と&と|はシェルに解釈されないようにエスケープ

tcp-syn|tcp-fin|tcp-rst の論理和(であってる?)と、tcp[tcpflags]で論理積をとって、0でなければどれかのフラグが立っているといる。

(参考)

https://eijiyoshida.hatenablog.jp/entry/20100805/1280995787