LoginSignup
6
6

More than 5 years have passed since last update.

Mac OS Xでgollumを導入してgithubにpushするようにする

Last updated at Posted at 2013-06-03

gollumのインストール

gem install gollum

レポジトリの用意

普通のgitのレポジトリを作るように、gollum用のレポジトリをつくる

git init my_wiki

起動時にgollumが立ち上がるようにする

正確にはユーザがログインした時にgollumが立ち上がるようにする。

まずスクリプトの用意

start.sh
#!/bin/zsh

# 適当に設定を読み込んでおいたりする。
source /Users/user-name/.rvm/scripts/rvm
source /Users/user-name/.zshrc

rvm use 1.9.2
gollum --mathjax --no-live-preview

launchctlを使ってログイン時に立ち上がるようにする

~/Library/LaunchAgents/com.github.gollum-startup.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>Disabled</key>
        <true/>
        <key>Label</key>
        <string>com.github.gollum-startup</string>
        <key>ProgramArguments</key>
        <array>
                <string>/Users/user-name/path/to/start/sh/start.sh</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
        <key>WorkingDirectory</key>
        <string>/Users/user-name/path/to/wiki/repository</string>
</dict>
</plist>

launchctlにloadしておく

launchctl load -w ~/Library/LaunchAgents/com.github.gollum-startup.plist

自動的にgithubにpushするようにする

gollumはページを編集すると、ローカルレポジトリにcommitしてくれるので、
定期的にレポジトリをpushするようにしてあげる。

同期用のスクリプトを作る

sync.sh
#!/bin/bash
DIR="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
(cd $DIR && git pull && git push)

sync.shはwikiレポジトリと同じDirectoryにおいてあげる。

また、ローカルレポジトリのoriginにgithub(とか)を追加しておいてげる。

launchctl用のplistを用意する

~/Library/LaunchAgents/com.github.gollum-sync.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key>
  <string>com.github.gollum-sync</string>
  <key>RunAtLoad</key>
  <true/>
  <key>ProgramArguments</key>
  <array>
      <string>/Users/user-name/path/to/sync.sh</string>
  </array>
  <key>StartInterval</key>
  <integer>60</integer>

</dict>
</plist>

launchctlに追加

launchctl load -w ~/Library/LaunchAgents/com.github.gollum-sync.plist

確認

こんなかんじに見えるはず

launchctl list | grep gollum
2718    -   com.github.gollum-sync
1876    -   com.github.gollum-start
6
6
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
6
6