LoginSignup
1
1

More than 5 years have passed since last update.

EdgeRouter X の設定をgitで管理する

Posted at

背景

せっかく、設定がテキストファイルで出力できるなら、gitで管理して自由自在にバージョンを行き来したい!
ということで、EdgeOSにgitを入れてGitHubのプライベートリポジトリにpushする設定を行った。

EdgeOSにDebianリポジトリを入れる

EdgeOSにはGitが入っておらず、公式リポジトリにもないため、単純にapt-getしても入らない。
そのため、ここを参考にDebianのリポジトリを追加する。
ここで注意しないといけないのは、Debianリポジトリを追加した状態で"upgrade"すると、EdgeOSまでDebianでアップグレードされてしまい上書きされてしまいます。

Gitを入れる

sudo apt-get install git-core

GitHubの準備

GitHubでリポジトリを作成しておき、クローンする。
今回はプライベートリポジトリの節約のため、ルータの設定のみを置くrouterブランチを作成して、それをクローンした。

git clone -b router git@github.com:[repositories].git

Commitする

方針は単純で、設定ファイルをクローンしたリポジトリにコピーしてきてCommitする。

cd ~/git
cp /config/config.boot router.config
git add router.config
git commit -m "Commit"
git push

参考にさせていただいたページでは、Commitメッセージに日時を入れて自動実行を想定しているが、ここでは任意のタイミングで任意のコメントをつけてCommitしてpushするスクリプトgit.shを設定した。

#!/bin/vbash
source /opt/vyatta/etc/functions/script-template

#check argument
if [ $# -ne 1 ]; then
  echo "Error: Invalid argument passed."
  exit 1
fi

cd ~/git
cp /config/config.boot router.config
git add router.config
git commit -m "$1"
git push
# chmod +x git.sh
# ./git.sh "test commit"
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1