Sneaky.NET

Tom’s Home page

Ocotpress Entries

This is an entry about how to create entries. This is as much for myself (so I don’t have to struggle to remmeber) as for anyone else looking at Ocotpress.

Background

I recently decided to start posting on my blog again. This was after a year or more of doing nothing. So, I had to go back and remember how things worked. Not only this, but since I’ve rebuilt my desktop a few times since then.. I didn’t have ruby and the other pre-requisites for Ocotpress. (I’ll try to write up another post about how I did that.. but stupid Evernote lost the notes I was keeping.)

How I use Octopress

I wanted something easy to use for blogging and it had to be able to be done on the command line. I also would like to be able to update it from anywhere..

I wanted it to be CHEAP for hosting. I also didn’t want to have to maintain yet another server. (Yeah, I’m getting old.)

I use GitHub to store the octopress and “source” directory. This gives me a central place to store and upload edits. I also have a “publish” server that runs on my home servers. This is a simple OpenVZ container. I have ruby and ocotopress installed with some cron jobs. They push the “generated” ocotpress content out to an Amazon S3 bucket. That bucket is configured to serve the files in that bucket as web pages.

Workflow

The workflow goes something like this:

  1. Create/Update the post
  2. Commit and push the post up into my GitHub repo
  3. The “publish” server does a cron’d git pull followed by a rake generate and a rake s3

Typical update

  • I do a git pull to make sure I’ve got the latest code
  • I do my editing with VI
  • I review with git diff, then git add the file and finally a git commit.

Publish server

Manual update

The commands I manually run are below. These pull dow the site, generate it locally and then uplaod it to S3.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
[tomn@octopress www.sneaky.net]$ git pull && rake generate && rake s3
Already up-to-date.
## Generating Site with Jekyll
identical source/stylesheets/screen.css
Configuration file: /home/tomn/git/www.sneaky.net/_config.yml
            Source: source
       Destination: public
      Generating...
                    done.
 Auto-regeneration: disabled. Use --watch to enable.
## Deploying website via s3cmd
public/atom.xml -> s3://www.sneaky.net/atom.xml  [1 of 19]
 17675 of 17675   100% in    0s    32.17 kB/s  done
public/blog/categories/2013-05-25-wheezy-raspbian-dot-zip/atom.xml -> s3://www.sneaky.net/blog/categories/2013-05-25-wheezy-raspbian-dot-zip/atom.xml  [2 of 19]
 5734 of 5734   100% in    0s    13.08 kB/s  done
public/blog/categories/bluetooth/atom.xml -> s3://www.sneaky.net/blog/categories/bluetooth/atom.xml  [3 of 19]
 3387 of 3387   100% in    0s     7.35 kB/s  done
public/blog/categories/hc-05/atom.xml -> s3://www.sneaky.net/blog/categories/hc-05/atom.xml  [4 of 19]
 3379 of 3379   100% in    0s     7.86 kB/s  done
public/blog/categories/hc-06/atom.xml -> s3://www.sneaky.net/blog/categories/hc-06/atom.xml  [5 of 19]
 3379 of 3379   100% in    0s     7.58 kB/s  done
public/blog/categories/m4v/atom.xml -> s3://www.sneaky.net/blog/categories/m4v/atom.xml  [6 of 19]
 1632 of 1632   100% in    0s     3.84 kB/s  done
public/blog/categories/memory/atom.xml -> s3://www.sneaky.net/blog/categories/memory/atom.xml  [7 of 19]
 7955 of 7955   100% in    0s    17.22 kB/s  done
public/blog/categories/movies/atom.xml -> s3://www.sneaky.net/blog/categories/movies/atom.xml  [8 of 19]
 1638 of 1638   100% in    0s     3.74 kB/s  done
public/blog/categories/octopress/atom.xml -> s3://www.sneaky.net/blog/categories/octopress/atom.xml  [9 of 19]
 9896 of 9896   100% in    0s    18.50 kB/s  done
public/blog/categories/raspberry-pi/atom.xml -> s3://www.sneaky.net/blog/categories/raspberry-pi/atom.xml  [10 of 19]
 2802 of 2802   100% in    0s     6.47 kB/s  done
public/blog/categories/raspberrypi/atom.xml -> s3://www.sneaky.net/blog/categories/raspberrypi/atom.xml  [11 of 19]
 3391 of 3391   100% in    0s     7.61 kB/s  done
public/blog/categories/raspbian/atom.xml -> s3://www.sneaky.net/blog/categories/raspbian/atom.xml  [12 of 19]
 5686 of 5686   100% in    0s    12.66 kB/s  done
public/blog/categories/streamclip/atom.xml -> s3://www.sneaky.net/blog/categories/streamclip/atom.xml  [13 of 19]
 1646 of 1646   100% in    0s     3.70 kB/s  done
public/blog/categories/test/atom.xml -> s3://www.sneaky.net/blog/categories/test/atom.xml  [14 of 19]
 953 of 953   100% in    0s     2.02 kB/s  done
public/blog/categories/twonky/atom.xml -> s3://www.sneaky.net/blog/categories/twonky/atom.xml  [15 of 19]
 1638 of 1638   100% in    0s     3.65 kB/s  done
public/blog/categories/webdev/atom.xml -> s3://www.sneaky.net/blog/categories/webdev/atom.xml  [16 of 19]
 7955 of 7955   100% in    0s    16.88 kB/s  done
public/blog/categories/wifi/atom.xml -> s3://www.sneaky.net/blog/categories/wifi/atom.xml  [17 of 19]
 2786 of 2786   100% in    0s     6.22 kB/s  done
public/blog/categories/wlan/atom.xml -> s3://www.sneaky.net/blog/categories/wlan/atom.xml  [18 of 19]
 2786 of 2786   100% in    0s     6.33 kB/s  done
public/sitemap.xml -> s3://www.sneaky.net/sitemap.xml  [19 of 19]
 2117 of 2117   100% in    0s     4.51 kB/s  done
Done. Uploaded 86435 bytes in 8.5 seconds, 9.90 kB/s
OK
[tomn@octopress www.sneaky.net]$

Cron Automatic update

I run the following script (manually or from cron) and it does the update. Note, you will need to make sure your github ssh key is in your agent!

1
2
3
4
5
6
7
8
9
10
11
#!/bin/sh

source /etc/profile.d/rvm.sh

cd /home/tomn/git/www.sneaky.net

/usr/bin/git pull

/usr/local/rvm/gems/ruby-1.9.3-p547/bin/rake generate

/usr/local/rvm/gems/ruby-1.9.3-p547/bin/rake s3

Comments