Etckeeper
Etckeeper は /etc をバージョン管理します。
インストール
Etckeeper は公式リポジトリの etckeeper パッケージでインストールできます。
設定
メインの設定ファイルは /etc/etckeeper/etckeeper.conf です。このファイルで使用する VCS などの設定ができます。
お好きな VCS (デフォルトは git) を設定したら、次を実行することで /etc リポジトリを初期化できます:
# etckeeper init
使用方法
Etckeeper は etckeeper.conf で LOWLEVEL_PACKAGE_MANAGER として pacman の使用をサポートしています。pacman にはフック機能が存在しないため HIGHLEVEL_PACKAGER_MANAGER として pacman を使うことは不可能です。そのため、手動で変更をコミットするか、以下のどれかの方法を使用する必要があります。
systemd
パッケージにはサービスとタイマーユニットが含まれています。etckeeper.timer を有効化してください。
タイマーの詳細は systemd/タイマーを、付属のユニットを編集する場合は systemd#ユニットファイルの編集を見て下さい。
Cron
There is a cron script in the source distribution at debian/cron.daily.
You can use this script to automatically commit changes on a schedule.
To make it run daily, for example, make sure you have cron installed and enabled,
then simply copy the script from the srcdir where you built etckeeper to /etc/cron.daily
and make sure it's executable (e.g. chmod +x /path/to/script).
ラッパースクリプト
In order to emulate the auto-commit functionality that etckeeper has on other systems,
you could place a script such as the one below somewhere in your PATH, make it executable,
and use it instead of pacman -Syu to update your system.
#!/bin/bash etckeeper pre-install pacman -Syu etckeeper post-install
Alternatively you can add a quick alias to ~/.bashrc:
alias pkg-update='sudo etckeeper pre-install && sudo pacman -Syu && sudo etckeeper post-install'
or a function where it is possible to specify the arguments for pacman or pacman wrapper:
Pacman () { sudo etckeeper pre-install && sudo pacman "$@" && sudo etckeeper post-install; }
To use the function, just run pacman as usual with flags as needed, but with a capital "P". For example:
Pacman -Syu Pacman -R foo
/usr/bin/pacman. One of the etckeeper pre-install hooks calls pacman without specifying its path, so your script will be invoked recursively without end.Incron
As an alternative to the above, you could set up incron to automatically commit changes using etckeeper whenever a file in /etc is modified.
リモートリポジトリに自動的にプッシュ
/etc/.git のローカルバックアップを作ることを第一歩として、etckeeper ではさらにコミットするたびに Github などのリモートリポジトリに変更を自動的にプッシュすることができます。実行可能ファイル /etc/etckeeper/commit.d/40github-push を作成:
#!/bin/sh set -e if [ "$VCS" = git ] && [ -d .git ]; then cd /etc/ git push origin master fi
etc/.git に移動してリモートの Github リポジトリを追加:
# git remote add origin https://github.com/user/repo.git
これで上記のラッパースクリプトやエイリアスを実行するたびに、自動的に Github リポジトリに変更がコミットされるようになります。